modified: src/planner.c

modified:   src/planner.h
	modified:   src/test.c
planner
simon 2024-12-12 16:24:19 +01:00
parent 7c16f20bc2
commit 8629bb0420
3 changed files with 26 additions and 4 deletions

View File

@ -43,6 +43,26 @@ void llistPrintE(llist *head) {
c = c->next;
}
}
void freeEvent(Event *e) {
free(e->task);
free(e);
}
void llistFreeE(llist *head) {
while (head != NULL) {
free((Event *)head->data);
llist *tmp = head;
head = head->next;
free(tmp);
}
}
void llistFreeT(llist *head) {
while (head != NULL) {
free(head->data);
llist *tmp = head;
head = head->next;
free(tmp);
}
}
void planLog(char *msg, bool e) {
if (!e)
printf("[Planner][log] %s\n", msg);

View File

@ -41,6 +41,7 @@ char *taskToStr(Task *t);
* prints human readable str of Task to stdout
*/
void printTask(Task *s);
void llistFreeT(llist *head);
/*
* create deepCopy of task
@ -74,6 +75,8 @@ Event *newEvent(Task *t, time_t s, time_t e, uint64_t sp);
/*
* compare function for Event
*/
void freeEvent(Event *e);
void llistFreeE(llist *head);
int cmpEvent(const void *a, const void *b);
/*
* takes llist of tasks and returns llist of events

View File

@ -33,7 +33,8 @@ int main() {
llistAppend(list1, t3);
llistAppend(list1, t4);
genPlan(list1);
llist *l1 = genPlan(list1);
llistFreeE(l1);
// print test tasks
printTask(t1);
@ -53,10 +54,8 @@ int main() {
char *t1Str = taskToStr(t1);
printf("%s\n", t1Str);
llistFreeT(list1);
free(t1Str);
free(t1);
free(t2);
return 0;
}