1996-12-05
1996-12-05 21:37:57 by Fredrik Hübinette (Hubbe) <hubbe@hubbe.net>
-
bf4577ef71e27ab59d8b8a5a6f811180db9450c3
(38 lines)
(+32/-6)
[
Show
| Annotate
]
Branch: 7.9
garbage collection fixed
Rev: src/ChangeLog:1.34
Rev: src/callback.c:1.5
Rev: src/gc.c:1.6
36: Inside #if defined(DEBUG)
#ifdef DEBUG
extern int d_flag;
+ static int is_in_free_list(struct callback * c)
+ {
+ struct callback *foo;
+ int e;
+ for(foo=free_callbacks;foo;foo=foo->next)
+ if(foo==c)
+ return 1;
+
+ return 0;
+ }
+
static void check_callback_chain(struct callback_list *lst)
{
int e,len=0;
67: Inside #if defined(DEBUG)
if(tmp->callbacks[e].free_func == (callback_func)remove_callback)
{
- for(foo=free_callbacks;foo;foo=foo->next)
- if(foo==tmp->callbacks+e)
- break;
-
- if(!foo)
+ if(!is_in_free_list(tmp->callbacks+e))
fatal("Lost track of a struct callback!\n");
-
+
+ if(tmp->callbacks[e].next &&
+ !is_in_free_list(tmp->callbacks[e].next))
+ fatal("Free callback has next in Z'ha'dum!\n");
+
+ }else{
+ if(is_in_free_list(tmp->callbacks[e].next))
+ fatal("Non-free callback has next in free list!\n");
}
if(tmp->callbacks[e].next)
151:
if(l->free_func)
l->free_func(l, l->arg, 0);
+ while(*ptr != l)
+ {
+ ptr=&(ptr[0]->next);
+ if(!*ptr)
+ {
+ /* We totally failed to find where we are in the linked list.. */
+ fatal("Callback linked list breakdown.\n");
+ }
+ }
+
*ptr=l->next;
l->next=free_callbacks;
free_callbacks=l;