Hi Moriyoshi, Sorry to copy the INIT_DATA macro in the mail. #define INIT_DATA(ht, p, pData, nDataSize) if (nDataSize == sizeof(void*)) { memcpy(&(p)->pDataPtr, pData, sizeof(void *)); (p)->pData = &(p)->pDataPtr; } else { (p)->pData = (void *) pemalloc_rel(nDataSize, (ht)->persistent); if (!(p)->pData) { pefree_rel(p, (ht)->persistent); return FAILURE; } memcpy((p)->pData, pData, nDataSize); (p)->pDataPtr=NULL; }
In case of deep copy the global_class_table, For each class entry in the hash table, We call the above macro INIT_DATA which allocates nDataSize( in this case 292) bytes for zend_class_entry. We copy the corressponding entry(INIT_DATA). Since nDataSize is 292 we will be in the else block. As you told there will be redundant memory of sizeof(zend_class_entry) - sizeof(zend_class_entry *) This redundancy is fine atleast. But the problem is in the NetWare port as I am not able copy the 292 bytes as the way with linux. The source address goes beyond my process address space and I am getting segmentation fault. What is the likelyhood of having similar seg fault in Linux? With regards Kamesh Jayachandran On Thu, 8 Jul 2004 18:01:17 +0900, "Moriyoshi Koizumi" <[EMAIL PROTECTED]> said: > > On 2004/07/08, at 14:41, Kamesh Jayachandran wrote: > > > The last parameter sizeof(zend_class_entry) of value say 292 to > > zend_hash_copy indicate it to dereference the value of one of the > > hashtable entry. > > This value is of type zend_class_entry** which when dereferenced once > > gives rise to zend_class_entry* the corresponding memcpy function > > copies > > 292 bytes from this zend_class_entry * which is not correct. > > For details look at INIT_DATA macro in zend_hash.c > > This makes sense. So, your intention is just to make the line in > question > to reduce unnecessary malloc()'s and memcpy()'s. > > zend_hash_copy(compiler_globals->class_table, ... , > sizeof(zend_class_entry)); > > Although this can eventually work, the newly built hash table > CG(class_table) > will hold the redundant space of sizeof(zend_class_entry) - > sizeof(zend_class_entry *) bytes > per class entry. > > And then you pointed out the above line should go like > > zend_hash_copy(compiler_globals->class_table, ... , > sizeof(zend_class_entry *)); > > This appears a typo because the global function table, which is > a hash table that contains instances of zend_function (not > zend_function *), > is also copied by zend_hash_copy() with the last argument being > sizeof(zend_function). > > zend_hash_copy(compiler_globals->function_table, ... , > sizeof(zend_function)); > > > ... Did I get it right? > > Regards, > Moriyoshi > -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php