LibC: Add two little assertions in malloc() and malloc_size()

This commit is contained in:
Andreas Kling 2020-11-08 01:13:07 +01:00
commit 79b45f96ee
Notes: sideshowbarker 2024-07-19 01:31:12 +09:00

View file

@ -310,6 +310,7 @@ static void* malloc_impl(size_t size)
--block->m_free_chunks;
void* ptr = block->m_freelist;
ASSERT(ptr);
block->m_freelist = block->m_freelist->next;
if (block->is_full()) {
g_malloc_stats.number_of_blocks_full++;
@ -455,6 +456,8 @@ size_t malloc_size(void* ptr)
auto size = header->m_size;
if (header->m_magic == MAGIC_BIGALLOC_HEADER)
size -= sizeof(CommonHeader);
else
ASSERT(header->m_magic == MAGIC_PAGE_HEADER);
return size;
}