Re: [PHP4BETA] ZEND API Question: Creating reference

From: Date: Sat, 04 Mar 2000 10:40:55 +0000
Subject: Re: [PHP4BETA] ZEND API Question: Creating reference
References: 1 2  Groups: php.version4 
Request: Send a blank email to php-version4+get-11508@lists.php.net to get a copy of this message
At 08:34 AM 3/3/00 -0600, Andrei Zmievski wrote:
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.
You should also change the strlen("root")+1 to sizeof("root"), wherever you are using a constant string. It is evaluated at compile time and thus faster. Andi --- Andi Gutmans <andi@zend.com> http://www.zend.com/

« previous php.version4 (#11508) next »