On Fri, 02 Jan 2004, Jon Parise wrote:
> It looks like this code from zend_execute.c is responsible for the
> added reference:
> 
>     if (PZVAL_IS_REF(value) && value->refcount > 0) {
>         ALLOC_ZVAL(variable_ptr);
>         *variable_ptr_ptr = variable_ptr;
>         *variable_ptr = *value;
>         zval_copy_ctor(variable_ptr);
>         variable_ptr->refcount=1;
>         break;
>     }
> 
> In my case, 'value' is a reference (PZVAL_IS_REF(value) == 1), and in
> the case of the native PHP object, it isn't.  zval_copy_ctor() calls
> zend_objects_store_add_ref(), which increments the store object's
> reference count.
> 
> Two questions:
> 
> Why is my object being treated as a reference while the native PHP
> object is not?

I guess that is a question for you really: are you doing anything
special to make your object a reference? I've used the new object model
for PHP-GTK and my objects were not treated as references.


> 'variable_ptr->refcount=1;' resets the reference count of the
> variable's zval to 1, but the underlying _store_object's reference
> count is still incremented.  What will ever reclaim that reference on
> the _store_object?

zval_dtor() will. It calls del_ref on the underlying object.

- Andrei

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to