Re: issue in copying the hash table(Reposted third time)
| From: | Kamesh Jayachandran | Date: | Thu, 08 Jul 2004 05:41:12 +0000 |
| Subject: | Re: issue in copying the hash table(Reposted third time) | ||
| References: | 1 2 3 4 5 6 7 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-10969@lists.php.net to get a copy of this message | ||
Hi Moriyoshi,
File: Zend/zend_compile.c
Function: do_bind_class
<some code snippet>
zend_class_entry *ce
zend_hash_add(class_table, opline->op2.u.constant.value.str.val,
opline->op2.u.constant.value.str.len+1, &ce, sizeof(zend_class_entry *),
NULL)
<some code snippet>
From the above zend_hash_add I came to a conclusion that class_table is
a HashTable of string versus zend_class_entry**.
Am I incorrect?
Whereas for function table
do_bind_function
zend_function *function;
zend_hash_add(function_table, opline->op2.u.constant.value.str.val,
opline->op2.u.constant.value.str.len+1, function, sizeof(zend_function),
NULL)
My argument is deep copy of hashtable using hash_copy will work in case
of function table not in case of class_table because of double
dereferencing needed in case of class_table.
In fact we invoke
zend_hash_copy(compiler_globals->class_table, global_class_table,
(copy_ctor_func_t) zend_class_add_ref, &tmp_class,
sizeof(zend_class_entry));
in Zend/zend.c in a function compiler_globals_ctor
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
Thanks in advance
With regards
Kamesh Jayachandran
On Thu, 8 Jul 2004 02:25:21 +0900, "Moriyoshi Koizumi"
<moriyoshi@at.wakwak.com> said:
>
> On 2004/07/08, at 1:04, Kamesh Jayachandran wrote:
>
> > My question is very simple.
> > Please answer the following question.
> > 1)Zend has global_class_table of type HashTable with a key as the class
> > name ('char*') and value of type 'zend_class_entry**'. True or False?
>
> Keys are just strings and associated values are of zend_class_entry *.
>
> ZendEngine's HashTable may seem a quirk. It passes a pointer to the
> given value, not the holding value itself (of type zend_class_entry *,
> in this case). Is there something wrong with this?
>
> Moriyoshi
>