Re: [PHP4BETA] major problem with allocating zval in modules

From: Date: Fri, 02 Jul 1999 16:20:45 +0000
Subject: Re: [PHP4BETA] major problem with allocating zval in modules
References: 1  Groups: php.version4 
Request: Send a blank email to php-version4+get-1835@lists.php.net to get a copy of this message
Well, this shouldn't affect you if you use API functions. If the array in question is the return value of the function, you need not take care of its reference counting. If it's a member in a different array (do we have any functions that return multidimensional arrays?), then you should be using API functions to register it in the array. Unfortunately, it seems we don't have API functions to register arrays within other arrays (only scalar types), but in any case, this should be the solution. Zeev On Fri, 2 Jul 1999, Thies C. Arntzen wrote: > hi, > > the following code is wrong (was correct in php3) > > zval *hallo = emalloc(sizeof(zval)); > array_init(hallo); > > as emalloc does NOT initialize is_ref and refcount in the zval structure. > > we should have some more api-functions that take care of this cause adding > > bla->is_ref = 0; > bla->refcount = 1; > > in every module that creates zvals is painful! and i'm sure we'll forget > some. > > this should be sorted before b1 in my opinion! > > btw: my last commit fixed all mem-leaks from my testcase (and there was a > LOT!). > > > tc > > > Thies C. Arntzen "One Big-Mac, Small Fries and a Coke!" > Digital Collections Phone +49 40 235350 Fax +49 40 23535180 > Hammerbrookstr. 93 20097 Hamburg / Germany > > > -- > PHP 4 Beta > -- ----------------------------------------------------- Zeev Suraski <zeev@zend.com> For a PGP public key, finger bourbon@netvision.net.il

« previous php.version4 (#1835) next »