From: Jean-Philippe Orsini Date: Wed, 17 Oct 2012 11:04:35 +0000 (+0000) Subject: (no commit message) X-Git-Tag: v0.0.6~139 X-Git-Url: https://git.wpitchoune.net/gitweb/?p=ptask.git;a=commitdiff_plain;h=9f792471ae3b97b304470e97c0a43983b9517f83 --- diff --git a/src/main.c b/src/main.c index c439fcf..8dcd89f 100644 --- a/src/main.c +++ b/src/main.c @@ -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"); diff --git a/src/tw.c b/src/tw.c index c92c1ee..ac8f82d 100644 --- 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); +} diff --git a/src/tw.h b/src/tw.h index c95d009..6e5f397 100644 --- 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);