Re: [PHP4BETA] zend_list_addref() / zend_list_delete() question. (fwd)

From: Date: Fri, 01 Oct 1999 18:33:05 +0000
Subject: Re: [PHP4BETA] zend_list_addref() / zend_list_delete() question. (fwd)
References: 1  Groups: php.version4 
Request: Send a blank email to php-version4+get-5073@lists.php.net to get a copy of this message
On Fri, 1 Oct 1999, Zeev Suraski wrote: > On Fri, 1 Oct 1999, Thies C. Arntzen wrote: > > > here you go - > > > > > > ---------- Forwarded message ---------- > > Date: Thu, 30 Sep 1999 11:06:58 +0200 (CEST) > > From: Thies C. Arntzen <thies@digicol.de> > > To: Zeev Suraski <zeev@php.net>, Andi Gutmans <andi@zend.com> > > Cc: php4beta@lists.php.net > > Subject: [PHP4BETA] zend_list_addref() / zend_list_delete() question. > > > > hi, > > > > been playing with the refcount stuff - works GREAT! > > > > question: > > > > can i call zend_list_delete() from a destructor function? - it would be > > great if we could implement resource-dependicies that way! > > From glancing at the code, I think you can. Remember you can't rely on > order of destruction though - if resource #2 depends on resource #1, on > shutdown time, resource #1 may be deleted before resource #2, and by the > time resource #2 is destroyed, it'll be relying on invalid data (of > course, if you can link resource #2 to #1 and delete #2 when #1 is > destroyed, things would work fine). you might remember a few month ago (glory old PHP3 days) you told me that one must *not* call hash_apply (on "list") inside a destructor function for "list". (search for _php3_hash_apply in php3/functions/sybase.c - there's still a bug!). - to reduce my fuzz / let code speak - int _my_dtor(mytype *data) { zend_list_delete(data->parentid); } ... le_stmt = register_list_destructors(_my_dtor, NULL); ... i think we need to be able to support this - try to convert the dir.c to use resources and you'll see what i mean. > > > sample shows how we can make sure that the db-connection gets closed > > *AFTER* all cursors! > > > > BTW: i think it would be nice to have a zend_list_delref(id) > > function/macro. > > zend_list_delete() reduces reference count and deletes the resource is the > refcount reaches zero. Isn't that what you would want > zend_list_delref() to do? yeps - but i tink it would be nice to have functions in pairs (*_addref(), *_delref()) - but it would in fact be zend_list_delete(). for somebody looking at the c-code zend_list_delete() would look far more evil that seeing zend_list_addref() paired with zend_list_delref(). so it's just a question of taste. btw: zend_list_delete no longer really deletes... regards, tc > > Zeev > > -- > ----------------------------------------------------- > Zeev Suraski <zeev@zend.com> http://www.zend.com/ > For a PGP public key, finger bourbon@netvision.net.il > > > Thies C. Arntzen "One Big-Mac, Small Fries and a Coke!" Digital Collections Phone +49 40 235350 Fax +49 40 23535180 Hammerbrookstr. 93 20097 Hamburg / Germany

« previous php.version4 (#5073) next »