+ uint8_t *next = (uint8_t *)t;
+ next += sizeof(struct task);
+ next += t->tasklength;
+
+ return next >= spacepointer ? NULL : (struct task *)next;
+}
+
+void task_delete(uint8_t c)
+{
+ debug("Going to delete task: %i", c);
+ debug("spacepointer: %p", spacepointer);
+ 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", spacepointer-end);
+ for(int i = 0; i<spacepointer-end; i++){
+ start[i] = end[i];
+ }
+
+ //Decrement the spacepointer
+ spacepointer -= end-start;
+ }
+ debug("spacepointer: %p", spacepointer);