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

From: Date: Sat, 02 Oct 1999 02:00:47 +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-5077@lists.php.net to get a copy of this message
On Fri, 1 Oct 1999, Thies C. Arntzen wrote: > 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. Ok, some severe lack of sleep and it all comes back to me... Yes, there's an inherent problem in touching ANY hash data structures from a destructor of an element in that hash. The reason is simple - on hash destruction, the hash performs a one-pass destruction&deallocation, and its data structures are 'dirty' and unreliable at that time. I'll take your word for it if you say it's fairly required (e.g. in dir.c) - I'm way too tired to check it myself. I'm vaguely thinking about an alternative way to do this that would also be high-performance, I see if I can come up with anything in the morning. > 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... I guess #define zend_list_delref zend_list_delete in zend_list.h should do the trick - it seems reasonable. Zeev -- ----------------------------------------------------- Zeev Suraski <zeev@zend.com> http://www.zend.com/ For a PGP public key, finger bourbon@netvision.net.il

« previous php.version4 (#5077) next »