2025-01-24 12:32 UTC+0100 Przemyslaw Czerpak (druzus/at/poczta.onet.pl)

* contrib/hbwin/olecore.c
    * pacified false MSVC warning. It's very seldom situation that I'm adding
      code to pacify false compiler warnings anyhow in this case it cost in
      practice nothing so I decided to do that.

  * contrib/xhb/hboutdbg.c
  * src/rtl/gtcrs/gtcrs.c
    * NULL pointer casting to pacify warning

  * src/pp/hbpp.c
    % do not created new iLen variable but reuse the one previously declared

  * src/vm/classes.c
    % allocate puiMsgIdx as array of HB_USHORT items instead of HB_SYMCNT.
      This modification only reduces the memory usage and has no effect on
      number of accepted symbols.
    * changed 'HB_SYMCNT uiHashKey' to 'HB_SIZE nHashKey' to avoid explicit
      casting in the code
This commit is contained in:
Przemysław Czerpak
2025-01-24 12:32:32 +01:00
parent 8b21566675
commit bf146ab5ee
6 changed files with 63 additions and 41 deletions

View File

@@ -7,6 +7,26 @@
Entries may not always be in chronological/commit order. Entries may not always be in chronological/commit order.
See license at the end of file. */ See license at the end of file. */
2025-01-24 12:32 UTC+0100 Przemyslaw Czerpak (druzus/at/poczta.onet.pl)
* contrib/hbwin/olecore.c
* pacified false MSVC warning. It's very seldom situation that I'm adding
code to pacify false compiler warnings anyhow in this case it cost in
practice nothing so I decided to do that.
* contrib/xhb/hboutdbg.c
* src/rtl/gtcrs/gtcrs.c
* NULL pointer casting to pacify warning
* src/pp/hbpp.c
% do not created new iLen variable but reuse the one previously declared
* src/vm/classes.c
% allocate puiMsgIdx as array of HB_USHORT items instead of HB_SYMCNT.
This modification only reduces the memory usage and has no effect on
number of accepted symbols.
* changed 'HB_SYMCNT uiHashKey' to 'HB_SIZE nHashKey' to avoid explicit
casting in the code
2025-01-24 10:10 UTC+0100 Przemyslaw Czerpak (druzus/at/poczta.onet.pl) 2025-01-24 10:10 UTC+0100 Przemyslaw Czerpak (druzus/at/poczta.onet.pl)
* contrib/hbssl/hbssl.hbm * contrib/hbssl/hbssl.hbm
* added -Wno-error=deprecated-declarations to suppress errors in Solaris * added -Wno-error=deprecated-declarations to suppress errors in Solaris

View File

@@ -2230,6 +2230,8 @@ HB_FUNC( WIN_OLEAUTO___ONERROR )
if( ! pDisp ) if( ! pDisp )
return; return;
dispid = ( DISPID ) 0; /* to pacify MSVC false warning */
iPCount = hb_pcount(); iPCount = hb_pcount();
szMethod = hb_itemGetSymbol( hb_stackBaseItem() )->szName; szMethod = hb_itemGetSymbol( hb_stackBaseItem() )->szName;

View File

