mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 00:57:36 +00:00
LibC: Add two little assertions in malloc() and malloc_size()
This commit is contained in:
parent
ae10c9d8ec
commit
79b45f96ee
1 changed files with 3 additions and 0 deletions
|
@ -310,6 +310,7 @@ static void* malloc_impl(size_t size)
|
||||||
|
|
||||||
--block->m_free_chunks;
|
--block->m_free_chunks;
|
||||||
void* ptr = block->m_freelist;
|
void* ptr = block->m_freelist;
|
||||||
|
ASSERT(ptr);
|
||||||
block->m_freelist = block->m_freelist->next;
|
block->m_freelist = block->m_freelist->next;
|
||||||
if (block->is_full()) {
|
if (block->is_full()) {
|
||||||
g_malloc_stats.number_of_blocks_full++;
|
g_malloc_stats.number_of_blocks_full++;
|
||||||
|
@ -455,6 +456,8 @@ size_t malloc_size(void* ptr)
|
||||||
auto size = header->m_size;
|
auto size = header->m_size;
|
||||||
if (header->m_magic == MAGIC_BIGALLOC_HEADER)
|
if (header->m_magic == MAGIC_BIGALLOC_HEADER)
|
||||||
size -= sizeof(CommonHeader);
|
size -= sizeof(CommonHeader);
|
||||||
|
else
|
||||||
|
ASSERT(header->m_magic == MAGIC_PAGE_HEADER);
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue