]> khamidou — GitHub mirrors - mojo.git/commitdiff
still chasing this elusive bug
authorkarim hamidou <khamidou@gmail.com>
Wed, 8 May 2013 10:47:45 +0000 (12:47 +0200)
committerkarim hamidou <khamidou@gmail.com>
Wed, 8 May 2013 10:47:45 +0000 (12:47 +0200)
list.c
list.h

diff --git a/list.c b/list.c
index aa0f9fab2bd7bd8e9c278c8ab42417c0ab444747..8a6de08e8fa75c6ae229fe32747c745ab3d5f248 100644 (file)
--- 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 e0fe170e7d9e77390c9de57110f0db9ee486687b..9972d6d44f454d824c02a3efea587f65b483ec90 100644 (file)
--- 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;