Skip to content

Commit c402343

Browse files
authored
Free task memory after completion (#23)
Previously, tasks were allocated using malloc but never freed, causing memory leaks. Added deallocation after task completion in task0 and task1 prevent memory leaks.
1 parent 0d5c7a4 commit c402343

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

coro/coro.c

+2
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ void task0(void *arg)
104104
}
105105

106106
printf("%s: complete\n", task->task_name);
107+
free(task);
107108
longjmp(sched, 1);
108109
}
109110

@@ -135,6 +136,7 @@ void task1(void *arg)
135136
}
136137

137138
printf("%s: complete\n", task->task_name);
139+
free(task);
138140
longjmp(sched, 1);
139141
}
140142

0 commit comments

Comments
 (0)