From c45a7d924b10d9cc69a48896f7a6c99ecbf56493 Mon Sep 17 00:00:00 2001 From: Aleksa Vučković Date: Mon, 30 May 2022 00:10:05 +0200 Subject: \small u \smallsize --- include/08.heap/heap.c | 1 + include/08.heap/heap23.c | 10 ---------- include/08.heap/heap24.c | 13 ++++++++++--- include/08.heap/heap25.c | 4 +++- include/08.heap/heap26.c | 5 +---- include/08.heap/heap27.c | 4 ++-- include/08.heap/heap28.c | 4 ++-- include/08.heap/heap29.c | 4 ++-- include/08.heap/heap30.c | 4 ++++ 9 files changed, 25 insertions(+), 24 deletions(-) create mode 100644 include/08.heap/heap30.c (limited to 'include/08.heap') diff --git a/include/08.heap/heap.c b/include/08.heap/heap.c index 3120ed8..954a220 100644 --- a/include/08.heap/heap.c +++ b/include/08.heap/heap.c @@ -129,6 +129,7 @@ void k_heapBMFree(KHEAPBM *heap, void *ptr) bi = ptroff / b->bsize; /* .. */ bm = (uint8_t*)&b[1]; + /* clear allocation */ id = bm[bi]; /* oddly.. GCC did not optimize this */ diff --git a/include/08.heap/heap23.c b/include/08.heap/heap23.c index 70305b7..4eaf953 100644 --- a/include/08.heap/heap23.c +++ b/include/08.heap/heap23.c @@ -9,13 +9,3 @@ bi = ptroff / b->bsize; /* .. */ bm = (uint8_t*)&b[1]; - /* clear allocation */ - id = bm[bi]; - /* oddly.. GCC did not optimize this */ - max = b->size / b->bsize; - for (x = bi; bm[x] == id && x < max; ++x) bm[x] = 0; - /* update free block count */ - b->used -= x - bi; - return; - } - } diff --git a/include/08.heap/heap24.c b/include/08.heap/heap24.c index 11a4697..221bc4f 100644 --- a/include/08.heap/heap24.c +++ b/include/08.heap/heap24.c @@ -1,3 +1,10 @@ - /* this error needs to be raised or reported somehow */ - return; -} + /* clear allocation */ + id = bm[bi]; + /* oddly.. GCC did not optimize this */ + max = b->size / b->bsize; + for (x = bi; bm[x] == id && x < max; ++x) bm[x] = 0; + /* update free block count */ + b->used -= x - bi; + return; + } + } diff --git a/include/08.heap/heap25.c b/include/08.heap/heap25.c index 6ac75a9..11a4697 100644 --- a/include/08.heap/heap25.c +++ b/include/08.heap/heap25.c @@ -1 +1,3 @@ -KHEAPBM kheap; + /* this error needs to be raised or reported somehow */ + return; +} diff --git a/include/08.heap/heap26.c b/include/08.heap/heap26.c index 6d7223d..6ac75a9 100644 --- a/include/08.heap/heap26.c +++ b/include/08.heap/heap26.c @@ -1,4 +1 @@ -void kheapinit() -{ - k_heapBMInit(&kheap); -} +KHEAPBM kheap; diff --git a/include/08.heap/heap27.c b/include/08.heap/heap27.c index de767a2..6d7223d 100644 --- a/include/08.heap/heap27.c +++ b/include/08.heap/heap27.c @@ -1,4 +1,4 @@ -int kheapaddblock(uintptr_t addr,uint32_t size,uint32_t bsize) +void kheapinit() { - return k_heapBMAddBlock(&kheap,addr,size,bsize); + k_heapBMInit(&kheap); } diff --git a/include/08.heap/heap28.c b/include/08.heap/heap28.c index 22972f4..de767a2 100644 --- a/include/08.heap/heap28.c +++ b/include/08.heap/heap28.c @@ -1,4 +1,4 @@ -void *kmalloc(uint32_t size) +int kheapaddblock(uintptr_t addr,uint32_t size,uint32_t bsize) { - return k_heapBMAlloc(&kheap,size); + return k_heapBMAddBlock(&kheap,addr,size,bsize); } diff --git a/include/08.heap/heap29.c b/include/08.heap/heap29.c index d4d5941..22972f4 100644 --- a/include/08.heap/heap29.c +++ b/include/08.heap/heap29.c @@ -1,4 +1,4 @@ -void kfree(void *ptr) +void *kmalloc(uint32_t size) { - k_heapBMFree(&kheap,ptr); + return k_heapBMAlloc(&kheap,size); } diff --git a/include/08.heap/heap30.c b/include/08.heap/heap30.c new file mode 100644 index 0000000..d4d5941 --- /dev/null +++ b/include/08.heap/heap30.c @@ -0,0 +1,4 @@ +void kfree(void *ptr) +{ + k_heapBMFree(&kheap,ptr); +} -- cgit v1.2.3