the list has been busy as of late, so i suppose this got lost in the
shuffle. anyways, here goes again :

im creating an extension which exposes classes which may act as containers
to other classes. These contained classes also get exposed via the
extension. Now when the container class gets destructed by the user
 $container->close(), called before RSHUTDOWN ), i need to ensure that all
resources allocated by the contained objects are released, otherwise
nastiness can occur is the user tries to access the contained objects later
in the script.

 to that end, ive written something like the following. i just wanted to
know if it will cause any problems, since it accesses EG(regular_list) from
a resource destructor. BTW the list destructor is
destroy_container_resource .

static int _kill_contained_objects(zend_rsrc_list *le,void *argument)
    container_t *cont = (container_t *)argument;
    if (le->type == le_contained_object) {
        contained_t *field = (contained_t *)le->ptr;
        return (field->container == cont);
    return 0;

static void kill_kids(apply_func_arg_t func, void *parent)
    zend_hash_apply_with_argument(  &EG(regular_list), func, parent );

static void destroy_container_resource(zend_rsrc_list_entry *rsrc) {
    container_t *cont = (container_t *)rsrc->ptr;
    kill_kids( (apply_func_t) _kill_contained_objects, cont );

"Fried Ice-Cream is a reality !" - George Clinton

PHP Development Mailing List <>
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to