FREE_ZVAL and/or zval_dtor()
| From: | Klaus Reimer | Date: | Tue, 12 Mar 2002 12:42:01 +0000 |
| Subject: | FREE_ZVAL and/or zval_dtor() | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-81075@lists.php.net to get a copy of this message | ||
Hi,
I'm not sure if I have understood how to free the memory allocatedof a zval
correctly. Because I don't want to create memory leaks, please tell me if I
am right or tell me how it is done correctly:
If I create a zval with MAKE_STD_ZVAL, I just need to call FREE_ZVAL, because
there is no value associated with that zval up to now. But if I store a
string or an object or something like that in this zval I also need to use
zval_dtor() before I destroy the zval itself with FREE_ZVAL, right? Example:
zval *foo;
MAKE_STD_ZVAL(foo); /* Allocate zval */
ZVAL_STRING(foo,'"Some text",1); /* Store a string in zval */
/* Do something */
zval_dtor(foo); /* Free the string */
FREE_ZVAL(foo); /* Free the zval */
Is that correct?
Another question: How do I free the return_value from a
call_user_function_ex() call? The Zend-API-Documentation says, I have to use
zval_dtor, but is this enough? This just frees the memory allocated by the
zval-value, or not? What about the zval itself?
--
Bye, K <http://www.ailis.de/~k/>
[A735 47EC D87B 1F15 C1E9 53D3 AA03 6173 A723 E391]
(Finger k@ailis.de to get public key)