(no commit message)
authorJean-Philippe Orsini <jeanfi@gmail.com>
Wed, 17 Oct 2012 11:04:35 +0000 (11:04 +0000)
committerJean-Philippe Orsini <jeanfi@gmail.com>
Wed, 17 Oct 2012 11:04:35 +0000 (11:04 +0000)
src/main.c
src/tw.c
src/tw.h

index c439fcf..8dcd89f 100644 (file)
@@ -113,6 +113,9 @@ static void refresh()
        status = gtk_combo_box_get_active(w_status);
        printf("status: %d\n", status);
 
+       if (tasks)
+               tw_task_list_free(tasks);
+
        switch (status) {
        case 0:
                tasks = tw_get_all_tasks("pending");
index c92c1ee..ac8f82d 100644 (file)
--- a/src/tw.c
+++ b/src/tw.c
@@ -279,3 +279,31 @@ void tw_done(const char *uuid)
 
        free(opts);
 }
+
+static void task_free(struct task *task)
+{
+       if (!task)
+               return ;
+
+       free(task->description);
+       free(task->status);
+       free(task->uuid);
+       free(task->note);
+       free(task->project);
+       free(task->priority);
+
+       free(task);
+}
+
+void tw_task_list_free(struct task **tasks)
+{
+       struct task **cur;
+
+       if (!tasks)
+               return ;
+
+       for (cur = tasks; *cur; cur++)
+               task_free(*cur);
+
+       free(tasks);
+}
index c95d009..6e5f397 100644 (file)
--- a/src/tw.h
+++ b/src/tw.h
@@ -36,6 +36,7 @@ void tw_modify_project(const char *uuid, const char *newproj);
 void tw_modify_priority(const char *uuid, const char *priority);
 void tw_done(const char *uuid);
 void tw_add(const char *newdesc);
+void tw_task_list_free(struct task **tasks);
 
 char *task_exec(char *opts);
 char *escape(const char *txt);