Re: when to duplicate string using add_index_string?

From: Date: Thu, 08 Feb 2001 14:29:33 +0000
Subject: Re: when to duplicate string using add_index_string?
References: 1 2  Groups: php.dev 
Request: Send a blank email to php-dev+get-46024@lists.php.net to get a copy of this message
On Thu, Feb 08, 2001 at 03:45:33PM +0200, Zeev Suraski wrote: > > >First of all, it definitely matters. Sending the right value is extremely > > >important. If you send 1 instead of 0, then you would get a memory > > >leak. If you send a 0 instead of 1, you'll most likely crash. So you > > >really must send the right values each time :) > > > [...] > > > >So what you're saying is > >- if duplicate is set to 0, you create a reference > >- if duplicate is set to 1, you increase the reference counter > >so that 'duplicate' means 'I am a duplicate', instead of what I first > >thought 'duplicate me' (which is why I sent a 1 first (duplicate me), and a > >0 second). > > No, it's not clear I guess :) > > 'duplicate' does mean 'duplicate me'. > If duplicate is set to 0, then you tell the engine not to duplicate the > string, but use it as-is. If it's set to 1, then you tell the engine to > duplicate it, because this string is either static, or already referenced > by other things in PHP. Perhaps 0 and 1 should be replaced by more verbose #define's (constants) to make this code clearer, then. -- Jon Parise (jon@csh.rit.edu) . Rochester Inst. of Technology http://www.csh.rit.edu/~jon/ : Computer Science House Member

« previous php.dev (#46024) next »