Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:6752 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 98431 invoked by uid 1010); 3 Jan 2004 00:28:48 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 98345 invoked from network); 3 Jan 2004 00:28:48 -0000 Received: from unknown (HELO blacksheep.csh.rit.edu) (129.21.60.6) by pb1.pair.com with SMTP; 3 Jan 2004 00:28:48 -0000 Received: from fury.csh.rit.edu (fury.csh.rit.edu [IPv6:2001:470:1f00:135:a00:20ff:fe8d:5399]) by blacksheep.csh.rit.edu (Postfix) with ESMTP id 6A84525B for ; Fri, 2 Jan 2004 19:28:43 -0500 (EST) Received: by fury.csh.rit.edu (Postfix, from userid 37404) id 0A2D1137F; Fri, 2 Jan 2004 19:28:42 -0500 (EST) Date: Fri, 2 Jan 2004 19:28:42 -0500 To: internals@lists.php.net Message-ID: <20040103002841.GB23760@csh.rit.edu> Mail-Followup-To: internals@lists.php.net References: <20040103000120.GA23760@csh.rit.edu> <20040103000921.GA3712@gravitonic.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20040103000921.GA3712@gravitonic.com> Subject: Re: [PHP-DEV] Custom object creation and reference counts From: jon@php.net (Jon Parise) On Fri, Jan 02, 2004 at 04:09:21PM -0800, Andrei Zmievski wrote: > > 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. It appears to be a side-effect of not defining the 'scope' field in the zend_internal_function call that is invokved from my custom 'constructor_get' handler. If the 'scope' field is NULL, my object is treated as a reference. If I assign my class entry to the 'scope' field, the object is "normal" (i.e. not a reference). > > '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. I see. I would have to call zval_dtor() myself in any of the cases where I knowingly created an additional reference. That makes sense. -- Jon Parise (jon@php.net) :: The PHP Project (http://www.php.net/)