----- Original Message ----- From: "Marshall A. Greenblatt" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Monday, August 09, 2004 11:38 PM Subject: [PHP-DEV] zend_list_addref and object resources
[snip] > 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] In answer to my own question: No, at least not with PHP4.3.1. <?php /* Create an object with a resource and return via 'getThis()'. */ $foo = new myobj(); print_zval($foo); /* Create an object with a resource and return via 'return_value'. */ $bar = getmyobj(); print_zval($bar); ?> In either case, irregardless of whether zend_list_addref() is explicitly called for the resource ID, output (via print_zval) is as follows: Addr:[9F75D0] is_ref:[0] refcount:[2] Type:[OBJECT] Class:[myobj] Val:[ Name:[value] => Addr:[9F7798] is_ref:[0] refcount:[1] Type:[RESOURCE] Val:[1] ] Addr:[9F7638] is_ref:[0] refcount:[2] Type:[OBJECT] Class:[myobj] Val:[ Name:[value] => Addr:[9F79B8] is_ref:[0] refcount:[1] Type:[RESOURCE] Val:[2] ] If anyone is interested in playing with this, email me and I'll make the source code available online. - Marshall Note: The print_zval function takes any type of variable and displays the value, similar to print_r, but in a more useful debugging format. -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php