diff options
Diffstat (limited to 'src/user/knob/heap.c')
-rw-r--r-- | src/user/knob/heap.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/user/knob/heap.c b/src/user/knob/heap.c index b770542..6e57000 100644 --- a/src/user/knob/heap.c +++ b/src/user/knob/heap.c @@ -25,8 +25,18 @@ static void add_header(struct block_header *bh) { first_block = bh; } +//static const char *const hextab = "0123456789abcdef"; +//static char *const get_debug = "getting 0x........ byte block"; +//static char *const free_debug = "freeing 0x........ byte block"; + __attribute__ ((malloc)) void *get_block(uint32_t bytes) { + if (!bytes) + return 0; +//for (uint8_t i = 0; i < 8; ++i) +// get_debug[10 + 7 - i] = hextab[(bytes >> (i * 4)) & 0xf]; +//_system_log(get_debug); + struct block_header *header = 0; for (struct block_header *ptr = first_block; ptr; ptr = ptr->next) { if (ptr->allocated) @@ -88,6 +98,10 @@ static void remove_header(struct block_header *bh) { void free_block(void *block) { struct block_header *header = block - sizeof(struct block_header); +//for (uint8_t i = 0; i < 8; ++i) +// free_debug[10 + 7 - i] = hextab[(header->length >> (i * 4)) & 0xf]; +//_system_log(free_debug); + header->allocated = false; void *after = block + header->length; |