Re: zval_copy_ctor

From: Date: Sat, 12 May 2001 11:39:32 +0000
Subject: Re: zval_copy_ctor
References: 1 2 3  Groups: php.dev 
Request: Send a blank email to php-dev+get-54998@lists.php.net to get a copy of this message
At 11:28 AM 5/12/2001 +0100, Wez Furlong wrote:
On 2001-05-12 10:12:14, "Andi Gutmans" <andi@zend.com> wrote: The code is almost OK. The only problem is that the reference count and is_ref from rfcbuf->headers are also copied to *headers. So what you should be doing (if you only add it once to the return_value) is to do INIT_PZVAL(headers) before the hash_update so that they are reset to refcount=1 is_ref=0. Like this? zval * headers; MAKE_STD_ZVAL(headers); *headers = *rfcbuf->headers; INIT_PZVAL(headers); if (zval_copy_ctor(headers) == SUCCESS) {
    zend_hash_update(HASH_OF(return_value), "headers",
        sizeof("headers"), &headers, sizeof(headers)
        NULL);
}
Yep that's good. By the way, another thing. You don't have to do the zval_copy_ctor() == SUCCESS either. I guess it is more correct but we don't do it anywhere in our code and if it ever happens we're screwed anyway. It could probably return void but I'd have to go back in time and think why it was done the way it was :) Andi
And by the way, zval_copy_ctor does recursive copy constructing so your code is OK. Great; that's a relief :-) Thanks! --Wez.


« previous php.dev (#54998) next »