From 5fcf57739e68a8b5053e03778aaee0eed445babd Mon Sep 17 00:00:00 2001 From: Benji Dial Date: Thu, 11 Mar 2021 22:00:22 -0500 Subject: settings editor, and lots of changes in service of that --- src/user/knob/heap.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/user/knob/heap.c') 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; -- cgit v1.2.3