diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 3202d925d7..881122fc7f 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -1,3 +1,15 @@ +2001-04-28 02:10 UTC-0800 Ron Pinkas + * include/hbapi.h + - Removed 2nd parameter from hb_arrayClone() declaration + + * source/vm/arrays.c + - Removed 2nd parameter from definition of hb_arrayClone(), added a static s_pClonedList instead. + + * source/vm/arrayshb.c + * source/vm/classes.c + * source/vm/hvm.c + - Removed 2nd parameter from calls to hb_arrayClone() + 2001-04-28 23:15 CET Martin Vogel + contrib/libct/atrepl.c diff --git a/harbour/include/hbapi.h b/harbour/include/hbapi.h index 4c9094aa36..7c2757d8a5 100644 --- a/harbour/include/hbapi.h +++ b/harbour/include/hbapi.h @@ -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, PHB_NESTED_CLONED pClonedList ); /* returns a duplicate of an existing array, including all nested items */ +extern PHB_ITEM hb_arrayClone( PHB_ITEM pArray ); /* 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. */ diff --git a/harbour/source/vm/arrays.c b/harbour/source/vm/arrays.c index fd2b2cc5e0..e772680e14 100644 --- a/harbour/source/vm/arrays.c +++ b/harbour/source/vm/arrays.c @@ -59,6 +59,9 @@ * hb_arrayCopyC() * hb_arrayGetC() * + * Copyright 2001 Ron Pinkas + * hb_arrayClone() + * * See doc/license.txt for licensing terms. * */ @@ -700,9 +703,11 @@ BOOL hb_arrayCopy( PHB_ITEM pSrcArray, PHB_ITEM pDstArray, ULONG * pulStart, return FALSE; } -PHB_ITEM hb_arrayClone( PHB_ITEM pSrcArray, PHB_NESTED_CLONED pClonedList ) +PHB_ITEM hb_arrayClone( PHB_ITEM pSrcArray ) { - HB_TRACE(HB_TR_DEBUG, ("hb_arrayClone(%p, %p)", pSrcArray, pClonedList)); + static PHB_NESTED_CLONED s_pClonedList; + + HB_TRACE(HB_TR_DEBUG, ("hb_arrayClone(%p)", pSrcArray)); if( HB_IS_ARRAY( pSrcArray ) ) { @@ -717,12 +722,12 @@ PHB_ITEM hb_arrayClone( PHB_ITEM pSrcArray, PHB_NESTED_CLONED pClonedList ) pDstArray = hb_itemNew( NULL ); hb_arrayNew( pDstArray, ulSrcLen ); - if( pClonedList == NULL ) + if( s_pClonedList == NULL ) { bTop = TRUE; - pClonedList = ( PHB_NESTED_CLONED ) hb_xgrab( sizeof( HB_NESTED_CLONED ) ); - pCloned = pClonedList; + s_pClonedList = ( PHB_NESTED_CLONED ) hb_xgrab( sizeof( HB_NESTED_CLONED ) ); + pCloned = s_pClonedList; pCloned->pSrcItems = pSrcArray->item.asArray.value->pItems; pCloned->pDest = pDstArray; @@ -733,7 +738,7 @@ PHB_ITEM hb_arrayClone( PHB_ITEM pSrcArray, PHB_NESTED_CLONED pClonedList ) { bTop = FALSE; - pCloned = pClonedList; + pCloned = s_pClonedList; while( pCloned->pNext ) { pCloned = pCloned->pNext; @@ -760,7 +765,7 @@ PHB_ITEM hb_arrayClone( PHB_ITEM pSrcArray, PHB_NESTED_CLONED pClonedList ) PHB_ITEM pClone; /* Broken down like this to avoid redandant comparisons. */ - pCloned = pClonedList; + pCloned = s_pClonedList; if( pCloned->pSrcItems == pSrcItem->item.asArray.value->pItems ) { pClone = pCloned->pDest; @@ -782,7 +787,7 @@ PHB_ITEM hb_arrayClone( PHB_ITEM pSrcArray, PHB_NESTED_CLONED pClonedList ) goto DontClone; } - pClone = hb_arrayClone( pSrcItem, pClonedList ); + pClone = hb_arrayClone( pSrcItem ); DontClone : hb_itemArrayPut( pDstArray, ulCount + 1, pClone ); @@ -796,10 +801,10 @@ PHB_ITEM hb_arrayClone( PHB_ITEM pSrcArray, PHB_NESTED_CLONED pClonedList ) /* Top Level - Release the created list. */ if( bTop ) { - while( pClonedList->pNext ) + while( s_pClonedList->pNext ) { - pCloned = pClonedList; - pClonedList = pClonedList->pNext; + pCloned = s_pClonedList; + s_pClonedList = s_pClonedList->pNext; if( pCloned->pDest != pDstArray ) { @@ -807,11 +812,14 @@ PHB_ITEM hb_arrayClone( PHB_ITEM pSrcArray, PHB_NESTED_CLONED pClonedList ) } hb_xfree( pCloned ); } - if( pClonedList->pDest != pDstArray ) + + if( s_pClonedList->pDest != pDstArray ) { - hb_itemRelease( pClonedList->pDest ); + hb_itemRelease( s_pClonedList->pDest ); } - hb_xfree( pClonedList ); + + hb_xfree( s_pClonedList ); + s_pClonedList = NULL; } return pDstArray; diff --git a/harbour/source/vm/arrayshb.c b/harbour/source/vm/arrayshb.c index 3d183b985c..2e724d5718 100644 --- a/harbour/source/vm/arrayshb.c +++ b/harbour/source/vm/arrayshb.c @@ -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, NULL ) ) ); /* AClone() returns the new array */ + hb_itemRelease( hb_itemReturn( hb_arrayClone( pSrcArray ) ) ); /* AClone() returns the new array */ } diff --git a/harbour/source/vm/classes.c b/harbour/source/vm/classes.c index deb59397d7..854343c028 100644 --- a/harbour/source/vm/classes.c +++ b/harbour/source/vm/classes.c @@ -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, NULL ); + pNewMeth->pInitValue = hb_arrayClone( pInit ); 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, NULL ); + pNewMeth->pInitValue = hb_arrayClone( pInit ); 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, NULL ); + pNewCls->pClassDatas = hb_arrayClone( pSprCls->pClassDatas ); - pNewCls->pInlines = hb_arrayClone( pSprCls->pInlines, NULL ); + pNewCls->pInlines = hb_arrayClone( pSprCls->pInlines ); pNewCls->uiDatasShared = pSprCls->uiDatasShared; @@ -1009,7 +1009,7 @@ HB_FUNC( __CLSNEW ) nLenDatas = ( USHORT ) pNewCls->uiDatas; /* ClassDatas */ - pClsAnyTmp = hb_arrayClone( pSprCls->pClassDatas, NULL ); + pClsAnyTmp = hb_arrayClone( pSprCls->pClassDatas ); 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, NULL ); + pClsAnyTmp = hb_arrayClone( pSprCls->pInlines ); 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, NULL ); + pNewCls->pMethods[ uiAt + uiBucket ].pInitValue = hb_arrayClone( pSprCls->pMethods[ ui ].pInitValue ); 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, NULL ); + pInit = hb_arrayClone( pMeth->pInitValue ); 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, NULL ); + pInitValue = hb_arrayClone( pMeth->pInitValue ); } 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, NULL ); + pInit = hb_arrayClone( pMeth->pInitValue ); 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, NULL ) ) ); + hb_itemRelease( hb_itemReturn( hb_arrayClone( pSrcObject ) ) ); else hb_errRT_BASE( EG_ARG, 3001, NULL, "__OBJCLONE", 0 ); } diff --git a/harbour/source/vm/hvm.c b/harbour/source/vm/hvm.c index 5211fc61f1..0b519adf47 100644 --- a/harbour/source/vm/hvm.c +++ b/harbour/source/vm/hvm.c @@ -4300,7 +4300,7 @@ void hb_vmRequestCancel( void ) * $End$ */ HB_FUNC( __VMVARSLIST ) { - PHB_ITEM pStatics = hb_arrayClone( &s_aStatics, NULL ); + PHB_ITEM pStatics = hb_arrayClone( &s_aStatics ); hb_itemCopy( &hb_stack.Return, pStatics ); hb_itemRelease( pStatics );