diff options
author | Clyne Sullivan <tullivan99@gmail.com> | 2018-02-21 16:43:38 -0500 |
---|---|---|
committer | Clyne Sullivan <tullivan99@gmail.com> | 2018-02-21 16:43:38 -0500 |
commit | eee1be766d35a3ab76b10fc0aeaf1bbe7a88bfbc (patch) | |
tree | 15901f324ca613e960619c6928b700b0052622f4 /src/heap.c | |
parent | 5a6c8f4c22e6581f1b970afd68bf4c2c4db4ebf2 (diff) |
rejoice! tasks suck no more
Diffstat (limited to 'src/heap.c')
-rw-r--r-- | src/heap.c | 8 |
1 files changed, 6 insertions, 2 deletions
@@ -1,4 +1,5 @@ -#include "heap.h" +#include <heap.h> +#include <task.h> #define HEAP_ALIGN 16 @@ -20,6 +21,9 @@ void heap_init(void *buf) void *malloc(uint32_t size) { + task_hold(1); + if (size < 16) + size = 16; alloc_t *node = &root; while (node->next & 1 || node->size < size) { if ((node->next & ~(1)) == 0) { @@ -34,6 +38,7 @@ void *malloc(uint32_t size) } node->next |= 1; + task_hold(0); return (void *)((uint32_t)node + sizeof(alloc_t)); } @@ -53,4 +58,3 @@ void free(void *buf) alloc_t *alloc = (alloc_t *)((uint32_t)buf - sizeof(alloc_t)); alloc->next &= ~(1); } - |