Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:12140 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 81056 invoked by uid 1010); 12 Aug 2004 21:03:30 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 80979 invoked from network); 12 Aug 2004 21:03:29 -0000 Received: from unknown (HELO venus.tictek.net) (209.226.39.19) by pb1.pair.com with SMTP; 12 Aug 2004 21:03:29 -0000 Received: from Marshall (ppp-68-250-174-198.dsl.sfldmi.ameritech.net [68.250.174.198]) by venus.tictek.net (Postfix) with ESMTP id 0B5B1320023 for ; Thu, 12 Aug 2004 17:03:06 -0400 (EDT) Message-ID: <002001c480af$d399a330$3201a8c0@Marshall> To: References: <002101c47e8b$8ea4dea0$3201a8c0@Marshall> Date: Thu, 12 Aug 2004 17:03:32 -0400 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1437 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 X-Antivirus: avast! (VPS 0433-2, 08/10/2004), Outbound message X-Antivirus-Status: Not-Tested Subject: Re: [PHP-DEV] zend_list_addref and object resources From: marshall@magpcss.com ("Marshall A. Greenblatt") ----- Original Message ----- From: "Marshall A. Greenblatt" To: 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': > > > 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] In answer to my own question: No, at least not with PHP4.3.1. 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.