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