Hi,

I'm having a bit of a conundrum that maybe someone here can help me out with
:-).

When assigning an object resource to either 'getThis()' or 'return_value' as
shown below, is it necessary to manually increment the reference count?

For example, /ext/ming/ming.c (version 1.70) contains many code fragments
like the following where zend_list_addref() is used with 'getThis()', and
not used with 'return_value':

<snip ming.c:297>
 ret = zend_list_insert(action, le_swfactionp);

 object_init_ex(getThis(), action_class_entry_ptr);
 add_property_resource(getThis(), "action", ret);
 zend_list_addref(ret);
</snip>

<snip ming.c:1979>
  ret = zend_list_insert(item, le_swfdisplayitemp);
  object_init_ex(return_value, displayitem_class_entry_ptr);
  add_property_resource(return_value, "displayitem", ret);
</snip>

Looking at earlier revisions of this file, it appears that usage of
zend_list_addref() with 'return_value' has been steadily decreasing.  There
is, however, one place where zend_list_addref() with 'return_value' is still
being called:

<snip ming.c:1686>
 int ret = zend_list_insert(shape, le_swfshapep);

 object_init_ex(return_value, shape_class_entry_ptr);
 add_property_resource(return_value, "shape", ret);
 zend_list_addref(ret);
</snip>

I can't find enough examples in other modules to feel confident that
zend_list_addref() with 'return_value' is a bad thing (some use it, some
don't), and my testing seems to show that everything works fine with or
without the explicit zend_list_addref() call for both 'return_value' and
'getThis()'.

That said, is there a "correct" way to handle reference counting with
'getThis()' and 'return_value' in this situation?

Thanks,
Marshall

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

Reply via email to