diff --git a/heap.c b/heap.c index d58085b..731ae4a 100644 --- a/heap.c +++ b/heap.c @@ -36,12 +36,18 @@ void heap_split(mblock_t* block, unsigned int size) void heap_join(mblock_t* block, mblock_t* other) { - if (other > block) + if (block < other) { mblock_t* next = (mblock_t*)((uint8_t*)other + other->size); next->prev = block; block->size += other->size; } + else if (block > other) + { + mblock_t* next = (mblock_t*)((uint8_t*)block + block->size); + next->prev = other; + other->size += block->size; + } } int main()