Add linearSpaceFree() for retrieving the free space in the linear heap
This commit is contained in:
parent
c7be1e415f
commit
a77e8ae1cd
@ -4,3 +4,4 @@
|
|||||||
void* linearAlloc(size_t size);
|
void* linearAlloc(size_t size);
|
||||||
void* linearRealloc(void* mem, size_t size);
|
void* linearRealloc(void* mem, size_t size);
|
||||||
void linearFree(void* mem);
|
void linearFree(void* mem);
|
||||||
|
u32 linearSpaceFree(); // get free linear space in bytes
|
||||||
|
@ -48,3 +48,8 @@ void linearFree(void* mem)
|
|||||||
auto pChunk = (MemChunk*)((u8*)mem - 16);
|
auto pChunk = (MemChunk*)((u8*)mem - 16);
|
||||||
sLinearPool.Deallocate(*pChunk);
|
sLinearPool.Deallocate(*pChunk);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
u32 linearSpaceFree()
|
||||||
|
{
|
||||||
|
return sLinearPool.GetFreeSpace();
|
||||||
|
}
|
||||||
|
@ -123,3 +123,11 @@ void MemPool::Dump(const char* title)
|
|||||||
printf(" - %p (%u bytes)\n", b->base, b->size);
|
printf(" - %p (%u bytes)\n", b->base, b->size);
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
u32 MemPool::GetFreeSpace()
|
||||||
|
{
|
||||||
|
u32 acc = 0;
|
||||||
|
for (auto b = first; b; b = b->next)
|
||||||
|
acc += b->size;
|
||||||
|
return acc;
|
||||||
|
}
|
||||||
|
@ -85,4 +85,5 @@ struct MemPool
|
|||||||
}
|
}
|
||||||
|
|
||||||
//void Dump(const char* title);
|
//void Dump(const char* title);
|
||||||
|
u32 GetFreeSpace();
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user