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:
parent
9b699bad94
commit
606b483231
1 changed files with 8 additions and 0 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue