diff --git a/src/planner.c b/src/planner.c index a069141..fb00f5a 100644 --- a/src/planner.c +++ b/src/planner.c @@ -52,6 +52,22 @@ Task *newTask(char *n, time_t c, time_t d, int p, uint64_t sp) { return r; } +/* + * create deepCopy of task + * !! r->name is malloced + */ +Task *copyTask(Task *t) { + Task *r = malloc(sizeof(Task)); + if (r != NULL) { + r->name = strdup(t->name); + r->created = t->created; + r->deadline = t->deadline; + r->priority = t->priority; + r->spare = t->spare; + } + return r; +} + void printTask(Task *s) { printf(taskFormat, s->name, s->created, s->deadline, s->priority, s->spare); } diff --git a/src/planner.h b/src/planner.h index 2f94461..2d232c7 100644 --- a/src/planner.h +++ b/src/planner.h @@ -41,6 +41,12 @@ char *taskToStr(Task *t); */ void printTask(Task *s); +/* + * create deepCopy of task + * !! r->name is malloced + */ +Task *copyTask(Task *t); + /* * Event struct contains task and planned time frame *