Re: [PHP4BETA] ZEND API Question: Creating reference
| From: | Andrei Zmievski | Date: | Fri, 03 Mar 2000 14:34:39 +0000 |
| Subject: | Re: [PHP4BETA] ZEND API Question: Creating reference | ||
| References: | 1 | Groups: | php.version4 |
| Request: | Send a blank email to php-version4+get-11456@lists.php.net to get a copy of this message | ||
On Fri, 03 Mar 2000, Uwe Steinmann wrote:
> In C this might look like the following (though it creates a copy):
>
> lht = children->value.ht;
> count = zend_hash_num_elements(lht);
> zend_hash_internal_pointer_reset(lht);
> for(i=0; i<count; i++) {
> zval **keydata;
> zend_hash_get_current_data(lht, (void **) &keydata);
> if([This is the one I was looking for]) {
> zend_hash_update(return_value->value.obj.properties, "root",
> strlen("root")+1, (void *) &(*keydata), sizeof(zval *), NULL);
> }
> zend_hash_move_forward(lht);
> }
>
> I tried zend_hash_update_ptr instead but this didn't work either.
> If fiddeled with refcount and is_ref, also without success.
Your update statement should look like this, first of all:
zend_hash_update(return_value->value.obj.properties, "root",
strlen("root")+1, (void **) keydata, sizeof(zval *), NULL);
Secondly, you can simply set is_ref and increment refcount and it should
work.
-Andrei
* Think digital, act analog. *