RE: [PHP-DEV] Help on ZVAL (array) memory management From: Huajie Liu (hliu <email protected>)
Date: 12/26/00

Thanks Stig,

What I am trying to do is to convert a C tree structure to
php array (hashtable) so that I can use this data structure
from my php scripts. I tried to use zval_dtor() but it seems
not to free the whole structure contained by zval, including
the hashtable in hashtable.

In the my code snippet, if I zval_dtor(myzval), will 'zarray'
get freed too?

-huajie

-----Original Message-----
From: Stig Venaas [mailto:Stig.Venaas <email protected>]
Sent: Tuesday, December 26, 2000 1:34 PM
To: Huajie Liu
Cc: php-dev <email protected>
Subject: Re: [PHP-DEV] Help on ZVAL (array) memory management

Hi

On Tue, Dec 26, 2000 at 12:38:46PM -0500, Huajie Liu wrote:
> Hi all,
> I am writing a C extension for PHP using zend API. But I got
> serious memory leak problem. They seems related to freeing
> zval hashtable. The following is a snippet of my code:
>
> MAKE_STD_ZVAL (myzval);
> if (array_init (myzval) == FAILURE)
> {
> }
> ZEND_SET_SYMBOL (myzval->value.ht, key, zarray);
>
>
> Can anyone give me some pointer on when and how to release
> the memory allocated? It will be hihgly appreciated if

Not sure what to say to when, except that you should free
all memory you allocate before returning from the function,
unless it belongs to the data you are returning.

I think all you need to do is

zval_dtor(myzval);

> you can also point me some documents I can read through.

Personally I mostly look at code that does similar things to what
I want to do and look at the Zend source. The documentation at
http://www.zend.com/apidoc/ might be of some help too.

Stig

-- 
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>