1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 18:17:44 +00:00

LibJS: Make BlockAllocator use free() on non-Serenity platforms

If we use aligned_alloc() to allocate, we have to use free() to free.
This commit is contained in:
Andreas Kling 2021-05-27 20:06:47 +02:00
parent 9b699bad94
commit 606b483231

View file

@ -20,10 +20,14 @@ BlockAllocator::BlockAllocator()
BlockAllocator::~BlockAllocator()
{
for (auto* block : m_blocks) {
#ifdef __serenity__
if (munmap(block, HeapBlock::block_size) < 0) {
perror("munmap");
VERIFY_NOT_REACHED();
}
#else
free(block);
#endif
}
}
@ -45,10 +49,14 @@ void BlockAllocator::deallocate_block(void* block)
{
VERIFY(block);
if (m_blocks.size() >= max_cached_blocks) {
#ifdef __serenity__
if (munmap(block, HeapBlock::block_size) < 0) {
perror("munmap");
VERIFY_NOT_REACHED();
}
#else
free(block);
#endif
return;
}