From 330ccfcebd1dbe7304c7b1b145462716200f67dc Mon Sep 17 00:00:00 2001 From: Luiz Rafael Culik Date: Sun, 30 Dec 2001 16:26:50 +0000 Subject: [PATCH] See changelog 2001-12-30 14:35 UTC-0300 --- harbour/include/hbapi.h | 16 ++++---- harbour/include/hbtypes.h | 10 ++++- harbour/source/vm/fm.c | 14 +++---- harbour/source/vm/maindllp.c | 78 +++++++++++++++++++++++++++++++----- 4 files changed, 91 insertions(+), 27 deletions(-) diff --git a/harbour/include/hbapi.h b/harbour/include/hbapi.h index a443cd427c..4325777dd2 100644 --- a/harbour/include/hbapi.h +++ b/harbour/include/hbapi.h @@ -287,7 +287,7 @@ extern int HB_EXPORT hb_parni( int iParam, ... ); /* retrieve a numeric par extern long HB_EXPORT hb_parnl( int iParam, ... ); /* retrieve a numeric parameter as a long */ extern PHB_ITEM HB_EXPORT hb_param( int iParam, int iMask ); /* retrieve a generic parameter */ extern PHB_ITEM HB_EXPORT hb_paramError( int iParam ); /* Returns either the generic parameter or a NIL item if param not provided */ - +extern BOOL HB_EXPORT hb_extIsArray( int iParam ); #ifdef HB_API_MACROS #include "hbapiitm.h" @@ -340,13 +340,13 @@ extern void HB_EXPORT hb_storni( int iValue, int iParam, ... ); /* stores an i extern void HB_EXPORT hb_stornl( long lValue, int iParam, ... ); /* stores a long on a variable by reference */ extern void HB_EXPORT hb_stornd( double dValue, int iParam, ... ); /* stores a double on a variable by reference */ -extern void hb_xinit( void ); /* Initialize fixed memory subsystem */ -extern void hb_xexit( void ); /* Deinitialize fixed memory subsystem */ -extern void * hb_xalloc( ULONG ulSize ); /* allocates memory, returns NULL on failure */ -extern void * hb_xgrab( ULONG ulSize ); /* allocates memory, exits on failure */ -extern void hb_xfree( void * pMem ); /* frees memory */ -extern void * hb_xrealloc( void * pMem, ULONG ulSize ); /* reallocates memory */ -extern ULONG hb_xsize( void * pMem ); /* returns the size of an allocated memory block */ +extern void HB_EXPORT hb_xinit( void ); /* Initialize fixed memory subsystem */ +extern void HB_EXPORT hb_xexit( void ); /* Deinitialize fixed memory subsystem */ +extern void * HB_EXPORT hb_xalloc( ULONG ulSize ); /* allocates memory, returns NULL on failure */ +extern void * HB_EXPORT hb_xgrab( ULONG ulSize ); /* allocates memory, exits on failure */ +extern void HB_EXPORT hb_xfree( void * pMem ); /* frees memory */ +extern void * HB_EXPORT hb_xrealloc( void * pMem, ULONG ulSize ); /* reallocates memory */ +extern ULONG HB_EXPORT hb_xsize( void * pMem ); /* returns the size of an allocated memory block */ extern ULONG hb_xquery( USHORT uiMode ); /* Query different types of memory information */ #if UINT_MAX == ULONG_MAX diff --git a/harbour/include/hbtypes.h b/harbour/include/hbtypes.h index 8956430a9e..f3584bc67e 100644 --- a/harbour/include/hbtypes.h +++ b/harbour/include/hbtypes.h @@ -126,5 +126,13 @@ typedef BOOL ( * HB_ARRAYSIZE)( PHB_ITEM pArray, ULONG ulLen ); typedef BOOL ( * HB_ARRAYLAST)( PHB_ITEM pArray, PHB_ITEM pResult ); typedef BOOL ( * HB_ARRAYRELEASE)( PHB_ITEM pArray ); typedef BOOL ( * HB_ARRAYSET)( PHB_ITEM pArray, ULONG ulIndex, PHB_ITEM pItem ); -typedef BOOL ( * HB_ARRAYGET)( PHB_ITEM pArray, ULONG ulIndex, PHB_ITEM pItem ); +typedef BOOL ( * HB_ARRAYGET)( PHB_ITEM pArray, ULONG ulIndex, PHB_ITEM pItem ); +typedef void ( * HB_XINIT)( void ); /* Initialize fixed memory subsystem */ +typedef void ( * HB_XEXIT)( void ); /* Deinitialize fixed memory subsystem */ +typedef void * ( * HB_XALLOC)( ULONG ulSize ); /* allocates memory, returns NULL on failure */ +typedef void * ( * HB_XGRAB)( ULONG ulSize ); /* allocates memory, exits on failure */ +typedef void ( * HB_XFREE)( void * pMem ); /* frees memory */ +typedef void * ( * HB_XREALLOC)( void * pMem, ULONG ulSize ); /* reallocates memory */ +typedef ULONG ( * HB_XSIZE)( void * pMem ); /* returns the size of an allocated memory block */ + #endif diff --git a/harbour/source/vm/fm.c b/harbour/source/vm/fm.c index 28e6b2b8c6..ab26d0dfa6 100644 --- a/harbour/source/vm/fm.c +++ b/harbour/source/vm/fm.c @@ -111,7 +111,7 @@ static PHB_MEMINFO s_pLastBlock = NULL; #endif -void * hb_xalloc( ULONG ulSize ) /* allocates fixed memory, returns NULL on failure */ +void HB_EXPORT * hb_xalloc( ULONG ulSize ) /* allocates fixed memory, returns NULL on failure */ { #ifdef HB_FM_STATISTICS @@ -190,7 +190,7 @@ void * hb_xalloc( ULONG ulSize ) /* allocates fixed memory, returns NULL #endif } -void * hb_xgrab( ULONG ulSize ) /* allocates fixed memory, exits on failure */ +void HB_EXPORT * hb_xgrab( ULONG ulSize ) /* allocates fixed memory, exits on failure */ { void * pMem; @@ -272,7 +272,7 @@ void * hb_xgrab( ULONG ulSize ) /* allocates fixed memory, exits on fail #endif } -void * hb_xrealloc( void * pMem, ULONG ulSize ) /* reallocates memory */ +void HB_EXPORT * hb_xrealloc( void * pMem, ULONG ulSize ) /* reallocates memory */ { #ifdef HB_FM_STATISTICS @@ -339,7 +339,7 @@ void * hb_xrealloc( void * pMem, ULONG ulSize ) /* reallocates memory */ #endif } -void hb_xfree( void * pMem ) /* frees fixed memory */ +void HB_EXPORT hb_xfree( void * pMem ) /* frees fixed memory */ { #ifdef HB_FM_STATISTICS @@ -390,7 +390,7 @@ void hb_xfree( void * pMem ) /* frees fixed memory */ /* 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 */ +ULONG HB_EXPORT hb_xsize( void * pMem ) /* returns the size of an allocated memory block */ { HB_TRACE(HB_TR_DEBUG, ("hb_xsize(%p)", pMem)); @@ -403,12 +403,12 @@ ULONG hb_xsize( void * pMem ) /* returns the size of an allocated memory block * #endif } -void hb_xinit( void ) /* Initialize fixed memory subsystem */ +void HB_EXPORT hb_xinit( void ) /* Initialize fixed memory subsystem */ { HB_TRACE(HB_TR_DEBUG, ("hb_xinit()")); } -void hb_xexit( void ) /* Deinitialize fixed memory subsystem */ +void HB_EXPORT hb_xexit( void ) /* Deinitialize fixed memory subsystem */ { HB_TRACE(HB_TR_DEBUG, ("hb_xexit()")); diff --git a/harbour/source/vm/maindllp.c b/harbour/source/vm/maindllp.c index df7bfdc0a7..24d89ccfdb 100644 --- a/harbour/source/vm/maindllp.c +++ b/harbour/source/vm/maindllp.c @@ -648,7 +648,7 @@ void hb_stornd( double dNumber, int iParam, ... ) BOOL hb_arrayNew( PHB_ITEM pItem, ULONG ulLen ) /* creates a new array */ { - HB_ARRAYNEW pArrayNew = GetProcAddress( GetModuleHandle( NULL ), "_hb_arrayNew" ); + HB_ARRAYNEW pArrayNew =(HB_ARRAYNEW) GetProcAddress( GetModuleHandle( NULL ), "_hb_arrayNew" ); if (pArrayNew) return pArrayNew( pItem, ulLen ); else @@ -657,7 +657,7 @@ BOOL hb_arrayNew( PHB_ITEM pItem, ULONG ulLen ) /* creates a new array */ ULONG hb_arrayLen( PHB_ITEM pArray ) /* retrives the array len */ { - HB_ARRAYLEN pArrayLen = GetProcAddress( GetModuleHandle( NULL ), "_hb_arrayLen" ); + HB_ARRAYLEN pArrayLen = (HB_ARRAYLEN)GetProcAddress( GetModuleHandle( NULL ), "_hb_arrayLen" ); if (pArrayLen) return pArrayLen( pArray ); else @@ -666,7 +666,7 @@ ULONG hb_arrayLen( PHB_ITEM pArray ) /* retrives the array len */ BOOL hb_arrayIsObject( PHB_ITEM pArray ) /* retrives if the array is an object */ { - HB_ARRAYISOBJECT pArrayIsObject = GetProcAddress( GetModuleHandle( NULL ), "_hb_arrayIsObject" ); + HB_ARRAYISOBJECT pArrayIsObject = (HB_ARRAYISOBJECT)GetProcAddress( GetModuleHandle( NULL ), "_hb_arrayIsObject" ); if (pArrayIsObject) return pArrayIsObject( pArray ); else @@ -675,7 +675,7 @@ BOOL hb_arrayIsObject( PHB_ITEM pArray ) /* retrives if the array is an obj BOOL hb_arrayAdd( PHB_ITEM pArray, PHB_ITEM pItemValue ) /* add a new item to the end of an array item */ { - HB_ARRAYADD pArrayadd = GetProcAddress( GetModuleHandle( NULL ), "_hb_arrayAdd" ); + HB_ARRAYADD pArrayAdd = (HB_ARRAYADD)GetProcAddress( GetModuleHandle( NULL ), "_hb_arrayAdd" ); if (pArrayAdd) return pArrayAdd( pArray, pItemValue ); else @@ -684,7 +684,7 @@ BOOL hb_arrayAdd( PHB_ITEM pArray, PHB_ITEM pItemValue ) /* add a new item BOOL hb_arrayIns( PHB_ITEM pArray, ULONG ulIndex ) /* insert a nil item into an array, without changing the length */ { - HB_ARRAYINS pArrayIns = GetProcAddress( GetModuleHandle( NULL ), "_hb_arrayIns" ); + HB_ARRAYINS pArrayIns = (HB_ARRAYINS)GetProcAddress( GetModuleHandle( NULL ), "_hb_arrayIns" ); if (pArrayIns) return pArrayIns( pArray, ulIndex ); else @@ -693,7 +693,7 @@ BOOL hb_arrayIns( PHB_ITEM pArray, ULONG ulIndex ) /* insert a nil item int BOOL hb_arrayDel( PHB_ITEM pArray, ULONG ulIndex ) /* delete an array item, without changing length */ { - HB_ARRAYDEL pArrayDel = GetProcAddress( GetModuleHandle( NULL ), "_hb_arrayDel" ); + HB_ARRAYDEL pArrayDel = (HB_ARRAYDEL)GetProcAddress( GetModuleHandle( NULL ), "_hb_arrayDel" ); if (pArrayDel) return pArrayDel( pArray, ulIndex ); else @@ -702,7 +702,7 @@ BOOL hb_arrayDel( PHB_ITEM pArray, ULONG ulIndex ) /* delete an array item, BOOL hb_arraySize( PHB_ITEM pArray, ULONG ulLen ) /* sets the array total length */ { - HB_ARRAYSIZE pArraySize = GetProcAddress( GetModuleHandle( NULL ), "_hb_arraySize" ); + HB_ARRAYSIZE pArraySize = (HB_ARRAYSIZE)GetProcAddress( GetModuleHandle( NULL ), "_hb_arraySize" ); if (pArraySize) return pArraySize( pArray, ulLen ); else @@ -711,7 +711,7 @@ BOOL hb_arraySize( PHB_ITEM pArray, ULONG ulLen ) /* sets the array total l BOOL hb_arrayLast( PHB_ITEM pArray, PHB_ITEM pResult ) /* retrieve last item in an array */ { - HB_ARRAYLAST pArrayLast= GetProcAddress( GetModuleHandle( NULL ), "_hb_arrayLast" ); + HB_ARRAYLAST pArrayLast= (HB_ARRAYLAST)GetProcAddress( GetModuleHandle( NULL ), "_hb_arrayLast" ); if (pArrayLast) return pArrayLast( pArray, pResult ); else @@ -720,7 +720,7 @@ BOOL hb_arrayLast( PHB_ITEM pArray, PHB_ITEM pResult ) /* retrieve last ite BOOL hb_arrayRelease( PHB_ITEM pArray ) /* releases an array - don't call it - use ItemRelease() !!! */ { - HB_ARRAYRELEASE pArrayRelease = GetProcAddress( GetModuleHandle( NULL ), "_hb_arrayRelease" ); + HB_ARRAYRELEASE pArrayRelease = (HB_ARRAYRELEASE)GetProcAddress( GetModuleHandle( NULL ), "_hb_arrayRelease" ); if (pArrayRelease) return pArrayRelease( pArray ); else @@ -729,7 +729,7 @@ BOOL hb_arrayRelease( PHB_ITEM pArray ) /* releases an array - don't call i BOOL hb_arraySet( PHB_ITEM pArray, ULONG ulIndex, PHB_ITEM pItem ) /* sets an array element */ { - HB_ARRAYSET pArraySet = GetProcAddress( GetModuleHandle( NULL ), "_hb_arraySet" ); + HB_ARRAYSET pArraySet = (HB_ARRAYSET)GetProcAddress( GetModuleHandle( NULL ), "_hb_arraySet" ); if (pArraySet) return pArraySet( pArray, ulIndex, pItem); else @@ -738,11 +738,67 @@ BOOL hb_arraySet( PHB_ITEM pArray, ULONG ulIndex, PHB_ITEM pItem ) /* sets BOOL hb_arrayGet( PHB_ITEM pArray, ULONG ulIndex, PHB_ITEM pItem ) /* retrieves an item */ { - HB_ARRAYGET pArrayGet = GetProcAddress( GetModuleHandle( NULL ), "_hb_arrayGet" ); + HB_ARRAYGET pArrayGet = (HB_ARRAYGET)GetProcAddress( GetModuleHandle( NULL ), "_hb_arrayGet" ); if (pArrayGet) return pArrayGet( pArray, ulIndex, pItem); else return FALSE; } +void hb_xinit( void ) /* Initialize fixed memory subsystem */ +{ + HB_XINIT pXinit = (HB_XINIT)GetProcAddress( GetModuleHandle( NULL ), "_hb_xinit" ); + if (pXinit) + pXinit(); +} + +void hb_xexit( void ) /* Deinitialize fixed memory subsystem */ +{ + HB_XEXIT pXexit = (HB_XEXIT)GetProcAddress( GetModuleHandle( NULL ), "_hb_xexit" ); + if (pXexit) + pXexit(); +} + +void * hb_xalloc( ULONG ulSize ) /* allocates memory, returns NULL on failure */ +{ + void * pRet; + HB_XALLOC pXalloc = (HB_XALLOC)GetProcAddress( GetModuleHandle( NULL ), "_hb_xalloc" ); + if (pXalloc) + pRet=pXalloc(ulSize); + return pRet; +} + +void * hb_xgrab( ULONG ulSize ) /* allocates memory, exits on failure */ +{ + void * pRet; + HB_XGRAB pXgrab = (HB_XGRAB)GetProcAddress( GetModuleHandle( NULL ), "_hb_xgrab" ); + if (pXgrab) + pRet=pXgrab(ulSize); + return pRet; +} + +void hb_xfree( void * pMem ) /* frees memory */ +{ + HB_XFREE pXfree = (HB_XFREE)GetProcAddress( GetModuleHandle( NULL ), "_hb_xfree" ); + if (pXfree) + pXfree(pMem); +} + +void * hb_xrealloc( void * pMem, ULONG ulSize ) /* reallocates memory */ +{ + void * pRet; + HB_XREALLOC pXrealloc = (HB_XREALLOC)GetProcAddress( GetModuleHandle( NULL ), "_hb_xrealloc" ); + if (pXrealloc) + pRet= (void*)pXrealloc( pMem, ulSize ); + return pRet; +} + +ULONG hb_xsize( void * pMem ) /* returns the size of an allocated memory block */ +{ + HB_XSIZE pXsize = (HB_XSIZE)GetProcAddress( GetModuleHandle( NULL ), "_hb_xsize" ); + ULONG ulReturn=0; + if (pXsize) + ulReturn= pXsize((void *)pMem); + return ulReturn; +} #endif