Re: cvs: php4 /ext/standard array.c /ext/standard/tests/array bug24198.phpt

From: Date: Tue, 17 Jun 2003 14:24:46 +0000
Subject: Re: cvs: php4 /ext/standard array.c /ext/standard/tests/array bug24198.phpt
References: 1 2  Groups: php.cvs 
Request: Send a blank email to php-cvs+get-21830@lists.php.net to get a copy of this message
To allow us to do this: $a = array('a' => 1, 'b' => 2); $b = $a; $c = $a; array_merge_recursive($b, $c); The old check has a problem, because $b & $c are write only copies *src_entry == *dest_entry condition is met and the function incorrectly terminates claiming a circular reference. We cannot use is_ref field to verify references since that field is always 0 no matter what. So, we rely on an interesting property of refcount, which causes refcount to be odd when we have a reference and even we simply have a write only copy. Ilia On June 17, 2003 10:06 am, Andrei Zmievski wrote: > On Mon, 16 Jun 2003, Ilia Alshanetsky wrote: > > + if (*src_entry == *dest_entry && ((*dest_entry)->refcount % 2)) { > > Why this %2 test? > > -Andrei > > For every complex problem, there is a solution > that is simple, neat, and wrong. -- H. L. Mencken

« previous php.cvs (#21830) next »