From 945e5cc142f1a6a4f25843c3bf2a11d730247195 Mon Sep 17 00:00:00 2001 From: karim hamidou Date: Wed, 8 May 2013 12:47:45 +0200 Subject: [PATCH] still chasing this elusive bug --- list.c | 15 +++++++++------ list.h | 1 + 2 files changed, 10 insertions(+), 6 deletions(-) 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; -- 2.43.0