Date: 12/26/00
- Next message: Zeev Suraski: "Re: [PHP-DEV] Why zend_language_scanner_cc.cc instead of zend_language_scanner.c?"
- Previous message: Chris Newbill: "RE: [PHP-DEV] register_shutdown_function() question in regards to bug #8395"
- In reply to: Huajie Liu: "RE: [PHP-DEV] Help on ZVAL (array) memory management"
- Next in thread: Andi Gutmans: "Re: [PHP-DEV] Help on ZVAL (array) memory management"
- Reply: Andi Gutmans: "Re: [PHP-DEV] Help on ZVAL (array) memory management"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Tue, Dec 26, 2000 at 03:49:01PM -0500, Huajie Liu wrote:
> 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?
Yes I think so.
array_init(myzval) will set myzval->value.ht->pDestructor to
ZVAL_PTR_DTOR.
When you later do zval_dtor(myzval), it will do
zend_hash_destroy(myzval->value.ht) which will then do
ZVAL_PTR_DTOR(q->pData) for each element in the hash (q).
Each pData refers to a zval, and it will reduce the refcount of
the zval, and if it becomes 0, it will do zval_dtor on it. So in
your case, the effect should be that it calls zval_dtor(zarray)
unless the refcount >1.
If I'm wrong, someone that knows this better will hopefully correct me.
A debugger should be able to help you a lot, just trace step by step
what happens when you try to free myzval.
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>
- Next message: Zeev Suraski: "Re: [PHP-DEV] Why zend_language_scanner_cc.cc instead of zend_language_scanner.c?"
- Previous message: Chris Newbill: "RE: [PHP-DEV] register_shutdown_function() question in regards to bug #8395"
- In reply to: Huajie Liu: "RE: [PHP-DEV] Help on ZVAL (array) memory management"
- Next in thread: Andi Gutmans: "Re: [PHP-DEV] Help on ZVAL (array) memory management"
- Reply: Andi Gutmans: "Re: [PHP-DEV] Help on ZVAL (array) memory management"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

