mirror of
https://github.com/php/php-src.git
synced 2024-11-27 11:53:33 +08:00
Add tracking for hashtable allocation
This commit is contained in:
parent
4e6635742d
commit
91b0d03346
@ -155,7 +155,7 @@ ZEND_API ulong zend_hash_func(char *arKey, uint nKeyLength)
|
||||
}
|
||||
|
||||
|
||||
ZEND_API int zend_hash_init(HashTable *ht, uint nSize, hash_func_t pHashFunction, dtor_func_t pDestructor, zend_bool persistent)
|
||||
ZEND_API int _zend_hash_init(HashTable *ht, uint nSize, hash_func_t pHashFunction, dtor_func_t pDestructor, zend_bool persistent ZEND_FILE_LINE_DC)
|
||||
{
|
||||
uint i = 3;
|
||||
|
||||
@ -169,7 +169,11 @@ ZEND_API int zend_hash_init(HashTable *ht, uint nSize, hash_func_t pHashFunction
|
||||
ht->nTableMask = ht->nTableSize - 1;
|
||||
|
||||
/* Uses ecalloc() so that Bucket* == NULL */
|
||||
ht->arBuckets = (Bucket **) pecalloc(ht->nTableSize, sizeof(Bucket *), persistent);
|
||||
if (persistent) {
|
||||
ht->arBuckets = (Bucket **) calloc(ht->nTableSize, sizeof(Bucket *));
|
||||
} else {
|
||||
ht->arBuckets = (Bucket **) ecalloc_rel(ht->nTableSize, sizeof(Bucket *));
|
||||
}
|
||||
|
||||
if (!ht->arBuckets) {
|
||||
return FAILURE;
|
||||
@ -188,9 +192,9 @@ ZEND_API int zend_hash_init(HashTable *ht, uint nSize, hash_func_t pHashFunction
|
||||
}
|
||||
|
||||
|
||||
ZEND_API int zend_hash_init_ex(HashTable *ht, uint nSize, hash_func_t pHashFunction, dtor_func_t pDestructor, zend_bool persistent, zend_bool bApplyProtection)
|
||||
ZEND_API int _zend_hash_init_ex(HashTable *ht, uint nSize, hash_func_t pHashFunction, dtor_func_t pDestructor, zend_bool persistent, zend_bool bApplyProtection ZEND_FILE_LINE_DC)
|
||||
{
|
||||
int retval = zend_hash_init(ht, nSize, pHashFunction, pDestructor, persistent);
|
||||
int retval = _zend_hash_init(ht, nSize, pHashFunction, pDestructor, persistent ZEND_FILE_LINE_CC);
|
||||
|
||||
ht->bApplyProtection = bApplyProtection;
|
||||
return retval;
|
||||
|
@ -77,10 +77,12 @@ typedef Bucket* HashPosition;
|
||||
BEGIN_EXTERN_C()
|
||||
|
||||
/* startup/shutdown */
|
||||
ZEND_API int zend_hash_init(HashTable *ht, uint nSize, hash_func_t pHashFunction, dtor_func_t pDestructor, zend_bool persistent);
|
||||
ZEND_API int zend_hash_init_ex(HashTable *ht, uint nSize, hash_func_t pHashFunction, dtor_func_t pDestructor, zend_bool persistent, zend_bool bApplyProtection);
|
||||
ZEND_API int _zend_hash_init(HashTable *ht, uint nSize, hash_func_t pHashFunction, dtor_func_t pDestructor, zend_bool persistent ZEND_FILE_LINE_DC);
|
||||
ZEND_API int _zend_hash_init_ex(HashTable *ht, uint nSize, hash_func_t pHashFunction, dtor_func_t pDestructor, zend_bool persistent, zend_bool bApplyProtection ZEND_FILE_LINE_DC);
|
||||
ZEND_API void zend_hash_destroy(HashTable *ht);
|
||||
ZEND_API void zend_hash_clean(HashTable *ht);
|
||||
#define zend_hash_init(ht, nSize, pHashFunction, pDestructor, persistent) _zend_hash_init((ht), (nSize), (pHashFunction), (pDestructor), (persistent) ZEND_FILE_LINE_CC)
|
||||
#define zend_hash_init_ex(ht, nSize, pHashFunction, pDestructor, persistent, bApplyProtection) _zend_hash_init_ex((ht), (nSize), (pHashFunction), (pDestructor), (persistent), (bApplyProtection) ZEND_FILE_LINE_CC)
|
||||
|
||||
/* additions/updates/changes */
|
||||
ZEND_API int zend_hash_add_or_update(HashTable *ht, char *arKey, uint nKeyLength, void *pData, uint nDataSize, void **pDest, int flag);
|
||||
|
Loading…
Reference in New Issue
Block a user