implement heap_join for block > other

This commit is contained in:
mykola2312 2022-05-24 20:24:58 +03:00
parent 1071f9c6fd
commit b1222ef8df

8
heap.c
View file

@ -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()