+ uint8_t *next = (uint8_t *)t + sizeof(struct task) + t->tasklength;
+ return next >= mem_task ? NULL : (struct task *)next;
+}
+
+void task_delete(uint8_t c)
+{
+ debug("Going to delete task: %i", c);
+ debug("mem_task: %p", mem_task);
+ struct task *t = task_head();
+ while(t != NULL){
+ if(t->taskid == c){
+ break;
+ }
+ t = task_next(t);
+ }
+
+ if(t != NULL){
+ //We found the task, now we move everything from the end of the task up
+ //to the spacepointer right
+ uint8_t *start = (uint8_t *)t;
+ uint8_t *end = start + sizeof(struct task) + t->tasklength;
+ debug("Moving %lu bytes\n", mem_task-end);
+ for(int i = 0; i<mem_task-end; i++){
+ start[i] = end[i];
+ }
+
+ //Decrement the spacepointer
+ mem_task -= end-start;
+ }
+ debug("mem_task: %p", mem_task);