implement heap_join for block > other
This commit is contained in:
parent
1071f9c6fd
commit
b1222ef8df
1 changed files with 7 additions and 1 deletions
8
heap.c
8
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()
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue