Re: PHP Extension Memory Problems

php.internals

Bruce Bailey

22 years ago
Wez Thanks for the information. Unfortunately, when I try: // This part of the extension is in a function that may well be called // several thousand times from a PHP script. SEPARATE_ZVAL(&Arr); array_init(Arr); The second time through, the httpd process segfaults and dies. Apparently, I can't just blindly do the separate_zval and array init. I have tried several combinations using the ZVAL_IS_NULL and Z_TYPE_P() == IS_ARRAY beforehand, but I'm just not getting it. Bruce
>From: "Wez Furlong" <wez@thebrainroom.com> >To: "Bruce Bailey" <bruce1828@hotmail.com>, <internals@lists.php.net> >Subject: Re: [PHP-DEV] PHP Extension Memory Problems >Date: Wed, 21 Apr 2004 22:04:19 +0100 > > > > > What can I do in my extension to unset or clear the variable so that it > > doesn’t have to be done in the PHP script? > > > > if (!PZVAL_IS_REF(Arr)) > > { > > zend_error(E_ERROR, "The Arr parameter must be passed by reference"); > ^^^^^^^ >Don't use E_ERROR in an extension unless it would be dangerous for >execution to continue (eg: crash iminent); use E_WARNING instead. > > > RETURN_NULL(); > > } > >SEPARATE_ZVAL(Arr); > > > array_init(Arr); > > > > if (add_assoc_string(Arr, (char *) szFieldName, (char *) szValue, 1) == > > FAILURE) { > > . . . > > } > >Hope that helps, > >--Wez. >
_________________________________________________________________ Is your PC infected? Get a FREE online computer virus scan from McAfee® Security. http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963