diff options
| author | Aleksa Vuckovic <aleksav013@gmail.com> | 2022-12-04 20:12:57 +0100 |
|---|---|---|
| committer | Aleksa Vuckovic <aleksav013@gmail.com> | 2022-12-04 20:12:57 +0100 |
| commit | 57fc2b58f362a361188856ed73dbb7391df66938 (patch) | |
| tree | 61d580e0bcb71e04754bc5d0f592339397ff20c3 /kernel/src/mem/heap.c | |
| parent | a36b01e05f09f642f261d42666af28a367fefc4e (diff) | |
kheap_free bug fixed
Diffstat (limited to 'kernel/src/mem/heap.c')
| -rw-r--r-- | kernel/src/mem/heap.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/kernel/src/mem/heap.c b/kernel/src/mem/heap.c index 539328c..b49eefb 100644 --- a/kernel/src/mem/heap.c +++ b/kernel/src/mem/heap.c @@ -100,11 +100,11 @@ void kheap_free(kheap_t* kheap, void* pointer) { kheapblock_t* kheapblock; for (kheapblock = kheap->fblock; kheapblock; kheapblock = kheapblock->next) { - if ((uintptr_t)(pointer) > (uintptr_t)kheapblock && (uintptr_t)kheapblock + sizeof(kheapblock_t) + kheapblock->size) { + if ((uintptr_t)(pointer) > (uintptr_t)kheapblock && (uintptr_t)(pointer) < (uintptr_t)kheapblock + sizeof(kheapblock_t) + kheapblock->size) { // found block // get index of bitmap entry - uintptr_t pointer_offset = (uintptr_t)pointer - (uintptr_t)&kheapblock[1]; + uintptr_t pointer_offset = (uintptr_t)pointer - (uintptr_t)&kheapblock[0]; uint32_t bi = (uint32_t)pointer_offset / kheapblock->bsize; uint8_t* bm = (uint8_t*)&kheapblock[1]; uint8_t id = bm[bi]; |
