From: karim hamidou Date: Wed, 8 May 2013 10:47:45 +0000 (+0200) Subject: still chasing this elusive bug X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=945e5cc142f1a6a4f25843c3bf2a11d730247195;p=mojo.git still chasing this elusive bug --- diff --git a/list.c b/list.c index aa0f9fa..8a6de08 100644 --- a/list.c +++ b/list.c @@ -83,14 +83,17 @@ void mojo_list_free(struct mojo_list *list) { free(list); */ - struct mojo_list_elem *e = (struct mojo_list_elem *) TAILQ_FIRST(&list->mojo_list_head); - TAILQ_FOREACH(e, &list->mojo_list_head, mojo_lists) { - TAILQ_REMOVE(&list->mojo_list_head, e, mojo_lists); - //display_object(e->obj, 0); - free_object(e->obj); + struct mojo_list_elem *e; + while (e = (struct mojo_list_elem *) TAILQ_FIRST(&list->mojo_list_head)) { + TAILQ_REMOVE(&list->mojo_list_head, e, mojo_lists); + + if (e->obj != NULL) + free_object(e->obj); + free(e); - } + } + } /* diff --git a/list.h b/list.h index e0fe170..9972d6d 100644 --- a/list.h +++ b/list.h @@ -4,6 +4,7 @@ #include "object.h" #include "queue.h" +/* see http://blog.jasonish.org/2006/08/tailq-example.html for help on bsd tail queues */ struct mojo_list_elem { struct Object *obj; TAILQ_ENTRY(mojo_list_elem) mojo_lists;