2017-12-12 12:26 UTC+0100 Przemyslaw Czerpak (druzus/at/poczta.onet.pl)
* contrib/hbnf/fttext.c
* contrib/hbnf/hbnf.hbx
* synced with Viktor's modifications:
- use FILE API instead of FS API
- protection against GPF when FT area has no valid file handle
- alternative function names which exceeds 10 character Cl*pper limit
! fixed handle and memory leak when new file is open in FT area which
already has open file
* include/harbour.hbx
* src/harbour.def
* src/vm/hvm.c
+ added new PRG function: __vmItemRefs( <xVal> ) -> <nRefs>
Please remember that passed <xVal> parameter increases the counter so
if you want to eliminate it then pass it by reference, i,e.:
aVal := {}
? __vmItemRefs( aVal ), __vmItemRefs( @aVal )
* include/hbapi.h
* src/harbour.def
* src/vm/arrays.c
* src/vm/codebloc.c
* src/vm/hashes.c
+ added new C functions:
HB_COUNTER hb_arrayRefs( PHB_ITEM pArray );
HB_COUNTER hb_hashRefs( PHB_ITEM pHash );
HB_COUNTER hb_codeblockRefs( PHB_ITEM pItem );
* src/rtl/itemseri.c
* added new internal function to replace 3 times repeated code for
resizing array of references.
% use new functions to check number of references to hashes, arrays and
objects to ignore in system detecting multiple references the items
which have reference counter smaller then 2. Such items cannot have
multiple references.
In practice this modification resolves the time problem when very big
items are serialized to the level comparable to HB_SERIALIZE_IGNOREREF
so now this flag is useless though I'll keep it because only in such
mode serialization code can be used as filter in streams.
I also created binary tree to store references but after this
modifications it is not necessary so I decided to not commit it yet.
Please only remember that practice limit of such serialization code
is created by physical memory attached by OS to the process. When this
limit is exceed then swap is actively used what completely kill the
performance. The CPU usage is reduced to less then 1% because it waits
for restoring swapped memory pages by extremely heavy used disks. In
such case I cannot help.
This commit is contained in:
@@ -1594,6 +1594,7 @@ DYNAMIC __TracePrgCalls
|
||||
DYNAMIC __TypeFile
|
||||
DYNAMIC __vmCountThreads
|
||||
DYNAMIC __vmItemID
|
||||
DYNAMIC __vmItemRefs
|
||||
DYNAMIC __vmModulesVerify
|
||||
DYNAMIC __vmNoInternals
|
||||
DYNAMIC __Wait
|
||||
|
||||
@@ -798,6 +798,7 @@ extern HB_EXPORT HB_BOOL hb_arrayNew( PHB_ITEM pItem, HB_SIZE nLen ); /* cr
|
||||
extern HB_EXPORT HB_SIZE hb_arrayLen( PHB_ITEM pArray ); /* retrieves the array length */
|
||||
extern HB_EXPORT HB_BOOL hb_arrayIsObject( PHB_ITEM pArray ); /* retrieves if the array is an object */
|
||||
extern HB_EXPORT void * hb_arrayId( PHB_ITEM pArray ); /* retrieves the array unique ID */
|
||||
extern HB_EXPORT HB_COUNTER hb_arrayRefs( PHB_ITEM pArray ); /* retrieves numer of references to the array */
|
||||
extern HB_EXPORT PHB_ITEM hb_arrayFromId( PHB_ITEM pItem, void * pArrayId );
|
||||
extern HB_EXPORT HB_BOOL hb_arrayAdd( PHB_ITEM pArray, PHB_ITEM pItemValue ); /* add a new item to the end of an array item */
|
||||
extern HB_EXPORT HB_BOOL hb_arrayAddForward( PHB_ITEM pArray, PHB_ITEM pValue ); /* add a new item to the end of an array item with no incrementing of reference counters */
|
||||
@@ -877,39 +878,40 @@ extern void hb_hashCloneBody( PHB_ITEM pDest, PHB_ITEM pHash, PHB_NESTED_CLONED
|
||||
|
||||
|
||||
/* hash management */
|
||||
extern HB_EXPORT PHB_ITEM hb_hashNew( PHB_ITEM pItem );
|
||||
extern HB_EXPORT HB_SIZE hb_hashLen( PHB_ITEM pHash );
|
||||
extern HB_EXPORT HB_BOOL hb_hashDel( PHB_ITEM pHash, PHB_ITEM pKey );
|
||||
extern HB_EXPORT HB_BOOL hb_hashAdd( PHB_ITEM pHash, PHB_ITEM pKey, PHB_ITEM pValue );
|
||||
extern HB_EXPORT HB_BOOL hb_hashAddNew( PHB_ITEM pHash, PHB_ITEM pKey, PHB_ITEM pValue );
|
||||
extern HB_EXPORT HB_BOOL hb_hashRemove( PHB_ITEM pHash, PHB_ITEM pItem );
|
||||
extern HB_EXPORT HB_BOOL hb_hashClear( PHB_ITEM pHash );
|
||||
extern HB_EXPORT HB_BOOL hb_hashAllocNewPair( PHB_ITEM pHash, PHB_ITEM * pKeyPtr, PHB_ITEM * pValPtr );
|
||||
extern HB_EXPORT void hb_hashSort( PHB_ITEM pHash );
|
||||
extern HB_EXPORT PHB_ITEM hb_hashClone( PHB_ITEM pHash );
|
||||
extern HB_EXPORT PHB_ITEM hb_hashCloneTo( PHB_ITEM pDest, PHB_ITEM pHash );
|
||||
extern HB_EXPORT void hb_hashJoin( PHB_ITEM pDest, PHB_ITEM pSource, int iType );
|
||||
extern HB_EXPORT HB_BOOL hb_hashScan( PHB_ITEM pHash, PHB_ITEM pKey, HB_SIZE * pnPos );
|
||||
extern HB_EXPORT HB_BOOL hb_hashScanSoft( PHB_ITEM pHash, PHB_ITEM pKey, HB_SIZE * pnPos );
|
||||
extern HB_EXPORT void hb_hashPreallocate( PHB_ITEM pHash, HB_SIZE nNewSize );
|
||||
extern HB_EXPORT PHB_ITEM hb_hashGetKeys( PHB_ITEM pHash );
|
||||
extern HB_EXPORT PHB_ITEM hb_hashGetValues( PHB_ITEM pHash );
|
||||
extern HB_EXPORT void hb_hashSetDefault( PHB_ITEM pHash, PHB_ITEM pValue );
|
||||
extern HB_EXPORT PHB_ITEM hb_hashGetDefault( PHB_ITEM pHash );
|
||||
extern HB_EXPORT void hb_hashSetFlags( PHB_ITEM pHash, int iFlags );
|
||||
extern HB_EXPORT void hb_hashClearFlags( PHB_ITEM pHash, int iFlags );
|
||||
extern HB_EXPORT int hb_hashGetFlags( PHB_ITEM pHash );
|
||||
extern HB_EXPORT void * hb_hashId( PHB_ITEM pHash ); /* retrieves the hash unique ID */
|
||||
extern HB_EXPORT PHB_ITEM hb_hashNew( PHB_ITEM pItem );
|
||||
extern HB_EXPORT HB_SIZE hb_hashLen( PHB_ITEM pHash );
|
||||
extern HB_EXPORT HB_BOOL hb_hashDel( PHB_ITEM pHash, PHB_ITEM pKey );
|
||||
extern HB_EXPORT HB_BOOL hb_hashAdd( PHB_ITEM pHash, PHB_ITEM pKey, PHB_ITEM pValue );
|
||||
extern HB_EXPORT HB_BOOL hb_hashAddNew( PHB_ITEM pHash, PHB_ITEM pKey, PHB_ITEM pValue );
|
||||
extern HB_EXPORT HB_BOOL hb_hashRemove( PHB_ITEM pHash, PHB_ITEM pItem );
|
||||
extern HB_EXPORT HB_BOOL hb_hashClear( PHB_ITEM pHash );
|
||||
extern HB_EXPORT HB_BOOL hb_hashAllocNewPair( PHB_ITEM pHash, PHB_ITEM * pKeyPtr, PHB_ITEM * pValPtr );
|
||||
extern HB_EXPORT void hb_hashSort( PHB_ITEM pHash );
|
||||
extern HB_EXPORT PHB_ITEM hb_hashClone( PHB_ITEM pHash );
|
||||
extern HB_EXPORT PHB_ITEM hb_hashCloneTo( PHB_ITEM pDest, PHB_ITEM pHash );
|
||||
extern HB_EXPORT void hb_hashJoin( PHB_ITEM pDest, PHB_ITEM pSource, int iType );
|
||||
extern HB_EXPORT HB_BOOL hb_hashScan( PHB_ITEM pHash, PHB_ITEM pKey, HB_SIZE * pnPos );
|
||||
extern HB_EXPORT HB_BOOL hb_hashScanSoft( PHB_ITEM pHash, PHB_ITEM pKey, HB_SIZE * pnPos );
|
||||
extern HB_EXPORT void hb_hashPreallocate( PHB_ITEM pHash, HB_SIZE nNewSize );
|
||||
extern HB_EXPORT PHB_ITEM hb_hashGetKeys( PHB_ITEM pHash );
|
||||
extern HB_EXPORT PHB_ITEM hb_hashGetValues( PHB_ITEM pHash );
|
||||
extern HB_EXPORT void hb_hashSetDefault( PHB_ITEM pHash, PHB_ITEM pValue );
|
||||
extern HB_EXPORT PHB_ITEM hb_hashGetDefault( PHB_ITEM pHash );
|
||||
extern HB_EXPORT void hb_hashSetFlags( PHB_ITEM pHash, int iFlags );
|
||||
extern HB_EXPORT void hb_hashClearFlags( PHB_ITEM pHash, int iFlags );
|
||||
extern HB_EXPORT int hb_hashGetFlags( PHB_ITEM pHash );
|
||||
extern HB_EXPORT void * hb_hashId( PHB_ITEM pHash ); /* retrieves the hash unique ID */
|
||||
extern HB_EXPORT HB_COUNTER hb_hashRefs( PHB_ITEM pHash ); /* retrieves numer of references to the hash */
|
||||
|
||||
/* these hb_hashGet*() functions are dangerous, be sure that base HASH value will not be changed */
|
||||
extern HB_EXPORT PHB_ITEM hb_hashGetItemPtr( PHB_ITEM pHash, PHB_ITEM pKey, int iFlags );
|
||||
extern HB_EXPORT PHB_ITEM hb_hashGetItemRefPtr( PHB_ITEM pHash, PHB_ITEM pKey );
|
||||
extern HB_EXPORT PHB_ITEM hb_hashGetCItemPtr( PHB_ITEM pHash, const char * pszKey );
|
||||
extern HB_EXPORT HB_SIZE hb_hashGetCItemPos( PHB_ITEM pHash, const char * pszKey );
|
||||
extern HB_EXPORT PHB_ITEM hb_hashGetKeyAt( PHB_ITEM pHash, HB_SIZE nPos );
|
||||
extern HB_EXPORT PHB_ITEM hb_hashGetValueAt( PHB_ITEM pHash, HB_SIZE nPos );
|
||||
extern HB_EXPORT PHB_ITEM hb_hashGetItemPtr( PHB_ITEM pHash, PHB_ITEM pKey, int iFlags );
|
||||
extern HB_EXPORT PHB_ITEM hb_hashGetItemRefPtr( PHB_ITEM pHash, PHB_ITEM pKey );
|
||||
extern HB_EXPORT PHB_ITEM hb_hashGetCItemPtr( PHB_ITEM pHash, const char * pszKey );
|
||||
extern HB_EXPORT HB_SIZE hb_hashGetCItemPos( PHB_ITEM pHash, const char * pszKey );
|
||||
extern HB_EXPORT PHB_ITEM hb_hashGetKeyAt( PHB_ITEM pHash, HB_SIZE nPos );
|
||||
extern HB_EXPORT PHB_ITEM hb_hashGetValueAt( PHB_ITEM pHash, HB_SIZE nPos );
|
||||
|
||||
extern HB_EXPORT HB_BOOL hb_hashDelAt( PHB_ITEM pHash, HB_SIZE nPos );
|
||||
extern HB_EXPORT HB_BOOL hb_hashDelAt( PHB_ITEM pHash, HB_SIZE nPos );
|
||||
|
||||
/* hash item flags */
|
||||
#define HB_HASH_AUTOADD_NEVER 0x00
|
||||
@@ -1071,7 +1073,8 @@ extern HB_EXPORT void hb_winmainArgVFree( void );
|
||||
#endif
|
||||
|
||||
/* Codeblock management */
|
||||
extern HB_EXPORT void * hb_codeblockId( PHB_ITEM pItem ); /* retrieves the codeblock unique ID */
|
||||
extern HB_EXPORT void * hb_codeblockId( PHB_ITEM pItem ); /* retrieves the codeblock unique ID */
|
||||
extern HB_EXPORT HB_COUNTER hb_codeblockRefs( PHB_ITEM pItem ); /* retrieves numer of references to the codeblock */
|
||||
extern PHB_CODEBLOCK hb_codeblockNew( const HB_BYTE * pBuffer, HB_USHORT uiLocals, const HB_BYTE * pLocalPosTable, PHB_SYMB pSymbols, HB_SIZE nLen ); /* create a code-block */
|
||||
extern PHB_CODEBLOCK hb_codeblockMacroNew( const HB_BYTE * pBuffer, HB_SIZE nLen );
|
||||
extern PHB_ITEM hb_codeblockGetVar( PHB_ITEM pItem, int iItemPos ); /* get local variable referenced in a codeblock */
|
||||
|
||||
Reference in New Issue
Block a user