cvs: ZendEngine2 / zend_hash.c zend_hash.h

From: Date: Tue, 17 Sep 2002 14:04:37 +0000
Subject: cvs: ZendEngine2 / zend_hash.c zend_hash.h
Groups: php.zend-engine.cvs 
Request: Send a blank email to php-zend-engine-cvs+get-435@lists.php.net to get a copy of this message
zeev Tue Sep 17 10:04:37 2002 EDT Modified files: /ZendEngine2 zend_hash.c zend_hash.h Log: Add tracking for hashtable allocation Index: ZendEngine2/zend_hash.c diff -u ZendEngine2/zend_hash.c:1.90 ZendEngine2/zend_hash.c:1.91 --- ZendEngine2/zend_hash.c:1.90 Sat Aug 17 12:07:26 2002 +++ ZendEngine2/zend_hash.c Tue Sep 17 10:04:37 2002 @@ -155,7 +155,7 @@ } -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 @@ 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_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; Index: ZendEngine2/zend_hash.h diff -u ZendEngine2/zend_hash.h:1.59 ZendEngine2/zend_hash.h:1.60 --- ZendEngine2/zend_hash.h:1.59 Sat Jun 8 09:01:05 2002 +++ ZendEngine2/zend_hash.h Tue Sep 17 10:04:37 2002 @@ -77,10 +77,12 @@ 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);

« previous php.zend-engine.cvs (#435) next »