diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 5194b12478..0d0909517d 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -17,6 +17,13 @@ past entries belonging to author(s): Viktor Szakats. */ +2010-02-06 14:00 UTC+0100 Viktor Szakats (harbour.01 syenar.hu) + * src/vm/garbage.c + * src/vm/fm.c + * src/vm/vm.c + * include/hbapi.h + * ULONG -> HB_SIZE in memory allocation functions. + 2010-02-06 12:46 UTC+0100 Viktor Szakats (harbour.01 syenar.hu) * src/rdd/dbf1.c * src/compiler/hbopt.c diff --git a/harbour/include/hbapi.h b/harbour/include/hbapi.h index 7a034da6d8..dec805070a 100644 --- a/harbour/include/hbapi.h +++ b/harbour/include/hbapi.h @@ -486,11 +486,11 @@ extern HB_SYMB hb_symEval; extern HB_EXPORT void hb_xinit( void ); /* Initialize fixed memory subsystem */ extern HB_EXPORT void hb_xexit( void ); /* Deinitialize fixed memory subsystem */ -extern HB_EXPORT void * hb_xalloc( ULONG ulSize ); /* allocates memory, returns NULL on failure */ -extern HB_EXPORT void * hb_xgrab( ULONG ulSize ) HB_MALLOC_ATTR HB_ALLOC_SIZE_ATTR( 1 ); /* allocates memory, exits on failure */ +extern HB_EXPORT void * hb_xalloc( HB_SIZE ulSize ); /* allocates memory, returns NULL on failure */ +extern HB_EXPORT void * hb_xgrab( HB_SIZE ulSize ) HB_MALLOC_ATTR HB_ALLOC_SIZE_ATTR( 1 ); /* allocates memory, exits on failure */ extern HB_EXPORT void hb_xfree( void * pMem ); /* frees memory */ -extern HB_EXPORT void * hb_xrealloc( void * pMem, ULONG ulSize ) HB_ALLOC_SIZE_ATTR( 2 ); /* reallocates memory */ -extern HB_EXPORT ULONG hb_xsize( void * pMem ); /* returns the size of an allocated memory block */ +extern HB_EXPORT void * hb_xrealloc( void * pMem, HB_SIZE ulSize ) HB_ALLOC_SIZE_ATTR( 2 ); /* reallocates memory */ +extern HB_EXPORT HB_SIZE hb_xsize( void * pMem ); /* returns the size of an allocated memory block */ extern HB_EXPORT ULONG hb_xquery( int iMode ); /* Query different types of memory information */ extern HB_EXPORT HB_BOOL hb_xtraced( void ); extern HB_EXPORT void hb_xsetfilename( const char * szValue ); @@ -506,7 +506,7 @@ extern void hb_xRefInc( void * pMem ); /* increment reference counter * extern HB_BOOL hb_xRefDec( void * pMem ); /* decrement reference counter, return HB_TRUE when 0 reached */ extern void hb_xRefFree( void * pMem ); /* decrement reference counter and free the block when 0 reached */ extern HB_COUNTER hb_xRefCount( void * pMem ); /* return number of references */ -extern void * hb_xRefResize( void * pMem, ULONG ulSave, ULONG ulSize, ULONG * pulAllocated ); /* reallocates memory, create copy if reference counter greater then 1 */ +extern void * hb_xRefResize( void * pMem, HB_SIZE ulSave, HB_SIZE ulSize, HB_SIZE * pulAllocated ); /* reallocates memory, create copy if reference counter greater then 1 */ #if 0 @@ -550,22 +550,22 @@ extern HB_EXPORT void * hb_xmemset( void * pDestArg, int iFill, HB_SIZE ulLen ); /* virtual memory */ typedef ULONG HB_VMHANDLE; -extern HB_EXPORT HB_VMHANDLE hb_xvalloc( ULONG nSize, USHORT nFlags ); +extern HB_EXPORT HB_VMHANDLE hb_xvalloc( HB_SIZE nSize, USHORT nFlags ); extern HB_EXPORT void hb_xvfree( HB_VMHANDLE h ); -extern HB_EXPORT HB_VMHANDLE hb_xvrealloc( HB_VMHANDLE h, ULONG nSize, USHORT nFlags ); +extern HB_EXPORT HB_VMHANDLE hb_xvrealloc( HB_VMHANDLE h, HB_SIZE nSize, USHORT nFlags ); extern HB_EXPORT void * hb_xvlock( HB_VMHANDLE h ); extern HB_EXPORT void hb_xvunlock( HB_VMHANDLE h ); extern HB_EXPORT void * hb_xvwire( HB_VMHANDLE h ); extern HB_EXPORT void hb_xvunwire( HB_VMHANDLE h ); -extern HB_EXPORT ULONG hb_xvlockcount( HB_VMHANDLE h ); -extern HB_EXPORT ULONG hb_xvsize( HB_VMHANDLE h ); -extern HB_EXPORT HB_VMHANDLE hb_xvheapnew( ULONG nSize ); +extern HB_EXPORT HB_SIZE hb_xvlockcount( HB_VMHANDLE h ); +extern HB_EXPORT HB_SIZE hb_xvsize( HB_VMHANDLE h ); +extern HB_EXPORT HB_VMHANDLE hb_xvheapnew( HB_SIZE nSize ); extern HB_EXPORT void hb_xvheapdestroy( HB_VMHANDLE h ); -extern HB_EXPORT HB_VMHANDLE hb_xvheapresize( HB_VMHANDLE h, ULONG nSize ); -extern HB_EXPORT ULONG hb_xvheapalloc( HB_VMHANDLE h, ULONG nSize ); -extern HB_EXPORT void hb_xvheapfree( HB_VMHANDLE h, ULONG nOffset ); -extern HB_EXPORT void * hb_xvheaplock( HB_VMHANDLE h, ULONG nOffset ); -extern HB_EXPORT void hb_xvheapunlock( HB_VMHANDLE h, ULONG nOffset ); +extern HB_EXPORT HB_VMHANDLE hb_xvheapresize( HB_VMHANDLE h, HB_SIZE nSize ); +extern HB_EXPORT HB_SIZE hb_xvheapalloc( HB_VMHANDLE h, HB_SIZE nSize ); +extern HB_EXPORT void hb_xvheapfree( HB_VMHANDLE h, HB_SIZE nOffset ); +extern HB_EXPORT void * hb_xvheaplock( HB_VMHANDLE h, HB_SIZE nOffset ); +extern HB_EXPORT void hb_xvheapunlock( HB_VMHANDLE h, HB_SIZE nOffset ); /* garbage collector */ #define HB_GARBAGE_FUNC( hbfunc ) void hbfunc( void * Cargo ) /* callback function for cleaning garbage memory pointer */ @@ -579,7 +579,7 @@ typedef struct } HB_GC_FUNCS; -extern HB_EXPORT void * hb_gcAllocate( ULONG ulSize, const HB_GC_FUNCS * pFuncs ); /* allocates a memory controlled by the garbage collector */ +extern HB_EXPORT void * hb_gcAllocate( HB_SIZE ulSize, const HB_GC_FUNCS * pFuncs ); /* allocates a memory controlled by the garbage collector */ extern HB_EXPORT void hb_gcFree( void * pAlloc ); /* deallocates a memory allocated by the garbage collector */ extern HB_EXPORT void * hb_gcLock( void * pAlloc ); /* do not release passed memory block */ extern HB_EXPORT void * hb_gcUnlock( void * pAlloc ); /* passed block is allowed to be released */ @@ -593,13 +593,13 @@ extern PHB_ITEM hb_gcGripGet( HB_ITEM_PTR pItem ); extern void hb_gcGripDrop( HB_ITEM_PTR pItem ); #ifdef HB_LEGACY_LEVEL2 -extern HB_EXPORT void * hb_gcAlloc( ULONG ulSize, HB_GARBAGE_FUNC_PTR pCleanupFunc ); +extern HB_EXPORT void * hb_gcAlloc( HB_SIZE ulSize, HB_GARBAGE_FUNC_PTR pCleanupFunc ); #endif #ifdef _HB_API_INTERNAL_ extern const HB_GC_FUNCS * hb_gcFuncs( void *pBlock ); /* return cleanup function pointer */ extern void hb_gcAttach( void * pBlock ); -extern void * hb_gcAllocRaw( ULONG ulSize, const HB_GC_FUNCS * pFuncs ); /* allocates a memory controlled by the garbage collector */ +extern void * hb_gcAllocRaw( HB_SIZE ulSize, const HB_GC_FUNCS * pFuncs ); /* allocates a memory controlled by the garbage collector */ extern void hb_gcGripMark( void * Cargo ); /* mark complex variables inside given item as used */ extern void hb_gcItemRef( HB_ITEM_PTR pItem ); /* mark complex variables inside given item as used */ extern void hb_vmIsStackRef( void ); /* hvm.c - mark all local variables as used */ diff --git a/harbour/src/vm/fm.c b/harbour/src/vm/fm.c index 5c7c6241bf..b25fadb710 100644 --- a/harbour/src/vm/fm.c +++ b/harbour/src/vm/fm.c @@ -270,7 +270,7 @@ static HB_BOOL s_fInitedFM = HB_FALSE; typedef struct _HB_MEMINFO { UINT32 u32Signature; - ULONG ulSize; + HB_SIZE ulSize; USHORT uiProcLine; char szProcName[ HB_SYMBOL_NAME_LEN + 1 ]; struct _HB_MEMINFO * pPrevBlock; @@ -561,7 +561,7 @@ void hb_xsetinfo( const char * szValue ) #endif } -void * hb_xalloc( ULONG ulSize ) /* allocates fixed memory, returns NULL on failure */ +void * hb_xalloc( HB_SIZE ulSize ) /* allocates fixed memory, returns NULL on failure */ { PHB_MEMINFO pMem; @@ -647,7 +647,7 @@ void * hb_xalloc( ULONG ulSize ) /* allocates fixed memory, returns NULL return HB_MEM_PTR( pMem ); } -void * hb_xgrab( ULONG ulSize ) /* allocates fixed memory, exits on failure */ +void * hb_xgrab( HB_SIZE ulSize ) /* allocates fixed memory, exits on failure */ { PHB_MEMINFO pMem; @@ -733,7 +733,7 @@ void * hb_xgrab( ULONG ulSize ) /* allocates fixed memory, exits on fail return HB_MEM_PTR( pMem ); } -void * hb_xrealloc( void * pMem, ULONG ulSize ) /* reallocates memory */ +void * hb_xrealloc( void * pMem, HB_SIZE ulSize ) /* reallocates memory */ { HB_TRACE_FM(HB_TR_DEBUG, ("hb_xrealloc(%p, %lu)", pMem, ulSize)); @@ -761,7 +761,7 @@ void * hb_xrealloc( void * pMem, ULONG ulSize ) /* reallocates memory */ else if( s_fStatistic ) { PHB_MEMINFO pMemBlock; - ULONG ulMemSize; + HB_SIZE ulMemSize; pMemBlock = HB_FM_PTR( pMem ); @@ -948,7 +948,7 @@ HB_COUNTER hb_xRefCount( void * pMem ) /* reallocates memory, create copy if reference counter greater then 1 */ #undef hb_xRefResize -void * hb_xRefResize( void * pMem, ULONG ulSave, ULONG ulSize, ULONG * pulAllocated ) +void * hb_xRefResize( void * pMem, HB_SIZE ulSave, HB_SIZE ulSize, HB_SIZE * pulAllocated ) { #ifdef HB_FM_STATISTICS @@ -1002,7 +1002,7 @@ void * hb_xRefResize( void * pMem, ULONG ulSave, ULONG ulSize, ULONG * pulAlloca /* NOTE: Debug function, it will always return 0 when HB_FM_STATISTICS is not defined, don't use it for final code [vszakats] */ -ULONG hb_xsize( void * pMem ) /* returns the size of an allocated memory block */ +HB_SIZE hb_xsize( void * pMem ) /* returns the size of an allocated memory block */ { HB_TRACE(HB_TR_DEBUG, ("hb_xsize(%p)", pMem)); diff --git a/harbour/src/vm/garbage.c b/harbour/src/vm/garbage.c index 05ec315868..126abe9fb0 100644 --- a/harbour/src/vm/garbage.c +++ b/harbour/src/vm/garbage.c @@ -195,7 +195,7 @@ static void hb_gcUnlink( HB_GARBAGE_PTR *pList, HB_GARBAGE_PTR pAlloc ) } /* allocates a memory block */ -void * hb_gcAllocate( ULONG ulSize, const HB_GC_FUNCS * pFuncs ) +void * hb_gcAllocate( HB_SIZE ulSize, const HB_GC_FUNCS * pFuncs ) { HB_GARBAGE_PTR pAlloc; @@ -225,7 +225,7 @@ void * hb_gcAllocate( ULONG ulSize, const HB_GC_FUNCS * pFuncs ) } /* allocates a memory block */ -void * hb_gcAllocRaw( ULONG ulSize, const HB_GC_FUNCS * pFuncs ) +void * hb_gcAllocRaw( HB_SIZE ulSize, const HB_GC_FUNCS * pFuncs ) { HB_GARBAGE_PTR pAlloc; @@ -769,7 +769,7 @@ static void hb_gcAllocExit( void ) } } -void * hb_gcAlloc( ULONG ulSize, HB_GARBAGE_FUNC_PTR pCleanupFunc ) +void * hb_gcAlloc( HB_SIZE ulSize, HB_GARBAGE_FUNC_PTR pCleanupFunc ) { HB_GC_ALLOC_FUNCS * pFuncs = s_pAllocFuncs, ** pFuncsPtr; diff --git a/harbour/src/vm/vm.c b/harbour/src/vm/vm.c index 852305c339..e00f5cd553 100644 --- a/harbour/src/vm/vm.c +++ b/harbour/src/vm/vm.c @@ -57,7 +57,7 @@ #include "hbapi.h" -HB_VMHANDLE hb_xvalloc( ULONG nSize, USHORT nFlags ) +HB_VMHANDLE hb_xvalloc( HB_SIZE nSize, USHORT nFlags ) { /* TODO */ HB_SYMBOL_UNUSED( nSize ); @@ -71,7 +71,7 @@ void hb_xvfree( HB_VMHANDLE h ) HB_SYMBOL_UNUSED( h ); } -HB_VMHANDLE hb_xvrealloc( HB_VMHANDLE h, ULONG nSize, USHORT nFlags ) +HB_VMHANDLE hb_xvrealloc( HB_VMHANDLE h, HB_SIZE nSize, USHORT nFlags ) { /* TODO */ HB_SYMBOL_UNUSED( h ); @@ -111,14 +111,14 @@ void hb_xvunwire( HB_VMHANDLE h ) /* State */ -ULONG hb_xvlockcount( HB_VMHANDLE h ) +HB_SIZE hb_xvlockcount( HB_VMHANDLE h ) { /* TODO */ HB_SYMBOL_UNUSED( h ); return 0; } -ULONG hb_xvsize( HB_VMHANDLE h ) +HB_SIZE hb_xvsize( HB_VMHANDLE h ) { /* TODO */ HB_SYMBOL_UNUSED( h ); @@ -127,7 +127,7 @@ ULONG hb_xvsize( HB_VMHANDLE h ) /* Heap */ -HB_VMHANDLE hb_xvheapnew( ULONG nSize ) +HB_VMHANDLE hb_xvheapnew( HB_SIZE nSize ) { /* TODO */ HB_SYMBOL_UNUSED( nSize ); @@ -140,7 +140,7 @@ void hb_xvheapdestroy( HB_VMHANDLE h ) HB_SYMBOL_UNUSED( h ); } -HB_VMHANDLE hb_xvheapresize( HB_VMHANDLE h, ULONG nSize ) +HB_VMHANDLE hb_xvheapresize( HB_VMHANDLE h, HB_SIZE nSize ) { /* TODO */ HB_SYMBOL_UNUSED( h ); @@ -148,7 +148,7 @@ HB_VMHANDLE hb_xvheapresize( HB_VMHANDLE h, ULONG nSize ) return 0; } -ULONG hb_xvheapalloc( HB_VMHANDLE h, ULONG nSize ) +HB_SIZE hb_xvheapalloc( HB_VMHANDLE h, HB_SIZE nSize ) { /* TODO */ HB_SYMBOL_UNUSED( h ); @@ -156,14 +156,14 @@ ULONG hb_xvheapalloc( HB_VMHANDLE h, ULONG nSize ) return 0; } -void hb_xvheapfree( HB_VMHANDLE h, ULONG nOffset ) +void hb_xvheapfree( HB_VMHANDLE h, HB_SIZE nOffset ) { /* TODO */ HB_SYMBOL_UNUSED( h ); HB_SYMBOL_UNUSED( nOffset ); } -void * hb_xvheaplock( HB_VMHANDLE h, ULONG nOffset ) +void * hb_xvheaplock( HB_VMHANDLE h, HB_SIZE nOffset ) { /* TODO */ HB_SYMBOL_UNUSED( h ); @@ -171,7 +171,7 @@ void * hb_xvheaplock( HB_VMHANDLE h, ULONG nOffset ) return NULL; } -void hb_xvheapunlock( HB_VMHANDLE h, ULONG nOffset ) +void hb_xvheapunlock( HB_VMHANDLE h, HB_SIZE nOffset ) { /* TODO */ HB_SYMBOL_UNUSED( h );