Re: FREE_ZVAL and/or zval_dtor()
| From: | Andrey Hristov | Date: | Tue, 12 Mar 2002 13:01:17 +0000 |
| Subject: | Re: FREE_ZVAL and/or zval_dtor() | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-81076@lists.php.net to get a copy of this message | ||
As far as I see FREE_ZVAL is ZEND_FAST_FREE and the latter is not freeing memory just removes the
zval from a list. So it is
required to release the memory before that. Fix me if I'm wrong.
Regards,
Andrey
----- Original Message -----
From: "Klaus Reimer" <k@ailis.de>
To: <php-dev@lists.php.net>
Sent: Tuesday, March 12, 2002 2:42 PM
Subject: [PHP-DEV] FREE_ZVAL and/or zval_dtor()
> 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)
>
> --
> PHP Development Mailing List <http://www.php.net/>
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>