ChangeLog 2000-07-03 11:40 UTC+0100
This commit is contained in:
@@ -1,4 +1,24 @@
|
||||
2000-06-02 12:30 UTC+0100 Ryszard Glab <rglab@imid.med.pl>
|
||||
2000-07-03 11:40 UTC+0100 Ryszard Glab <rglab@imid.med.pl>
|
||||
|
||||
*include/hbpp.h
|
||||
*source/pp/ppcore.c
|
||||
* fixed declaration and definition of hb_pp_SetRule() - Watcom C/C++
|
||||
was recognizing it as overloading of the function
|
||||
|
||||
*source/rtl/gtdos/gtdos.c
|
||||
* fixed low level processor ports access for Watcom C/C++
|
||||
|
||||
*source/vm/garbage.c
|
||||
* fixed possible endless loop in hb_gcCollectAll()
|
||||
|
||||
*source/vm/arrays.c
|
||||
* arrays are no longer released recursively during the garbage
|
||||
collecting
|
||||
|
||||
*source/rdd/dbfntx/dbfntx1.c
|
||||
* fixed warning for unused variable
|
||||
|
||||
2000-07-02 12:30 UTC+0100 Ryszard Glab <rglab@imid.med.pl>
|
||||
|
||||
*source/vm/garbage.c
|
||||
*source/vm/memvars.c
|
||||
|
||||
@@ -79,7 +79,11 @@ typedef struct _COMMANDS
|
||||
|
||||
/* HBPP.C exported functions */
|
||||
|
||||
extern void hb_pp_SetRules( BOOL ( *hb_compInclude )( char *, PATHNAMES * ), BOOL hb_comp_bQuiet );
|
||||
#define HB_INCLUDE_FUNC_( hbFunc ) BOOL hbFunc( char *, PATHNAMES * )
|
||||
typedef HB_INCLUDE_FUNC_( HB_INCLUDE_FUNC );
|
||||
typedef HB_INCLUDE_FUNC *HB_INCLUDE_FUNC_PTR;
|
||||
|
||||
extern void hb_pp_SetRules( HB_INCLUDE_FUNC_PTR hb_compInclude, BOOL hb_comp_bQuiet );
|
||||
extern void hb_pp_Init( void );
|
||||
extern int hb_pp_ParseDirective( char * ); /* Parsing preprocessor directives ( #... ) */
|
||||
extern int hb_pp_ParseExpression( char *, char * ); /* Parsing a line ( without preprocessor directive ) */
|
||||
|
||||
@@ -203,7 +203,7 @@ char * hb_pp_szWarnings[] =
|
||||
extern BOOL bDebug;
|
||||
*/
|
||||
|
||||
void hb_pp_SetRules( BOOL (*hb_compInclude)(char *, PATHNAMES * ), BOOL hb_comp_bQuiet )
|
||||
void hb_pp_SetRules( HB_INCLUDE_FUNC_PTR hb_compInclude, BOOL hb_comp_bQuiet )
|
||||
{
|
||||
HB_TRACE(HB_TR_DEBUG, ("hb_pp_SetRules()"));
|
||||
|
||||
|
||||
@@ -88,7 +88,7 @@ typedef struct _NTXHEADER /* Header of NTX file */
|
||||
|
||||
typedef NTXHEADER * LPNTXHEADER;
|
||||
|
||||
typedef struct _NTXBUFFER /* Header of each block in NTX file (only block
|
||||
typedef struct _NTXBUFFER /* Header of each block in NTX file (only block
|
||||
with header has other format */
|
||||
{
|
||||
USHORT item_count;
|
||||
@@ -102,13 +102,13 @@ typedef struct _NTXITEM /* each item in NTX block has following format */
|
||||
ULONG page; /* subpage (each key in subpage has < value like this key */
|
||||
ULONG rec_no; /* RecNo of record with this key */
|
||||
char key[ 1 ]; /* value of key */
|
||||
} NTXITEM;
|
||||
} NTXITEM;
|
||||
|
||||
typedef NTXITEM * LPNTXITEM;
|
||||
|
||||
/* Functions for debug this module */
|
||||
#ifdef DEBUG
|
||||
static void hb_ntxIndexDump( LPINDEXINFO pIndex );
|
||||
static void hb_ntxIndexDump( LPINDEXINFO pIndex );
|
||||
/* Dump index. Uses hb_ntxPageDump */
|
||||
static void hb_ntxPageDump( LPPAGEINFO pPage );
|
||||
/* Dump one page of index with all subpages */
|
||||
@@ -127,7 +127,7 @@ static void hb_ntxIndexFree( LPINDEXINFO pIndex );
|
||||
static ERRCODE hb_ntxIndexCreate( LPINDEXINFO pIndex );
|
||||
/* Create index from database */
|
||||
|
||||
static LPTAGINFO hb_ntxTagNew( LPINDEXINFO PIF, char * ITN, char *szKeyExpr,
|
||||
static LPTAGINFO hb_ntxTagNew( LPINDEXINFO PIF, char * ITN, char *szKeyExpr,
|
||||
PHB_ITEM pKeyExpr, BYTE bKeyType, USHORT uiKeyLen, char *szForExp,
|
||||
PHB_ITEM pForExp, BOOL fAscendKey, BOOL fUnique );
|
||||
/* Create Compound Tag with information about index */
|
||||
@@ -281,7 +281,7 @@ static ERRCODE hb_ntxPageAddPageKeyAdd( LPPAGEINFO pPage, PHB_ITEM pKey, int lev
|
||||
if( nEnd > pos )
|
||||
memmove( pNewPage->pKeys + nNewPos + 1, pPage->pKeys + pos, ( nEnd - pos ) * sizeof( KEYINFO ));
|
||||
pPage->pKeys[nEnd].Tag = pNewPage->Page;
|
||||
memmove( pPage->pKeys + nBegin , pPage->pKeys + nEnd,
|
||||
memmove( pPage->pKeys + nBegin , pPage->pKeys + nEnd,
|
||||
( pPage->uiKeys - nEnd ) * sizeof( KEYINFO ) + sizeof( pPage->pKeys->Tag ) );
|
||||
//memset( pPage->pKeys + nBegin + nCount, 0 ,
|
||||
//( pPage->uiKeys - nEnd ) * sizeof( KEYINFO ) + sizeof( pPage->pKeys->Tag ) );
|
||||
@@ -289,7 +289,9 @@ static ERRCODE hb_ntxPageAddPageKeyAdd( LPPAGEINFO pPage, PHB_ITEM pKey, int lev
|
||||
pNewPage->uiKeys = nCount + 1;
|
||||
pPage->Changed = TRUE;
|
||||
pNewPage->Changed = TRUE;
|
||||
hb_ntxPageFree( pNewPage );
|
||||
hb_ntxPageFree( pNewPage );
|
||||
|
||||
HB_SYMBOL_UNUSED( level );
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
@@ -309,7 +311,7 @@ static ERRCODE hb_ntxPageKeyAdd( LPPAGEINFO pPage, PHB_ITEM pKey, int level)
|
||||
{
|
||||
int i,cmp;
|
||||
LPPAGEINFO pLoadedPage;
|
||||
|
||||
|
||||
i=0;
|
||||
if( pPage->uiKeys == 0 )
|
||||
{
|
||||
@@ -372,14 +374,14 @@ static ERRCODE hb_ntxTagKeyAdd( LPTAGINFO pTag, PHB_ITEM pKey)
|
||||
{
|
||||
LPPAGEINFO pPage;
|
||||
|
||||
if( pTag->RootPage )
|
||||
{
|
||||
if( pTag->RootPage )
|
||||
{
|
||||
/* TODO :
|
||||
Add next keys */
|
||||
return hb_ntxPageKeyAdd( pTag->RootPage, pKey, 0);
|
||||
|
||||
}
|
||||
else
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
pPage = hb_ntxPageNew( pTag, NULL );
|
||||
pPage->Changed = TRUE;
|
||||
@@ -418,7 +420,7 @@ static LPINDEXINFO hb_ntxIndexNew( AREAP pArea )
|
||||
}
|
||||
}
|
||||
while( found );
|
||||
}
|
||||
}
|
||||
return pIndex;
|
||||
}
|
||||
|
||||
@@ -459,7 +461,7 @@ static LPTAGINFO hb_ntxTagNew( LPINDEXINFO PIF, char * ITN, char *szKeyExpr, PHB
|
||||
}
|
||||
if( szForExp )
|
||||
{
|
||||
pTag->ForExpr = (char *) hb_xgrab( NTX_MAX_KEY );
|
||||
pTag->ForExpr = (char *) hb_xgrab( NTX_MAX_KEY );
|
||||
strcpy( pTag->ForExpr, szForExp );
|
||||
}
|
||||
pTag->pKeyItem = pKeyExpr;
|
||||
@@ -493,8 +495,8 @@ static ERRCODE hb_ntxIndexCreate( LPINDEXINFO pIndex )
|
||||
pArea = pIndex->Owner;
|
||||
pTag = pIndex->CompoundTag;
|
||||
pItem = hb_itemNew( NULL );
|
||||
for( ulRecNo = 1; ulRecNo <= ulRecCount; ulRecNo++)
|
||||
{
|
||||
for( ulRecNo = 1; ulRecNo <= ulRecCount; ulRecNo++)
|
||||
{
|
||||
hb_fsSeek( pArea->lpDataInfo->hFile,
|
||||
pArea->lpExtendInfo->uiHeaderLen +
|
||||
( ulRecNo - 1 ) * pArea->lpExtendInfo->uiRecordLen,
|
||||
@@ -540,11 +542,11 @@ static ERRCODE hb_ntxIndexCreate( LPINDEXINFO pIndex )
|
||||
hb_ntxTagKeyAdd( pTag, pItem );
|
||||
#ifdef DEBUG
|
||||
pPage = pTag->RootPage;
|
||||
while( pPage )
|
||||
while( pPage )
|
||||
{
|
||||
if( pPage->Changed )
|
||||
{
|
||||
if( pPage->NewRoot )
|
||||
if( pPage->NewRoot )
|
||||
{
|
||||
pPage->TagParent->RootBlock = pPage->Page;
|
||||
hb_ntxHeaderSave( pIndex );
|
||||
@@ -615,16 +617,16 @@ static void hb_ntxPageSave( LPPAGEINFO pPage )
|
||||
pKey = pPage->pKeys;
|
||||
itemlist = ( LPNTXBUFFER ) buffer;
|
||||
itemlist->item_count = pPage->uiKeys;
|
||||
for( i = 0; i < pPage->uiKeys; i++ )
|
||||
for( i = 0; i < pPage->uiKeys; i++ )
|
||||
{
|
||||
itemlist->item_offset[i] = 2 + 2 * ( pPage->TagParent->MaxKeys + 1 ) +
|
||||
itemlist->item_offset[i] = 2 + 2 * ( pPage->TagParent->MaxKeys + 1 ) +
|
||||
i * ( pPage->TagParent->KeyLength + 8 );
|
||||
item=(NTXITEM *)(buffer+itemlist->item_offset[i]);
|
||||
item->page = pKey[i].Tag;
|
||||
item->rec_no = pKey[i].Xtra;
|
||||
strcpy(item->key, pKey[i].pItem->item.asString.value);
|
||||
}
|
||||
itemlist->item_offset[i] = 2 + 2 * ( pPage->TagParent->MaxKeys + 1 ) +
|
||||
itemlist->item_offset[i] = 2 + 2 * ( pPage->TagParent->MaxKeys + 1 ) +
|
||||
i * ( pPage->TagParent->KeyLength + 8 );
|
||||
item=(NTXITEM *)(buffer+itemlist->item_offset[i]);
|
||||
item->page = pKey[i].Tag;
|
||||
@@ -658,7 +660,7 @@ static LPPAGEINFO hb_ntxIndexRootPageLoad( LPINDEXINFO pIndex )
|
||||
memset( pPage->pKeys, 0, sizeof( KEYINFO ) * ( pPage->TagParent->MaxKeys + 1 ) );
|
||||
itemlist = ( LPNTXBUFFER ) buffer;
|
||||
pPage->uiKeys = itemlist->item_count;
|
||||
for( i = 0; i < itemlist->item_count; i++ )
|
||||
for( i = 0; i < itemlist->item_count; i++ )
|
||||
{
|
||||
item=(NTXITEM *)(buffer+itemlist->item_offset[i]);
|
||||
pPage->pKeys[i].Xtra = item->rec_no;
|
||||
@@ -696,7 +698,7 @@ static LPPAGEINFO hb_ntxPageLoad( LPPAGEINFO pParentPage, ULONG ulOffset )
|
||||
|
||||
itemlist = ( LPNTXBUFFER ) buffer;
|
||||
pPage->uiKeys = itemlist->item_count ;
|
||||
for( i = 0; i < itemlist->item_count; i++ )
|
||||
for( i = 0; i < itemlist->item_count; i++ )
|
||||
{
|
||||
item=(NTXITEM *)(buffer+itemlist->item_offset[i]);
|
||||
pPage->pKeys[i].Xtra = item->rec_no;
|
||||
@@ -818,7 +820,7 @@ static ERRCODE ntxOrderCreate( AREAP pArea, LPDBORDERCREATEINFO pOrderInfo )
|
||||
return FAILURE;
|
||||
pExpr = pArea->valResult;
|
||||
pArea->valResult = NULL;
|
||||
}
|
||||
}
|
||||
/* Save for later use */
|
||||
pKeyExp = hb_itemNew( NULL );
|
||||
hb_itemCopy( pKeyExp, pExpr );
|
||||
@@ -915,7 +917,7 @@ static ERRCODE ntxOrderCreate( AREAP pArea, LPDBORDERCREATEINFO pOrderInfo )
|
||||
{
|
||||
if( hb_itemType( pExpr ) == HB_IT_BLOCK )
|
||||
{
|
||||
if( SELF_EVALBLOCK( pArea, pExpr ) == FAILURE )
|
||||
if( SELF_EVALBLOCK( pArea, pExpr ) == FAILURE )
|
||||
{
|
||||
hb_itemRelease( pKeyExp );
|
||||
hb_itemRelease( pForExp );
|
||||
|
||||
@@ -68,6 +68,7 @@
|
||||
|
||||
/* NOTE: User programs should never call this layer directly! */
|
||||
|
||||
#include "hbapi.h"
|
||||
#include "hbapigt.h"
|
||||
#include "hbset.h" /* For Ctrl+Break handling */
|
||||
#include "hbvm.h" /* For Ctrl+Break handling */
|
||||
@@ -975,7 +976,7 @@ void hb_gt_Tone( double dFrequency, double dDuration )
|
||||
tasking friendly. */
|
||||
end_clock = clock() + temp;
|
||||
while( clock() < end_clock )
|
||||
hb_releaseCPU();
|
||||
hb_idleState();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1184,6 +1185,12 @@ USHORT hb_gt_VertLine( USHORT uiCol, USHORT uiTop, USHORT uiBottom, BYTE byChar,
|
||||
#define outport( p, w ) /* Do nothing */
|
||||
#define outportb( p, b ) /* Do nothing */
|
||||
#define POKE_BYTE( s, o, b ) (*((BYTE FAR *)MK_FP((s),(o)) )=(BYTE)(b))
|
||||
#elif defined(__WATCOMC__)
|
||||
#define outportb outp /* Use correct function name */
|
||||
#define outport outpw /* Use correct function name */
|
||||
#define inport inpw /* Use correct function name */
|
||||
#define inportb inp /* Use correct function name */
|
||||
#define POKE_BYTE( s, o, b ) (*((BYTE FAR *)MK_FP((s),(o)) )=(BYTE)(b))
|
||||
#else
|
||||
#define POKE_BYTE( s, o, b ) (*((BYTE FAR *)MK_FP((s),(o)) )=(BYTE)(b))
|
||||
#endif
|
||||
@@ -1191,7 +1198,7 @@ USHORT hb_gt_VertLine( USHORT uiCol, USHORT uiTop, USHORT uiBottom, BYTE byChar,
|
||||
static void vmode12x40( void )
|
||||
{
|
||||
union REGS regs;
|
||||
regs.x.ax = 0x0001; /* video mode 40 cols */
|
||||
regs.HB_XREGS.ax = 0x0001; /* video mode 40 cols */
|
||||
HB_DOS_INT86( INT_VIDEO, ®s, ®s);
|
||||
outportb( 0x03D4, 0x09 ); /* update cursor size / pointers */
|
||||
regs.h.al = ( inportb( 0x03D5 ) | 0x80 );
|
||||
@@ -1202,27 +1209,27 @@ static void vmode12x40( void )
|
||||
static void vmode25x40( void )
|
||||
{
|
||||
union REGS regs;
|
||||
regs.x.ax = 0x0001;
|
||||
regs.HB_XREGS.ax = 0x0001;
|
||||
HB_DOS_INT86( INT_VIDEO, ®s, ®s);
|
||||
}
|
||||
|
||||
static void vmode28x40( void )
|
||||
{
|
||||
union REGS regs;
|
||||
regs.x.ax = 0x0001; /* video mode 40 cols */
|
||||
regs.HB_XREGS.ax = 0x0001; /* video mode 40 cols */
|
||||
HB_DOS_INT86( INT_VIDEO, ®s, ®s);
|
||||
regs.x.bx = 0; /* load block 0 (BL = 0) */
|
||||
regs.x.ax = 0x1111; /* load 8x8 monochrome char set into RAM */
|
||||
regs.HB_XREGS.bx = 0; /* load block 0 (BL = 0) */
|
||||
regs.HB_XREGS.ax = 0x1111; /* load 8x8 monochrome char set into RAM */
|
||||
HB_DOS_INT86( INT_VIDEO, ®s, ®s);
|
||||
}
|
||||
|
||||
static void vmode50x40( void )
|
||||
{
|
||||
union REGS regs;
|
||||
regs.x.ax = 0x0001;
|
||||
regs.HB_XREGS.ax = 0x0001;
|
||||
HB_DOS_INT86( INT_VIDEO, ®s, ®s);
|
||||
regs.x.bx = 0; /* load block 0 (BL = 0) */
|
||||
regs.x.ax = 0x1112; /* load 8x8 double dot char set into RAM */
|
||||
regs.HB_XREGS.bx = 0; /* load block 0 (BL = 0) */
|
||||
regs.HB_XREGS.ax = 0x1112; /* load 8x8 double dot char set into RAM */
|
||||
HB_DOS_INT86( INT_VIDEO, ®s, ®s);
|
||||
outport( 0x03D4, 0x060A );
|
||||
}
|
||||
@@ -1230,7 +1237,7 @@ static void vmode50x40( void )
|
||||
static void vmode12x80( void )
|
||||
{
|
||||
union REGS regs;
|
||||
regs.x.ax = 0x0003; /* mode in AL, if bit 7 is on, No CLS */
|
||||
regs.HB_XREGS.ax = 0x0003; /* mode in AL, if bit 7 is on, No CLS */
|
||||
HB_DOS_INT86( INT_VIDEO, ®s, ®s);
|
||||
outportb( 0x03D4, 0x09 ); /* update cursor size / pointers */
|
||||
regs.h.al = ( inportb( 0x03D5 ) | 0x80 );
|
||||
@@ -1241,37 +1248,37 @@ static void vmode12x80( void )
|
||||
static void vmode25x80( void )
|
||||
{
|
||||
union REGS regs;
|
||||
regs.x.ax = 0x1202; /* select 350 scan line mode */
|
||||
regs.HB_XREGS.ax = 0x1202; /* select 350 scan line mode */
|
||||
regs.h.bl = 0x30;
|
||||
HB_DOS_INT86( INT_VIDEO, ®s, ®s);
|
||||
regs.x.ax = 0x0083; /* mode in AL, if higher bit is on, No CLS */
|
||||
regs.HB_XREGS.ax = 0x0083; /* mode in AL, if higher bit is on, No CLS */
|
||||
HB_DOS_INT86( INT_VIDEO, ®s, ®s);
|
||||
regs.x.bx = 0; /* load block 0 (BL = 0) */
|
||||
regs.x.ax = 0x1114; /* load 8x14 VGA char set into RAM */
|
||||
regs.HB_XREGS.bx = 0; /* load block 0 (BL = 0) */
|
||||
regs.HB_XREGS.ax = 0x1114; /* load 8x14 VGA char set into RAM */
|
||||
HB_DOS_INT86( INT_VIDEO, ®s, ®s);
|
||||
}
|
||||
|
||||
static void vmode28x80( void )
|
||||
{
|
||||
union REGS regs;
|
||||
regs.x.ax = 0x0003; /* mode in AL, if higher bit is on, No CLS */
|
||||
regs.HB_XREGS.ax = 0x0003; /* mode in AL, if higher bit is on, No CLS */
|
||||
HB_DOS_INT86( INT_VIDEO, ®s, ®s);
|
||||
regs.x.bx = 0; /* load block 0 (BL = 0) */
|
||||
regs.x.ax = 0x1111; /* load 8x8 monochrome char set into RAM */
|
||||
regs.HB_XREGS.bx = 0; /* load block 0 (BL = 0) */
|
||||
regs.HB_XREGS.ax = 0x1111; /* load 8x8 monochrome char set into RAM */
|
||||
HB_DOS_INT86( INT_VIDEO, ®s, ®s);
|
||||
}
|
||||
|
||||
static void vmode43x80( void )
|
||||
{
|
||||
union REGS regs;
|
||||
regs.x.ax = 0x1201; /* select 350 scan line mode */
|
||||
regs.HB_XREGS.ax = 0x1201; /* select 350 scan line mode */
|
||||
regs.h.bl = 0x30;
|
||||
HB_DOS_INT86( INT_VIDEO, ®s, ®s);
|
||||
regs.x.ax = 0x0003; /* mode in AL, if higher bit is on, No CLS */
|
||||
regs.HB_XREGS.ax = 0x0003; /* mode in AL, if higher bit is on, No CLS */
|
||||
HB_DOS_INT86( INT_VIDEO, ®s, ®s);
|
||||
regs.h.bh = 0x1; /* bytes per character */
|
||||
regs.h.bl = 0x0; /* load block 0 */
|
||||
regs.x.ax = 0x1112; /* load 8x8 double dot char set into RAM */
|
||||
regs.HB_XREGS.ax = 0x1112; /* load 8x8 double dot char set into RAM */
|
||||
HB_DOS_INT86( INT_VIDEO, ®s, ®s);
|
||||
outport( 0x03D4, 0x060A ); /* update cursor size / pointers */
|
||||
POKE_BYTE( 0x40, 0x84, 42); /* 42 rows number update */
|
||||
@@ -1280,13 +1287,13 @@ static void vmode43x80( void )
|
||||
static void vmode50x80( void )
|
||||
{
|
||||
union REGS regs;
|
||||
regs.x.ax = 0x1202; /* select 400 scan line mode */
|
||||
regs.HB_XREGS.ax = 0x1202; /* select 400 scan line mode */
|
||||
regs.h.bl = 0x30;
|
||||
HB_DOS_INT86( INT_VIDEO, ®s, ®s);
|
||||
regs.x.ax = 0x0003; /* mode in AL, if bit 7 is on, No CLS */
|
||||
regs.HB_XREGS.ax = 0x0003; /* mode in AL, if bit 7 is on, No CLS */
|
||||
HB_DOS_INT86( INT_VIDEO, ®s, ®s);
|
||||
regs.x.bx = 0; /* load block 0 (BL = 0) */
|
||||
regs.x.ax = 0x1112; /* load 8x8 double dot char set into RAM */
|
||||
regs.HB_XREGS.bx = 0; /* load block 0 (BL = 0) */
|
||||
regs.HB_XREGS.ax = 0x1112; /* load 8x8 double dot char set into RAM */
|
||||
HB_DOS_INT86( INT_VIDEO, ®s, ®s);
|
||||
}
|
||||
|
||||
@@ -1320,7 +1327,7 @@ static USHORT hb_gt_GetDisplay( void )
|
||||
{
|
||||
union REGS regs;
|
||||
|
||||
regs.x.ax = 0x1A00;
|
||||
regs.HB_XREGS.ax = 0x1A00;
|
||||
HB_DOS_INT86( INT_VIDEO, ®s, ®s);
|
||||
|
||||
return ( regs.h.al == 0x1A ) ? regs.h.bl : 0xFF;
|
||||
|
||||
@@ -746,13 +746,23 @@ static HB_GARBAGE_FUNC( hb_arrayReleaseGarbage )
|
||||
{
|
||||
HB_ITEM_PTR pItem = pBaseArray->pItems;
|
||||
ULONG ulLen = pBaseArray->ulLen;
|
||||
|
||||
|
||||
while( ulLen-- )
|
||||
{
|
||||
pBaseArray->uiHolders = 0; /* to prevent cyclic release of this array */
|
||||
hb_itemClear( pItem++ );
|
||||
/* Only strings should be deallocated.
|
||||
* Arrays, objects and codeblock should be released directly by
|
||||
* the garbage collector
|
||||
*/
|
||||
if( HB_IS_STRING( pItem ) )
|
||||
{
|
||||
if( pItem->item.asString.value )
|
||||
{
|
||||
hb_xfree( pItem->item.asString.value );
|
||||
}
|
||||
}
|
||||
++pItem;
|
||||
}
|
||||
hb_xfree( pBaseArray->pItems );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -51,8 +51,9 @@ typedef struct HB_GARBAGE_
|
||||
} HB_GARBAGE, *HB_GARBAGE_PTR;
|
||||
|
||||
/* status of memory block */
|
||||
#define HB_GC_UNLOCKED 0
|
||||
#define HB_GC_LOCKED 1 /* do not collect a memory block */
|
||||
#define HB_GC_UNLOCKED 0
|
||||
#define HB_GC_LOCKED 1 /* do not collect a memory block */
|
||||
#define HB_GC_NOTCHECKED 2 /* this item was not checked yet */
|
||||
|
||||
/* pointer to memory block that will be checked in next step */
|
||||
static HB_GARBAGE_PTR s_pCurrBlock = NULL;
|
||||
@@ -70,8 +71,8 @@ static BOOL s_bCollecting = FALSE;
|
||||
void * hb_gcAlloc( ULONG ulSize, HB_GARBAGE_FUNC_PTR pCleanupFunc )
|
||||
{
|
||||
HB_GARBAGE_PTR pAlloc;
|
||||
|
||||
pAlloc = HB_GARBAGE_NEW( ulSize + sizeof( HB_GARBAGE ) );
|
||||
|
||||
pAlloc = HB_GARBAGE_NEW( ulSize + sizeof( HB_GARBAGE ) );
|
||||
if( pAlloc )
|
||||
{
|
||||
if( s_pCurrBlock )
|
||||
@@ -89,7 +90,7 @@ void * hb_gcAlloc( ULONG ulSize, HB_GARBAGE_FUNC_PTR pCleanupFunc )
|
||||
}
|
||||
pAlloc->pFunc = pCleanupFunc;
|
||||
pAlloc->status = HB_GC_UNLOCKED;
|
||||
|
||||
|
||||
return (void *)( pAlloc + 1 ); /* hide the internal data */
|
||||
}
|
||||
else
|
||||
@@ -131,7 +132,7 @@ void *hb_gcLock( void *pBlock )
|
||||
{
|
||||
HB_GARBAGE_PTR pAlloc = ( HB_GARBAGE_PTR ) pBlock;
|
||||
--pAlloc;
|
||||
|
||||
|
||||
pAlloc->status |= HB_GC_LOCKED;
|
||||
}
|
||||
return pBlock;
|
||||
@@ -146,7 +147,7 @@ void *hb_gcUnlock( void *pBlock )
|
||||
{
|
||||
HB_GARBAGE_PTR pAlloc = ( HB_GARBAGE_PTR ) pBlock;
|
||||
--pAlloc;
|
||||
|
||||
|
||||
pAlloc->status &= ~( ( ULONG ) HB_GC_LOCKED );
|
||||
}
|
||||
return pBlock;
|
||||
@@ -187,7 +188,8 @@ void hb_gcCollect( void )
|
||||
void *pBlock = ( void * )( s_pCurrBlock + 1 ); /* change for real pointer */
|
||||
HB_GARBAGE_PTR pNext = s_pCurrBlock->pNext;
|
||||
|
||||
if( !( s_pCurrBlock->status & HB_GC_LOCKED ) )
|
||||
s_pCurrBlock->status &= ~( (ULONG)HB_GC_NOTCHECKED );
|
||||
if( !( s_pCurrBlock->status & HB_GC_LOCKED ) )
|
||||
{
|
||||
if( !hb_vmIsLocalRef( pBlock ) )
|
||||
{
|
||||
@@ -197,8 +199,8 @@ void hb_gcCollect( void )
|
||||
{
|
||||
if( !hb_clsIsClassRef( pBlock ) )
|
||||
{
|
||||
/* It is possible that s_pCurrBlock will be requested
|
||||
* to release from a cleanup function - to prevent it
|
||||
/* It is possible that s_pCurrBlock will be requested
|
||||
* to release from a cleanup function - to prevent it
|
||||
* we have to use some flag.
|
||||
*/
|
||||
s_bCollecting = TRUE;
|
||||
@@ -224,12 +226,21 @@ void hb_gcCollect( void )
|
||||
*/
|
||||
void hb_gcCollectAll( void )
|
||||
{
|
||||
HB_GARBAGE_PTR pStart = s_pCurrBlock;
|
||||
|
||||
do
|
||||
HB_GARBAGE_PTR pBlock = s_pCurrBlock;
|
||||
|
||||
if( s_pCurrBlock )
|
||||
{
|
||||
hb_gcCollect();
|
||||
} while( s_pCurrBlock && (pStart != s_pCurrBlock) );
|
||||
do
|
||||
{
|
||||
pBlock->status |= HB_GC_NOTCHECKED;
|
||||
pBlock = pBlock->pNext;
|
||||
} while (pBlock != s_pCurrBlock);
|
||||
|
||||
do
|
||||
{
|
||||
hb_gcCollect();
|
||||
} while( s_pCurrBlock && (s_pCurrBlock->status & HB_GC_NOTCHECKED) );
|
||||
}
|
||||
}
|
||||
|
||||
/* Check if passed item <pItem> contains a reference to passed
|
||||
@@ -247,7 +258,7 @@ BOOL hb_gcItemRef( HB_ITEM_PTR pItem, void *pBlock )
|
||||
else
|
||||
return FALSE; /* all items should be passed directly */
|
||||
}
|
||||
|
||||
|
||||
if( HB_IS_ARRAY( pItem ) )
|
||||
{
|
||||
/* NOTE: this checks for objects too */
|
||||
@@ -257,7 +268,7 @@ BOOL hb_gcItemRef( HB_ITEM_PTR pItem, void *pBlock )
|
||||
{
|
||||
ULONG ulSize = pItem->item.asArray.value->ulLen;
|
||||
pItem = pItem->item.asArray.value->pItems;
|
||||
|
||||
|
||||
while( ulSize-- )
|
||||
{
|
||||
if( hb_gcItemRef( pItem, pBlock ) )
|
||||
@@ -270,12 +281,12 @@ BOOL hb_gcItemRef( HB_ITEM_PTR pItem, void *pBlock )
|
||||
else if( HB_IS_BLOCK( pItem ) )
|
||||
{
|
||||
return ( pItem->item.asBlock.value == ( HB_CODEBLOCK_PTR )pBlock );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* service a single garbage collector step
|
||||
/* service a single garbage collector step
|
||||
* Check a single memory block if it can be released
|
||||
*/
|
||||
HB_FUNC( HB_GCSTEP )
|
||||
|
||||
Reference in New Issue
Block a user