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


-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to