From 1071f9c6fd64add72c546314f33cf7f2a395c5bb Mon Sep 17 00:00:00 2001 From: mykola2312 <49044616+mykola2312@users.noreply.github.com> Date: Tue, 24 May 2022 20:22:18 +0300 Subject: [PATCH] implement heap_join for other > block --- heap.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/heap.c b/heap.c index c041f36..d58085b 100644 --- a/heap.c +++ b/heap.c @@ -34,6 +34,16 @@ void heap_split(mblock_t* block, unsigned int size) block->size = size; } +void heap_join(mblock_t* block, mblock_t* other) +{ + if (other > block) + { + mblock_t* next = (mblock_t*)((uint8_t*)other + other->size); + next->prev = block; + block->size += other->size; + } +} + int main() { printf("mblock_t\t%u\n", sizeof(mblock_t));