2001-05-02 11:05 UTC-0800 Ron Pinkas <ron@profit-master.com>
* include/hbapi.h
* Changed HB_NESTED_CLONED to record BaseArray instead of first item.
* Reverted declaration of hb_arrayClone to use 2nd paramater ( pClonedList ) for futute Thread Safety.
* source/vm/arrays.c
* Corrected handling of nested (shared) empty array in hb_arrayClone().
* Reverted definition of hb_arrayClone() to use 2nd parameter ( pClonedList ) for future Thread Safety.
* source/vm/arrayshb.c
* source/vm/classes.c
* source/vm/hvm.c
* Added required 2nd parameter ( NULL ) to calls to hb_arrayClone()
This commit is contained in:
@@ -1,3 +1,17 @@
|
||||
2001-05-02 11:05 UTC-0800 Ron Pinkas <ron@profit-master.com>
|
||||
* include/hbapi.h
|
||||
* Changed HB_NESTED_CLONED to record BaseArray instead of first item.
|
||||
* Reverted declaration of hb_arrayClone to use 2nd paramater ( pClonedList ) for futute Thread Safety.
|
||||
|
||||
* source/vm/arrays.c
|
||||
* Corrected handling of nested (shared) empty array in hb_arrayClone().
|
||||
* Reverted definition of hb_arrayClone() to use 2nd parameter ( pClonedList ) for future Thread Safety.
|
||||
|
||||
* source/vm/arrayshb.c
|
||||
* source/vm/classes.c
|
||||
* source/vm/hvm.c
|
||||
* Added required 2nd parameter ( NULL ) to calls to hb_arrayClone()
|
||||
|
||||
2001-05-01 02:35 UTC-0800 Ron Pinkas <ron@profit-master.com>
|
||||
* contrib/dot/rp_run.ch
|
||||
* contrib/dot/pp.prg
|
||||
|
||||
@@ -258,7 +258,7 @@ typedef struct _HB_VALUE
|
||||
|
||||
typedef struct _HB_NESTED_CLONED
|
||||
{
|
||||
PHB_ITEM pSrcItems;
|
||||
PHB_BASEARRAY pSrcBaseArray;
|
||||
PHB_ITEM pDest;
|
||||
struct _HB_NESTED_CLONED * pNext;
|
||||
} HB_NESTED_CLONED, * PHB_NESTED_CLONED;
|
||||
@@ -385,7 +385,7 @@ extern BOOL hb_arrayFill( PHB_ITEM pArray, PHB_ITEM pValue, ULONG * pulStart
|
||||
extern ULONG hb_arrayScan( PHB_ITEM pArray, PHB_ITEM pValue, ULONG * pulStart, ULONG * pulCount ); /* scan an array for a given item, or until code-block item returns TRUE */
|
||||
extern BOOL hb_arrayEval( PHB_ITEM pArray, PHB_ITEM bBlock, ULONG * pulStart, ULONG * pulCount ); /* execute a code-block for every element of an array item */
|
||||
extern BOOL hb_arrayCopy( PHB_ITEM pSrcArray, PHB_ITEM pDstArray, ULONG * pulStart, ULONG * pulCount, ULONG * pulTarget ); /* copy items from one array to another */
|
||||
extern PHB_ITEM hb_arrayClone( PHB_ITEM pArray ); /* returns a duplicate of an existing array, including all nested items */
|
||||
extern PHB_ITEM hb_arrayClone( PHB_ITEM pArray, PHB_NESTED_CLONED pClonedList ); /* returns a duplicate of an existing array, including all nested items */
|
||||
extern BOOL hb_arraySort( PHB_ITEM pArray, ULONG * pulStart, ULONG * pulCount, PHB_ITEM pBlock ); /* sorts an array item */
|
||||
extern PHB_ITEM hb_arrayFromStack( USHORT uiLen ); /* Creates and returns an Array of n Elements from the Eval Stack - Does NOT pop the items. */
|
||||
extern PHB_ITEM hb_arrayFromParams( void ); /* Creates and returns an Array of current Generic Parameters. */
|
||||
|
||||
@@ -703,11 +703,9 @@ BOOL hb_arrayCopy( PHB_ITEM pSrcArray, PHB_ITEM pDstArray, ULONG * pulStart,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
PHB_ITEM hb_arrayClone( PHB_ITEM pSrcArray )
|
||||
PHB_ITEM hb_arrayClone( PHB_ITEM pSrcArray, PHB_NESTED_CLONED pClonedList )
|
||||
{
|
||||
static PHB_NESTED_CLONED s_pClonedList;
|
||||
|
||||
HB_TRACE(HB_TR_DEBUG, ("hb_arrayClone(%p)", pSrcArray));
|
||||
HB_TRACE(HB_TR_DEBUG, ("hb_arrayClone(%p, %p)", pSrcArray, pClonedList));
|
||||
|
||||
if( HB_IS_ARRAY( pSrcArray ) )
|
||||
{
|
||||
@@ -722,14 +720,14 @@ PHB_ITEM hb_arrayClone( PHB_ITEM pSrcArray )
|
||||
pDstArray = hb_itemNew( NULL );
|
||||
hb_arrayNew( pDstArray, ulSrcLen );
|
||||
|
||||
if( s_pClonedList == NULL )
|
||||
if( pClonedList == NULL )
|
||||
{
|
||||
bTop = TRUE;
|
||||
|
||||
s_pClonedList = ( PHB_NESTED_CLONED ) hb_xgrab( sizeof( HB_NESTED_CLONED ) );
|
||||
pCloned = s_pClonedList;
|
||||
pClonedList = ( PHB_NESTED_CLONED ) hb_xgrab( sizeof( HB_NESTED_CLONED ) );
|
||||
pCloned = pClonedList;
|
||||
|
||||
pCloned->pSrcItems = pSrcArray->item.asArray.value->pItems;
|
||||
pCloned->pSrcBaseArray = pSrcArray->item.asArray.value;
|
||||
pCloned->pDest = pDstArray;
|
||||
|
||||
pCloned->pNext = NULL;
|
||||
@@ -738,7 +736,7 @@ PHB_ITEM hb_arrayClone( PHB_ITEM pSrcArray )
|
||||
{
|
||||
bTop = FALSE;
|
||||
|
||||
pCloned = s_pClonedList;
|
||||
pCloned = pClonedList;
|
||||
while( pCloned->pNext )
|
||||
{
|
||||
pCloned = pCloned->pNext;
|
||||
@@ -747,7 +745,7 @@ PHB_ITEM hb_arrayClone( PHB_ITEM pSrcArray )
|
||||
pCloned->pNext = ( PHB_NESTED_CLONED ) hb_xgrab( sizeof( HB_NESTED_CLONED ) );
|
||||
pCloned = pCloned->pNext;
|
||||
|
||||
pCloned->pSrcItems = pSrcArray->item.asArray.value->pItems;
|
||||
pCloned->pSrcBaseArray = pSrcArray->item.asArray.value;
|
||||
pCloned->pDest = pDstArray;
|
||||
|
||||
pCloned->pNext = NULL;
|
||||
@@ -764,9 +762,9 @@ PHB_ITEM hb_arrayClone( PHB_ITEM pSrcArray )
|
||||
{
|
||||
PHB_ITEM pClone;
|
||||
|
||||
/* Broken down like this to avoid redandant comparisons. */
|
||||
pCloned = s_pClonedList;
|
||||
if( pCloned->pSrcItems == pSrcItem->item.asArray.value->pItems )
|
||||
/* Broken down like this to avoid redundant comparisons. */
|
||||
pCloned = pClonedList;
|
||||
if( pCloned->pSrcBaseArray == pSrcItem->item.asArray.value )
|
||||
{
|
||||
pClone = pCloned->pDest;
|
||||
goto DontClone;
|
||||
@@ -775,19 +773,19 @@ PHB_ITEM hb_arrayClone( PHB_ITEM pSrcArray )
|
||||
{
|
||||
pCloned = pCloned->pNext;
|
||||
|
||||
if( pCloned->pSrcItems == pSrcItem->item.asArray.value->pItems )
|
||||
if( pCloned->pSrcBaseArray == pSrcItem->item.asArray.value )
|
||||
{
|
||||
pClone = pCloned->pDest;
|
||||
goto DontClone;
|
||||
}
|
||||
}
|
||||
if( pCloned->pSrcItems == pSrcItem->item.asArray.value->pItems )
|
||||
if( pCloned->pSrcBaseArray == pSrcItem->item.asArray.value )
|
||||
{
|
||||
pClone = pCloned->pDest;
|
||||
goto DontClone;
|
||||
}
|
||||
|
||||
pClone = hb_arrayClone( pSrcItem );
|
||||
pClone = hb_arrayClone( pSrcItem, pClonedList );
|
||||
|
||||
DontClone :
|
||||
hb_itemArrayPut( pDstArray, ulCount + 1, pClone );
|
||||
@@ -801,10 +799,10 @@ PHB_ITEM hb_arrayClone( PHB_ITEM pSrcArray )
|
||||
/* Top Level - Release the created list. */
|
||||
if( bTop )
|
||||
{
|
||||
while( s_pClonedList->pNext )
|
||||
while( pClonedList->pNext )
|
||||
{
|
||||
pCloned = s_pClonedList;
|
||||
s_pClonedList = s_pClonedList->pNext;
|
||||
pCloned = pClonedList;
|
||||
pClonedList = pClonedList->pNext;
|
||||
|
||||
if( pCloned->pDest != pDstArray )
|
||||
{
|
||||
@@ -813,13 +811,12 @@ PHB_ITEM hb_arrayClone( PHB_ITEM pSrcArray )
|
||||
hb_xfree( pCloned );
|
||||
}
|
||||
|
||||
if( s_pClonedList->pDest != pDstArray )
|
||||
if( pClonedList->pDest != pDstArray )
|
||||
{
|
||||
hb_itemRelease( s_pClonedList->pDest );
|
||||
hb_itemRelease( pClonedList->pDest );
|
||||
}
|
||||
|
||||
hb_xfree( s_pClonedList );
|
||||
s_pClonedList = NULL;
|
||||
hb_xfree( pClonedList );
|
||||
}
|
||||
|
||||
return pDstArray;
|
||||
|
||||
@@ -288,6 +288,6 @@ HB_FUNC( ACLONE )
|
||||
PHB_ITEM pSrcArray = hb_param( 1, HB_IT_ARRAY );
|
||||
|
||||
if( pSrcArray && ! hb_arrayIsObject( pSrcArray ) )
|
||||
hb_itemRelease( hb_itemReturn( hb_arrayClone( pSrcArray ) ) ); /* AClone() returns the new array */
|
||||
hb_itemRelease( hb_itemReturn( hb_arrayClone( pSrcArray, NULL ) ) ); /* AClone() returns the new array */
|
||||
}
|
||||
|
||||
|
||||
@@ -823,7 +823,7 @@ HB_FUNC( __CLSADDMSG )
|
||||
if( pInit && ! HB_IS_NIL( pInit ) ) /* Initializer found */
|
||||
{
|
||||
if( HB_IS_ARRAY( pInit ) )
|
||||
pNewMeth->pInitValue = hb_arrayClone( pInit );
|
||||
pNewMeth->pInitValue = hb_arrayClone( pInit, NULL );
|
||||
else
|
||||
{
|
||||
pNewMeth->pInitValue = hb_itemNew( NULL );
|
||||
@@ -850,7 +850,7 @@ HB_FUNC( __CLSADDMSG )
|
||||
if( pInit && ! HB_IS_NIL( pInit ) ) /* Initializer found */
|
||||
{
|
||||
if( HB_IS_ARRAY( pInit ) )
|
||||
pNewMeth->pInitValue = hb_arrayClone( pInit );
|
||||
pNewMeth->pInitValue = hb_arrayClone( pInit, NULL );
|
||||
else
|
||||
{
|
||||
pNewMeth->pInitValue = hb_itemNew( NULL );
|
||||
@@ -994,9 +994,9 @@ HB_FUNC( __CLSNEW )
|
||||
pNewCls->uiHashKey = pSprCls->uiHashKey;
|
||||
|
||||
/* CLASS DATA Not Shared ( new array, new value ) */
|
||||
pNewCls->pClassDatas = hb_arrayClone( pSprCls->pClassDatas );
|
||||
pNewCls->pClassDatas = hb_arrayClone( pSprCls->pClassDatas, NULL );
|
||||
|
||||
pNewCls->pInlines = hb_arrayClone( pSprCls->pInlines );
|
||||
pNewCls->pInlines = hb_arrayClone( pSprCls->pInlines, NULL );
|
||||
|
||||
pNewCls->uiDatasShared = pSprCls->uiDatasShared;
|
||||
|
||||
@@ -1009,7 +1009,7 @@ HB_FUNC( __CLSNEW )
|
||||
nLenDatas = ( USHORT ) pNewCls->uiDatas;
|
||||
|
||||
/* ClassDatas */
|
||||
pClsAnyTmp = hb_arrayClone( pSprCls->pClassDatas );
|
||||
pClsAnyTmp = hb_arrayClone( pSprCls->pClassDatas, NULL );
|
||||
nLen = ( USHORT ) hb_itemSize( pClsAnyTmp );
|
||||
for( ui = 1; ui <= nLen; ui++ )
|
||||
{
|
||||
@@ -1024,7 +1024,7 @@ HB_FUNC( __CLSNEW )
|
||||
pNewCls->uiDatasShared += pSprCls->uiDatasShared;
|
||||
|
||||
/* Inlines */
|
||||
pClsAnyTmp = hb_arrayClone( pSprCls->pInlines );
|
||||
pClsAnyTmp = hb_arrayClone( pSprCls->pInlines, NULL );
|
||||
nLen = ( USHORT ) hb_itemSize( pClsAnyTmp );
|
||||
for( ui = 1; ui <= nLen; ui++ )
|
||||
{
|
||||
@@ -1122,7 +1122,7 @@ HB_FUNC( __CLSNEW )
|
||||
PHB_ITEM pInitValue;
|
||||
|
||||
if( HB_IS_ARRAY( pSprCls->pMethods[ ui ].pInitValue ) )
|
||||
pNewCls->pMethods[ uiAt + uiBucket ].pInitValue = hb_arrayClone( pSprCls->pMethods[ ui ].pInitValue );
|
||||
pNewCls->pMethods[ uiAt + uiBucket ].pInitValue = hb_arrayClone( pSprCls->pMethods[ ui ].pInitValue, NULL );
|
||||
else
|
||||
{
|
||||
pInitValue = hb_itemNew( NULL );
|
||||
@@ -1353,7 +1353,7 @@ static PHB_ITEM hb_clsInst( USHORT uiClass, PHB_ITEM * * ppObjects, USHORT * pui
|
||||
{
|
||||
|
||||
if( HB_IS_ARRAY( pMeth->pInitValue ) )
|
||||
pInit = hb_arrayClone( pMeth->pInitValue );
|
||||
pInit = hb_arrayClone( pMeth->pInitValue, NULL );
|
||||
else
|
||||
{
|
||||
pInit = hb_itemNew( NULL );
|
||||
@@ -1414,7 +1414,7 @@ static PHB_ITEM hb_clsInst( USHORT uiClass, PHB_ITEM * * ppObjects, USHORT * pui
|
||||
|
||||
if( HB_IS_ARRAY( pMeth->pInitValue ) )
|
||||
{
|
||||
pInitValue = hb_arrayClone( pMeth->pInitValue );
|
||||
pInitValue = hb_arrayClone( pMeth->pInitValue, NULL );
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1439,7 +1439,7 @@ static PHB_ITEM hb_clsInst( USHORT uiClass, PHB_ITEM * * ppObjects, USHORT * pui
|
||||
{
|
||||
|
||||
if( HB_IS_ARRAY( pMeth->pInitValue ) )
|
||||
pInit = hb_arrayClone( pMeth->pInitValue );
|
||||
pInit = hb_arrayClone( pMeth->pInitValue, NULL );
|
||||
else
|
||||
{
|
||||
pInit = hb_itemNew( NULL );
|
||||
@@ -1571,7 +1571,7 @@ HB_FUNC( __OBJCLONE )
|
||||
PHB_ITEM pSrcObject = hb_param( 1, HB_IT_OBJECT );
|
||||
|
||||
if( pSrcObject )
|
||||
hb_itemRelease( hb_itemReturn( hb_arrayClone( pSrcObject ) ) );
|
||||
hb_itemRelease( hb_itemReturn( hb_arrayClone( pSrcObject, NULL ) ) );
|
||||
else
|
||||
hb_errRT_BASE( EG_ARG, 3001, NULL, "__OBJCLONE", 0 );
|
||||
}
|
||||
|
||||
@@ -4300,7 +4300,7 @@ void hb_vmRequestCancel( void )
|
||||
* $End$ */
|
||||
HB_FUNC( __VMVARSLIST )
|
||||
{
|
||||
PHB_ITEM pStatics = hb_arrayClone( &s_aStatics );
|
||||
PHB_ITEM pStatics = hb_arrayClone( &s_aStatics, NULL );
|
||||
|
||||
hb_itemCopy( &hb_stack.Return, pStatics );
|
||||
hb_itemRelease( pStatics );
|
||||
|
||||
Reference in New Issue
Block a user