Re: Input paramters...
| From: | Zeev Suraski | Date: | Thu, 23 Nov 2000 22:09:49 +0000 |
| Subject: | Re: Input paramters... | ||
| References: | 1 2 3 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-39038@lists.php.net to get a copy of this message | ||
At 00:02 24/11/2000, David Muse wrote:
Having thought about it more, I don't think that estrdup'ing it will solve the problem. When the function exits, there would be no references (that PHP is aware of) to the new variable, just like there aren't any (that PHP is aware of) to the parameter. I could be wrong about this though, I'm pretty new to PHP.The rules are pretty simple: 1. You can't 'take ownership' over data that you receive as arguments to your PHP functions. You must duplicate the data first, because PHP is responsible for freeing those. 2. If you duplicate the data, you become responsible for freeing it, unless you return this data as a part of the return_value. PHP takes ownership over the contents of return_value, and anything that may be nested under it (e.g., if return_value contains an array, PHP becomes responsible for freeing this entire array, including all of its elements, when it is time for it to be destructed). That's all. Zeev -- Zeev Suraski <zeev@zend.com> CTO, Zend Technologies Ltd. http://www.zend.com/