
初始化
有指定析构函数,在销毁hash的时候会调用,如:“类似extension=test.so扩展”也是存放在HashTable中的,“类似extension=test.so扩展”的module_shutdown_func函数就是靠hash的析构函数来调用的
zend_hash_init_ex(GLOBAL_FUNCTION_TABLE, , NULL, ZEND_FUNCTION_DTOR, , );
{
// zend_hash_init_ex 定义在文件“php-5.6.26\Zend\zend_hash.h”
#define zend_hash_init_ex(ht, nSize, pHashFunction, pDestructor, persistent, bApplyProtection) _zend_hash_init_ex((ht), (nSize), (pDestructor), (persistent), (bApplyProtection) ZEND_FILE_LINE_CC)
{ // _zend_hash_init_ex 实现在文件“php-5.6.26\Zend\zend_hash.c”
ZEND_API int _zend_hash_init_ex(HashTable *ht, uint nSize, dtor_func_t pDestructor, zend_bool persistent, zend_bool bApplyProtection ZEND_FILE_LINE_DC)
{
int retval = _zend_hash_init(ht, nSize, pDestructor, persistent ZEND_FILE_LINE_CC);
{
uint i = ; SET_INCONSISTENT(HT_OK); if (nSize >= 0x80000000) {
/* prevent overflow */
ht->nTableSize = 0x80000000;
} else {
while ((1U << i) < nSize) {
i++;
}
ht->nTableSize = << i;
} ht->nTableMask = ; /* 0 means that ht->arBuckets is uninitialized */
ht->pDestructor = pDestructor; // !!! 析构函数
ht->arBuckets = (Bucket**)&uninitialized_bucket;
ht->pListHead = NULL;
ht->pListTail = NULL;
ht->nNumOfElements = ;
ht->nNextFreeElement = ;
ht->pInternalPointer = NULL;
ht->persistent = persistent;
ht->nApplyCount = ;
ht->bApplyProtection = ;
return SUCCESS;
} ht->bApplyProtection = bApplyProtection;
return retval;
}
}
}