Re: [PHP-DEV] zval_copy_ctor From: Wez Furlong (wez <email protected>)
Date: 05/12/01

On 2001-05-12 10:12:14, "Andi Gutmans" <andi <email protected>> 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);
}

> And by the way, zval_copy_ctor does recursive copy constructing so your

> code is OK.

Great; that's a relief :-)

Thanks!

--Wez.

-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: php-dev-unsubscribe <email protected>
For additional commands, e-mail: php-dev-help <email protected>
To contact the list administrators, e-mail: php-list-admin <email protected>