Skip to content

Commit

Permalink
- Try php#2. Wasn't allowed to delete in the previous manner because …
Browse files Browse the repository at this point in the history
…we were

  in the middle of an llist_apply()
  • Loading branch information
Andi Gutmans committed Oct 18, 2000
1 parent ffc6e72 commit 928da71
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 8 deletions.
12 changes: 4 additions & 8 deletions Zend/zend_extensions.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,20 +138,16 @@ static void zend_extension_shutdown(zend_extension *extension)
#endif
}

static int zend_compare_extensions(zend_extension *extension1, zend_extension *extension2)
{
return (extension1->handle == extension2->handle);
}

static void zend_extension_startup(zend_extension *extension)
static int zend_extension_startup(zend_extension *extension)
{
#if ZEND_EXTENSIONS_SUPPORT
if (extension->startup) {
if (extension->startup(extension)!=SUCCESS) {
zend_llist_del_element(&zend_extensions, extension, (int(*)(void *, void *)) zend_compare_extensions);
return 1;
}
}
#endif
return 0;
}


Expand All @@ -166,7 +162,7 @@ int zend_startup_extensions_mechanism()

int zend_startup_extensions()
{
zend_llist_apply(&zend_extensions, (void (*)(void *)) zend_extension_startup);
zend_llist_apply_with_del(&zend_extensions, (int (*)(void *)) zend_extension_startup);
return SUCCESS;
}

Expand Down
18 changes: 18 additions & 0 deletions Zend/zend_llist.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,24 @@ ZEND_API void zend_llist_copy(zend_llist *dst, zend_llist *src)
}


ZEND_API void zend_llist_apply_with_del(zend_llist *l, int (*func)(void *data))
{
zend_llist_element *element, *next;

element=l->head;
while (element) {
next = element->next;
if (func(element->data)) {
if (l->dtor) {
l->dtor(element->data);
pefree(element, l->persistent);
}
}
element = next;
}
}


ZEND_API void zend_llist_apply(zend_llist *l, void (*func)(void *data))
{
zend_llist_element *element;
Expand Down
1 change: 1 addition & 0 deletions Zend/zend_llist.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ ZEND_API void zend_llist_clean(zend_llist *l);
ZEND_API void zend_llist_remove_tail(zend_llist *l);
ZEND_API void zend_llist_copy(zend_llist *dst, zend_llist *src);
ZEND_API void zend_llist_apply(zend_llist *l, llist_apply_func_t);
ZEND_API void zend_llist_apply_with_del(zend_llist *l, int (*func)(void *data));
ZEND_API void zend_llist_apply_with_argument(zend_llist *l, llist_apply_with_arg_func_t, void *arg);
ZEND_API void zend_llist_apply_with_arguments(zend_llist *l, llist_apply_with_args_func_t func, int num_args, ...);
ZEND_API int zend_llist_count(zend_llist *l);
Expand Down

0 comments on commit 928da71

Please sign in to comment.