diff options
author | Benji Dial <benji6283@gmail.com> | 2021-03-11 22:00:22 -0500 |
---|---|---|
committer | Benji Dial <benji6283@gmail.com> | 2021-03-11 22:00:22 -0500 |
commit | 5fcf57739e68a8b5053e03778aaee0eed445babd (patch) | |
tree | e7a8bab18668d112e58b1b48190195035c71fa8a /src/user/knob/heap.c | |
parent | 0f2398d1f622cce37925f52d978d92e6cce1c7a9 (diff) | |
download | portland-os-5fcf57739e68a8b5053e03778aaee0eed445babd.tar.gz |
settings editor, and lots of changes in service of that
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; |