@@ -116,7 +116,7 @@ static void debugInit( void )
if( iFifoResult != EEXIST ) if( iFifoResult != EEXIST )
{ {
s_iXtermPid = execlp( "xterm", "xterm", "-T", szDebugTitle, "-e", s_iXtermPid = execlp( "xterm", "xterm", "-T", szDebugTitle, "-e",
"cat", szDebugName, NULL ); "cat", szDebugName, ( char * ) NULL );
if( s_iXtermPid <= 0 ) if( s_iXtermPid <= 0 )
{ {

View File

@@ -594,8 +594,8 @@ static int hb_pp_parseChangelog( PHB_PP_STATE pState, const char * pszFileName,
if( strlen( szLog ) >= 16 ) if( strlen( szLog ) >= 16 )
{ {
long lJulian = 0, lMilliSec = 0; long lJulian = 0, lMilliSec = 0;
int iLen = 16;
iLen = 16;
if( szLog[ 16 ] == ' ' && szLog[ 17 ] == 'U' && if( szLog[ 16 ] == ' ' && szLog[ 17 ] == 'U' &&
szLog[ 18 ] == 'T' && szLog[ 19 ] == 'C' && szLog[ 18 ] == 'T' && szLog[ 19 ] == 'C' &&
( szLog[ 20 ] == '+' || szLog[ 20 ] == '-' ) && ( szLog[ 20 ] == '+' || szLog[ 20 ] == '-' ) &&

View File

@@ -2163,7 +2163,7 @@ static InOutBase * create_newXterm( void )
( void ) setgid( getgid() ); ( void ) setgid( getgid() );
execlp( "xterm", "xterm", buf, "+sb", execlp( "xterm", "xterm", buf, "+sb",
"-fg", "white", "-fg", "white",
"-bg", "black", "-fn", "fixed", "-T", "HB-XTERM Window", NULL ); "-bg", "black", "-fn", "fixed", "-T", "HB-XTERM Window", ( char * ) NULL );
_exit( EXIT_FAILURE ); _exit( EXIT_FAILURE );
} }
close( masterfd ); close( masterfd );

View File

@@ -167,10 +167,10 @@ typedef struct
HB_USHORT uiFriendSyms; /* Number of friend function's symbols */ HB_USHORT uiFriendSyms; /* Number of friend function's symbols */
HB_USHORT uiFriendModule; /* Number of friend symbols in pFriendModule */ HB_USHORT uiFriendModule; /* Number of friend symbols in pFriendModule */
HB_USHORT uiMutexOffset; /* Offset in instance area to SYNC method mutex */ HB_USHORT uiMutexOffset; /* Offset in instance area to SYNC method mutex */
HB_SYMCNT uiHashKey; HB_SIZE nHashKey;
#ifdef HB_MSG_POOL #ifdef HB_MSG_POOL
HB_USHORT uiMethodCount; HB_USHORT uiMethodCount;
HB_SYMCNT * puiMsgIdx; HB_USHORT * puiMsgIdx;
#endif #endif
} CLASS, * PCLASS; } CLASS, * PCLASS;
@@ -181,12 +181,12 @@ typedef struct
#define HASH_KEY ( ( 1 << HASHBITS ) - 1 ) #define HASH_KEY ( ( 1 << HASHBITS ) - 1 )
#define HASH_KEYMAX ( 1 << ( 32 - BUCKETBITS ) ) #define HASH_KEYMAX ( 1 << ( 32 - BUCKETBITS ) )
#define hb_clsInited(p) ( (p)->pMethods != NULL ) #define hb_clsInited(p) ( (p)->pMethods != NULL )
#define hb_clsBucketPos( p, m ) ( ( (p)->uiSymNum & (m) ) << BUCKETBITS ) #define hb_clsBucketPos( p, m ) ( ( ( HB_SIZE ) (p)->uiSymNum & (m) ) << BUCKETBITS )
#ifdef HB_MSG_POOL #ifdef HB_MSG_POOL
# define hb_clsMthNum( p ) ( ( HB_SIZE ) ( p )->uiMethodCount ) # define hb_clsMthNum( p ) ( ( HB_SIZE ) ( p )->uiMethodCount )
#else #else
# define hb_clsMthNum( p ) ( ( ( HB_SIZE ) ( p )->uiHashKey + 1 ) << BUCKETBITS ) # define hb_clsMthNum( p ) ( ( ( p )->nHashKey + 1 ) << BUCKETBITS )
#endif #endif
#if defined( HB_REAL_BLOCK_SCOPE ) #if defined( HB_REAL_BLOCK_SCOPE )
@@ -196,7 +196,7 @@ typedef struct
#endif #endif
#if ! defined( HB_CLASSY_BLOCK_SCOPE ) #if ! defined( HB_CLASSY_BLOCK_SCOPE )
# define hb_clsSenderOffset() hb_stackBaseProcOffset( 1 ) # define hb_clsSenderOffset() hb_stackBaseProcOffset( 1 )
#endif #endif
@@ -374,7 +374,7 @@ static PHB_ITEM s_pClassMtx = NULL;
/* --- */ /* --- */
#if 0 #if 0
static HB_SYMCNT hb_clsBucketPos( PHB_DYNS pMsg, HB_SYMCNT uiMask ) static HB_SIZE hb_clsBucketPos( PHB_DYNS pMsg, HB_SIZE uiMask )
{ {
/* we can use PHB_DYNS address as base for hash key. /* we can use PHB_DYNS address as base for hash key.
* This value is perfectly unique and we do not need anything more * This value is perfectly unique and we do not need anything more
@@ -408,14 +408,14 @@ static HB_BOOL hb_clsDictRealloc( PCLASS pClass )
HB_SIZE nNewHashKey, nLimit, n; HB_SIZE nNewHashKey, nLimit, n;
#ifdef HB_MSG_POOL #ifdef HB_MSG_POOL
HB_SYMCNT * puiMsgIdx; HB_USHORT * puiMsgIdx;
#else #else
PMETHOD pNewMethods; PMETHOD pNewMethods;
#endif #endif
HB_TRACE( HB_TR_DEBUG, ( "hb_clsDictRealloc(%p)", ( void * ) pClass ) ); HB_TRACE( HB_TR_DEBUG, ( "hb_clsDictRealloc(%p)", ( void * ) pClass ) );
nNewHashKey = ( HB_SIZE ) pClass->uiHashKey + 1; nNewHashKey = pClass->nHashKey + 1;
nLimit = nNewHashKey << BUCKETBITS; nLimit = nNewHashKey << BUCKETBITS;
do do
@@ -425,15 +425,15 @@ static HB_BOOL hb_clsDictRealloc( PCLASS pClass )
hb_errInternal( 6002, "Could not realloc class message in __clsDictRealloc()", NULL, NULL ); hb_errInternal( 6002, "Could not realloc class message in __clsDictRealloc()", NULL, NULL );
#ifdef HB_MSG_POOL #ifdef HB_MSG_POOL
puiMsgIdx = ( HB_SYMCNT * ) hb_xgrabz( ( nNewHashKey << BUCKETBITS ) * sizeof( HB_SYMCNT ) ); puiMsgIdx = ( HB_USHORT * ) hb_xgrabz( ( nNewHashKey << BUCKETBITS ) * sizeof( HB_USHORT ) );
for( n = 0; n < nLimit; n++ ) for( n = 0; n < nLimit; n++ )
{ {
HB_SYMCNT uiMsg = pClass->puiMsgIdx[ n ]; HB_USHORT uiMsg = pClass->puiMsgIdx[ n ];
if( pClass->puiMsgIdx[ n ] ) if( pClass->puiMsgIdx[ n ] )
{ {
HB_SYMCNT uiBucket = BUCKETSIZE; HB_USHORT uiBucket = BUCKETSIZE;
HB_SYMCNT * puiIdx = puiMsgIdx + hb_clsBucketPos( HB_USHORT * puiIdx = puiMsgIdx + hb_clsBucketPos(
pClass->pMethods[ uiMsg ].pMessage, nNewHashKey - 1 ); pClass->pMethods[ uiMsg ].pMessage, nNewHashKey - 1 );
do do
{ {
@@ -457,7 +457,7 @@ static HB_BOOL hb_clsDictRealloc( PCLASS pClass )
} }
while( n < nLimit ); while( n < nLimit );
pClass->uiHashKey = ( HB_SYMCNT ) ( nNewHashKey - 1 ); pClass->nHashKey = nNewHashKey - 1;
hb_xfree( pClass->puiMsgIdx ); hb_xfree( pClass->puiMsgIdx );
pClass->puiMsgIdx = puiMsgIdx; pClass->puiMsgIdx = puiMsgIdx;
@@ -472,7 +472,7 @@ static HB_BOOL hb_clsDictRealloc( PCLASS pClass )
if( pMessage ) if( pMessage )
{ {
PMETHOD pMethod = pNewMethods + hb_clsBucketPos( pMessage, nNewHashKey - 1 ); PMETHOD pMethod = pNewMethods + hb_clsBucketPos( pMessage, nNewHashKey - 1 );
HB_SYMCNT uiBucket = BUCKETSIZE; HB_USHORT uiBucket = BUCKETSIZE;
do do
{ {
@@ -496,7 +496,7 @@ static HB_BOOL hb_clsDictRealloc( PCLASS pClass )
} }
while( n < nLimit ); while( n < nLimit );
pClass->uiHashKey = ( HB_SYMCNT ) ( nNewHashKey - 1 ); pClass->nHashKey = nNewHashKey - 1;
hb_xfree( pClass->pMethods ); hb_xfree( pClass->pMethods );
pClass->pMethods = pNewMethods; pClass->pMethods = pNewMethods;
#endif #endif
@@ -504,21 +504,21 @@ static HB_BOOL hb_clsDictRealloc( PCLASS pClass )
return HB_TRUE; return HB_TRUE;
} }
static void hb_clsDictInit( PCLASS pClass, HB_SYMCNT uiHashKey ) static void hb_clsDictInit( PCLASS pClass, HB_SIZE nHashKey )
{ {
HB_SIZE nSize; HB_SIZE nSize;
HB_TRACE( HB_TR_DEBUG, ( "hb_clsDictInit(%p,%u)", ( void * ) pClass, uiHashKey ) ); HB_TRACE( HB_TR_DEBUG, ( "hb_clsDictInit(%p,%" HB_PFS "u)", ( void * ) pClass, nHashKey ) );
pClass->uiHashKey = uiHashKey; pClass->nHashKey = nHashKey;
#ifdef HB_MSG_POOL #ifdef HB_MSG_POOL
nSize = ( ( ( HB_SIZE ) uiHashKey + 1 ) << BUCKETBITS ) * sizeof( HB_SYMCNT ); nSize = ( ( nHashKey + 1 ) << BUCKETBITS ) * sizeof( HB_USHORT );
pClass->puiMsgIdx = ( HB_SYMCNT * ) hb_xgrabz( nSize ); pClass->puiMsgIdx = ( HB_USHORT * ) hb_xgrabz( nSize );
pClass->uiMethodCount = 1; pClass->uiMethodCount = 1;
pClass->pMethods = ( PMETHOD ) hb_xgrabz( sizeof( METHOD ) ); pClass->pMethods = ( PMETHOD ) hb_xgrabz( sizeof( METHOD ) );
#else #else
nSize = ( ( ( HB_SIZE ) uiHashKey + 1 ) << BUCKETBITS ) * sizeof( METHOD ); nSize = ( ( nHashKey + 1 ) << BUCKETBITS ) * sizeof( METHOD );
pClass->pMethods = ( PMETHOD ) hb_xgrabz( nSize ); pClass->pMethods = ( PMETHOD ) hb_xgrabz( nSize );
#endif #endif
} }
@@ -527,11 +527,11 @@ static PMETHOD hb_clsFindMsg( PCLASS pClass, PHB_DYNS pMsg )
{ {
#ifdef HB_MSG_POOL #ifdef HB_MSG_POOL
HB_SYMCNT uiBucket, * puiMsgIdx; HB_USHORT uiBucket, * puiMsgIdx;
HB_TRACE( HB_TR_DEBUG, ( "hb_clsFindMsg(%p,%p)", ( void * ) pClass, ( void * ) pMsg ) ); HB_TRACE( HB_TR_DEBUG, ( "hb_clsFindMsg(%p,%p)", ( void * ) pClass, ( void * ) pMsg ) );
puiMsgIdx = pClass->puiMsgIdx + hb_clsBucketPos( pMsg, pClass->uiHashKey ); puiMsgIdx = pClass->puiMsgIdx + hb_clsBucketPos( pMsg, pClass->nHashKey );
uiBucket = BUCKETSIZE; uiBucket = BUCKETSIZE;
do do
@@ -547,11 +547,11 @@ static PMETHOD hb_clsFindMsg( PCLASS pClass, PHB_DYNS pMsg )
#else #else
PMETHOD pMethod; PMETHOD pMethod;
HB_SYMCNT uiBucket; HB_USHORT uiBucket;
HB_TRACE( HB_TR_DEBUG, ( "hb_clsFindMsg(%p,%p)", ( void * ) pClass, ( void * ) pMsg ) ); HB_TRACE( HB_TR_DEBUG, ( "hb_clsFindMsg(%p,%p)", ( void * ) pClass, ( void * ) pMsg ) );
pMethod = pClass->pMethods + hb_clsBucketPos( pMsg, pClass->uiHashKey ); pMethod = pClass->pMethods + hb_clsBucketPos( pMsg, pClass->nHashKey );
uiBucket = BUCKETSIZE; uiBucket = BUCKETSIZE;
do do
@@ -576,8 +576,8 @@ static PMETHOD hb_clsAllocMsg( PCLASS pClass, PHB_DYNS pMsg )
#ifdef HB_MSG_POOL #ifdef HB_MSG_POOL
HB_SYMCNT uiBucket = BUCKETSIZE, * puiMsgIdx = pClass->puiMsgIdx + HB_USHORT uiBucket = BUCKETSIZE, * puiMsgIdx = pClass->puiMsgIdx +
hb_clsBucketPos( pMsg, pClass->uiHashKey ); hb_clsBucketPos( pMsg, pClass->nHashKey );
do do
{ {
@@ -597,8 +597,8 @@ static PMETHOD hb_clsAllocMsg( PCLASS pClass, PHB_DYNS pMsg )
#else #else
PMETHOD pMethod = pClass->pMethods + hb_clsBucketPos( pMsg, pClass->uiHashKey ); PMETHOD pMethod = pClass->pMethods + hb_clsBucketPos( pMsg, pClass->nHashKey );
HB_SYMCNT uiBucket = BUCKETSIZE; HB_USHORT uiBucket = BUCKETSIZE;
do do
{ {
@@ -637,12 +637,12 @@ static void hb_clsFreeMsg( PCLASS pClass, PHB_DYNS pMsg )
{ {
#ifdef HB_MSG_POOL #ifdef HB_MSG_POOL
HB_SYMCNT uiBucket, * puiMsgIdx; HB_USHORT uiBucket, * puiMsgIdx;
HB_TRACE( HB_TR_DEBUG, ( "hb_clsFreeMsg(%p,%p)", ( void * ) pClass, ( void * ) pMsg ) ); HB_TRACE( HB_TR_DEBUG, ( "hb_clsFreeMsg(%p,%p)", ( void * ) pClass, ( void * ) pMsg ) );
puiMsgIdx = pClass->puiMsgIdx + hb_clsBucketPos( pMsg, pClass->uiHashKey ); puiMsgIdx = pClass->puiMsgIdx + hb_clsBucketPos( pMsg, pClass->nHashKey );
uiBucket = BUCKETSIZE; uiBucket = BUCKETSIZE;
do do
@@ -664,12 +664,12 @@ static void hb_clsFreeMsg( PCLASS pClass, PHB_DYNS pMsg )
#else #else
PMETHOD pMethod; PMETHOD pMethod;
HB_SYMCNT uiBucket; HB_USHORT uiBucket;
HB_TRACE( HB_TR_DEBUG, ( "hb_clsFreeMsg(%p,%p)", ( void * ) pClass, ( void * ) pMsg ) ); HB_TRACE( HB_TR_DEBUG, ( "hb_clsFreeMsg(%p,%p)", ( void * ) pClass, ( void * ) pMsg ) );
pMethod = pClass->pMethods + hb_clsBucketPos( pMsg, pClass->uiHashKey ); pMethod = pClass->pMethods + hb_clsBucketPos( pMsg, pClass->nHashKey );
uiBucket = BUCKETSIZE; HB_USHORT = BUCKETSIZE;
do do
{ {
@@ -984,7 +984,7 @@ static void hb_clsCopyClass( PCLASS pClsDst, PCLASS pClsSrc )
HB_TRACE( HB_TR_DEBUG, ( "hb_clsCopyClass(%p,%p)", ( void * ) pClsDst, ( void * ) pClsSrc ) ); HB_TRACE( HB_TR_DEBUG, ( "hb_clsCopyClass(%p,%p)", ( void * ) pClsDst, ( void * ) pClsSrc ) );
hb_clsDictInit( pClsDst, pClsSrc->uiHashKey ); hb_clsDictInit( pClsDst, pClsSrc->nHashKey );
pClsDst->fHasOnError = pClsSrc->fHasOnError; pClsDst->fHasOnError = pClsSrc->fHasOnError;
pClsDst->fHasDestructor = pClsSrc->fHasDestructor; pClsDst->fHasDestructor = pClsSrc->fHasDestructor;
@@ -1027,7 +1027,7 @@ static void hb_clsCopyClass( PCLASS pClsDst, PCLASS pClsSrc )
nLimit = hb_clsMthNum( pClsSrc ); nLimit = hb_clsMthNum( pClsSrc );
#ifdef HB_MSG_POOL #ifdef HB_MSG_POOL
memcpy( pClsDst->puiMsgIdx, pClsSrc->puiMsgIdx, memcpy( pClsDst->puiMsgIdx, pClsSrc->puiMsgIdx,
( ( ( HB_SIZE ) pClsSrc->uiHashKey + 1 ) << BUCKETBITS ) * sizeof( HB_SYMCNT ) ); ( ( pClsSrc->nHashKey + 1 ) << BUCKETBITS ) * sizeof( HB_USHORT ) );
pClsDst->uiMethodCount = pClsSrc->uiMethodCount; pClsDst->uiMethodCount = pClsSrc->uiMethodCount;
pClsDst->pMethods = ( PMETHOD ) hb_xrealloc( pClsDst->pMethods, pClsDst->pMethods = ( PMETHOD ) hb_xrealloc( pClsDst->pMethods,
nLimit * sizeof( METHOD ) ); nLimit * sizeof( METHOD ) );
@@ -1836,8 +1836,8 @@ PHB_SYMB hb_objGetMethod( PHB_ITEM pObject, PHB_SYMB pMessage,
} }
#ifdef HB_MSG_POOL #ifdef HB_MSG_POOL
{ {
HB_SYMCNT uiBucket = BUCKETSIZE, * puiMsgIdx = HB_USHORT uiBucket = BUCKETSIZE, * puiMsgIdx =
pClass->puiMsgIdx + hb_clsBucketPos( pMsg, pClass->uiHashKey ); pClass->puiMsgIdx + hb_clsBucketPos( pMsg, pClass->nHashKey );
do do
{ {