implement heap_join for other > block
This commit is contained in:
parent
4947abc31c
commit
1071f9c6fd
1 changed files with 10 additions and 0 deletions
10
heap.c
10
heap.c
|
|
@ -34,6 +34,16 @@ void heap_split(mblock_t* block, unsigned int size)
|
||||||
block->size = 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()
|
int main()
|
||||||
{
|
{
|
||||||
printf("mblock_t\t%u\n", sizeof(mblock_t));
|
printf("mblock_t\t%u\n", sizeof(mblock_t));
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue