diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 65244b0cf7..85a4d8af12 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -8,6 +8,23 @@ 2002-12-01 23:12 UTC+0100 Foo Bar */ +2004-04-14 12:20 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) + * harbour/tests/bldtest/Makefile + * fixed typo in file name + + * xharbour/include/hbdefs.h + + added HB_COUNTER and HB_PTRDIFF types - first for reference + counters and second for any pointer differences and pointer to + integer conversions - this modification is synced with xHarbour + + * harbour/include/hbapi.h + * harbour/include/hbdefs.h + * harbour/source/rtl/philes.c + * harbour/source/vm/arrays.c + * harbour/source/vm/hvm.c + * harbour/source/vm/itemapi.c + * use HB_COUNTER type + 2004-04-09 15:00 UTC-0500 David G. Holm * source/rdd/dbfntx/dbfntx1.c ! Converted first parameter in the call to hb_fsCreateTemp from "" to diff --git a/harbour/include/hbapi.h b/harbour/include/hbapi.h index cf7a074740..2c6c082749 100644 --- a/harbour/include/hbapi.h +++ b/harbour/include/hbapi.h @@ -204,8 +204,8 @@ struct hb_struString SHORT bStatic; /* it is a static string from pcode or from a C string */ union { - char value[1]; - USHORT * puiHolders; /* number of holders of this string */ + char value[1]; + HB_COUNTER * pulHolders; /* number of holders of this string */ } u; }; @@ -241,23 +241,23 @@ typedef struct _HB_ITEM typedef struct _HB_BASEARRAY { - PHB_ITEM pItems; /* pointer to the array items */ - ULONG ulLen; /* number of items in the array */ - USHORT uiHolders; /* number of holders of this array */ - USHORT uiClass; /* offset to the classes base if it is an object */ - USHORT uiPrevCls; /* for fixing after access super */ - USHORT * puiClsTree; /* remember array of super called ID Tree */ + PHB_ITEM pItems; /* pointer to the array items */ + ULONG ulLen; /* number of items in the array */ + HB_COUNTER ulHolders; /* number of holders of this array */ + USHORT uiClass; /* offset to the classes base if it is an object */ + USHORT uiPrevCls; /* for fixing after access super */ + USHORT * puiClsTree; /* remember array of super called ID Tree */ } HB_BASEARRAY, * PHB_BASEARRAY, * HB_BASEARRAY_PTR; /* internal structure for codeblocks */ typedef struct _HB_CODEBLOCK { - BYTE * pCode; /* codeblock pcode */ - PHB_ITEM pLocals; /* table with referenced local variables */ - USHORT uiLocals; /* number of referenced local variables */ - PHB_SYMB pSymbols; /* codeblocks symbols */ - ULONG ulCounter; /* numer of references to this codeblock */ - BOOL dynBuffer; /* is pcode buffer allocated dynamically */ + BYTE * pCode; /* codeblock pcode */ + PHB_ITEM pLocals; /* table with referenced local variables */ + USHORT uiLocals; /* number of referenced local variables */ + PHB_SYMB pSymbols; /* codeblocks symbols */ + HB_COUNTER ulCounter; /* numer of references to this codeblock */ + BOOL dynBuffer; /* is pcode buffer allocated dynamically */ } HB_CODEBLOCK, * PHB_CODEBLOCK, * HB_CODEBLOCK_PTR; typedef struct _HB_VALUE diff --git a/harbour/include/hbdefs.h b/harbour/include/hbdefs.h index 1a1cc013f9..5f786d254d 100644 --- a/harbour/include/hbdefs.h +++ b/harbour/include/hbdefs.h @@ -148,6 +148,12 @@ #endif /* HB_DONT_DEFINE_BASIC_TYPES */ +/* type of reference counter */ +typedef ULONG HB_COUNTER; + +/* type for memory pointer diff */ +typedef ULONG HB_PTRDIFF; + #define HB_MAX( a, b ) ( ( ( a ) > ( b ) ) ? ( a ) : ( b ) ) #define HB_MIN( a, b ) ( ( ( a ) < ( b ) ) ? ( a ) : ( b ) ) diff --git a/harbour/source/rtl/philes.c b/harbour/source/rtl/philes.c index f2f60b2f9f..62c2cd806d 100644 --- a/harbour/source/rtl/philes.c +++ b/harbour/source/rtl/philes.c @@ -97,7 +97,7 @@ HB_FUNC( FREAD ) PHB_ITEM pItem = hb_itemUnRef( hb_stackItemFromBase( 2 ) ); if( pItem->item.asString.bStatic || - ( * pItem->item.asString.u.puiHolders ) > 1 ) + ( * pItem->item.asString.u.pulHolders ) > 1 ) // Warning: Don't use hb_itemPutC() here, as it fails if 1 byte buffer used // cause 1 byte length strings optimization hb_itemPutCPtr( pItem, hb_strdup( hb_parc( 2 ) ), hb_parclen( 2 ) ); diff --git a/harbour/source/vm/arrays.c b/harbour/source/vm/arrays.c index 36449d8175..b4c8435724 100644 --- a/harbour/source/vm/arrays.c +++ b/harbour/source/vm/arrays.c @@ -92,7 +92,7 @@ BOOL HB_EXPORT hb_arrayNew( PHB_ITEM pItem, ULONG ulLen ) /* creates a new array pBaseArray->pItems = NULL; pBaseArray->ulLen = ulLen; - pBaseArray->uiHolders = 1; + pBaseArray->ulHolders = 1; pBaseArray->uiClass = 0; pBaseArray->uiPrevCls = 0; @@ -860,7 +860,7 @@ PHB_ITEM hb_arrayFromStack( USHORT uiLen ) pBaseArray->pItems = NULL; pBaseArray->ulLen = uiLen; - pBaseArray->uiHolders = 1; + pBaseArray->ulHolders = 1; pBaseArray->uiClass = 0; pBaseArray->uiPrevCls = 0; @@ -890,7 +890,7 @@ PHB_ITEM hb_arrayFromParams( PHB_ITEM *pBase ) pBaseArray->pItems = NULL; pBaseArray->ulLen = uiPCount; - pBaseArray->uiHolders = 1; + pBaseArray->ulHolders = 1; pBaseArray->uiClass = 0; pBaseArray->uiPrevCls = 0; diff --git a/harbour/source/vm/hvm.c b/harbour/source/vm/hvm.c index ef4c576b86..a253c60513 100644 --- a/harbour/source/vm/hvm.c +++ b/harbour/source/vm/hvm.c @@ -2915,7 +2915,7 @@ static void hb_vmArrayPush( void ) { if( ulIndex > 0 && ulIndex <= pArray->item.asArray.value->ulLen ) { - if( pArray->item.asArray.value->uiHolders > 1 ) + if( pArray->item.asArray.value->ulHolders > 1 ) { /* this is a temporary copy of an array - we can overwrite * it with no problem @@ -2977,7 +2977,7 @@ static void hb_vmArrayPop( void ) { if( ulIndex > 0 && ulIndex <= pArray->item.asString.length ) { - if( pArray->item.asString.bStatic || *( pArray->item.asString.u.puiHolders ) > 1 ) + if( pArray->item.asString.bStatic || *( pArray->item.asString.u.pulHolders ) > 1 ) hb_itemPutC( pArray, pArray->item.asString.value ); pArray->item.asString.value[ ulIndex - 1 ] = hb_itemGetNI( pValue ); @@ -4139,8 +4139,8 @@ void hb_vmPushString( char * szText, ULONG length ) pStackTopItem->item.asString.value = szTemp; pStackTopItem->item.asString.bStatic = 0; - pStackTopItem->item.asString.u.puiHolders = ( USHORT * ) hb_xgrab( sizeof( USHORT ) ); - *( pStackTopItem->item.asString.u.puiHolders ) = 1; + pStackTopItem->item.asString.u.pulHolders = ( HB_COUNTER * ) hb_xgrab( sizeof( HB_COUNTER ) ); + *( pStackTopItem->item.asString.u.pulHolders ) = 1; } hb_stackPush(); } diff --git a/harbour/source/vm/itemapi.c b/harbour/source/vm/itemapi.c index 576c7ba880..7adb8e0dd9 100644 --- a/harbour/source/vm/itemapi.c +++ b/harbour/source/vm/itemapi.c @@ -223,8 +223,8 @@ PHB_ITEM hb_itemPutC( PHB_ITEM pItem, char * szText ) pItem->item.asString.length = strlen( szText ); pItem->item.asString.value = ( char * ) hb_xgrab( pItem->item.asString.length + 1 ); pItem->item.asString.bStatic = 0; - pItem->item.asString.u.puiHolders = ( USHORT * ) hb_xgrab( sizeof( USHORT ) ); - * ( pItem->item.asString.u.puiHolders ) = 1; + pItem->item.asString.u.pulHolders = ( HB_COUNTER * ) hb_xgrab( sizeof( HB_COUNTER ) ); + * ( pItem->item.asString.u.pulHolders ) = 1; strcpy( pItem->item.asString.value, szText ); } @@ -289,8 +289,8 @@ PHB_ITEM hb_itemPutCL( PHB_ITEM pItem, char * szText, ULONG ulLen ) pItem->item.asString.length = ulLen; pItem->item.asString.value = ( char * ) hb_xgrab( ulLen + 1 ); pItem->item.asString.bStatic = 0; - pItem->item.asString.u.puiHolders = ( USHORT * ) hb_xgrab( sizeof( USHORT ) ); - * ( pItem->item.asString.u.puiHolders ) = 1; + pItem->item.asString.u.pulHolders = ( HB_COUNTER * ) hb_xgrab( sizeof( HB_COUNTER ) ); + * ( pItem->item.asString.u.pulHolders ) = 1; hb_xmemcpy( pItem->item.asString.value, szText, ulLen ); pItem->item.asString.value[ ulLen ] = '\0'; } @@ -312,8 +312,8 @@ PHB_ITEM hb_itemPutCPtr( PHB_ITEM pItem, char * szText, ULONG ulLen ) pItem->item.asString.value = szText; pItem->item.asString.value[ ulLen ] = '\0'; pItem->item.asString.bStatic = 0; - pItem->item.asString.u.puiHolders = ( USHORT * ) hb_xgrab( sizeof( USHORT ) ); - * ( pItem->item.asString.u.puiHolders ) = 1; + pItem->item.asString.u.pulHolders = ( HB_COUNTER * ) hb_xgrab( sizeof( HB_COUNTER ) ); + * ( pItem->item.asString.u.pulHolders ) = 1; return pItem; } @@ -872,18 +872,18 @@ void hb_itemClear( PHB_ITEM pItem ) pItem->item.asString.value = NULL; else { - if( --*( pItem->item.asString.u.puiHolders ) == 0 ) + if( --*( pItem->item.asString.u.pulHolders ) == 0 ) { hb_xfree( pItem->item.asString.value ); pItem->item.asString.value = NULL; - hb_xfree( pItem->item.asString.u.puiHolders ); + hb_xfree( pItem->item.asString.u.pulHolders ); } } pItem->item.asString.length = 0; } else if( HB_IS_ARRAY( pItem ) && pItem->item.asArray.value ) { - if( --( pItem->item.asArray.value )->uiHolders == 0 ) + if( --( pItem->item.asArray.value )->ulHolders == 0 ) hb_arrayRelease( pItem ); } else if( HB_IS_BLOCK( pItem ) ) @@ -912,11 +912,11 @@ void hb_itemCopy( PHB_ITEM pDest, PHB_ITEM pSource ) if( HB_IS_STRING( pSource ) ) { if( !pSource->item.asString.bStatic ) - ++*( pSource->item.asString.u.puiHolders ); + ++*( pSource->item.asString.u.pulHolders ); } else if( HB_IS_ARRAY( pSource ) ) { - ( pSource->item.asArray.value )->uiHolders++; + ( pSource->item.asArray.value )->ulHolders++; } else if( HB_IS_BLOCK( pSource ) ) { diff --git a/harbour/tests/bldtest/Makefile b/harbour/tests/bldtest/Makefile index 063f154f5b..4c3aa6f2e4 100644 --- a/harbour/tests/bldtest/Makefile +++ b/harbour/tests/bldtest/Makefile @@ -6,7 +6,7 @@ ROOT = ../../ C_SOURCES=\ -C_MAIN=endian.c +C_MAIN=bldtest.c LIBS=\