Re: Input paramters...
| From: | Zeev Suraski | Date: | Wed, 22 Nov 2000 21:13:06 +0000 |
| Subject: | Re: Input paramters... | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-38946@lists.php.net to get a copy of this message | ||
At 22:32 22/11/2000, David Muse wrote:
I've got a question about input parameters: After calling zend_get_parameters, are the zval's that it returns appear to be deallocated automatically when the function terminates. Is this proper behavior?Yes. It's one of the main reasons that built-in functions are relatively leak safe.
The issue is as follows: Say I have a PHP function that accepts a string, calls zend_get_parameters and passes the value.str.val member to a C function that accepts a char*. If that C function passes the char* to a C++ function that sets a private member variable (also of type char*) equal to it, future references to that private member variable return the wrong value. In fact, they frequently return PHP function names. I assume that what's happening is that the zval is getting deallocated and another variable is getting allocated and used at the same address. I guess I could get around the whole mess by estrdup'ing string parameters that this behavior apply's to, but should I really have to do that?Yes. It's also very efficient, even though I realize it may not seem like that from your point of view (I'm way too tired to explain why it's efficient). Zeev -- Zeev Suraski <zeev@zend.com> CTO, Zend Technologies Ltd. http://www.zend.com/