mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 03:47:35 +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()
|
BlockAllocator::~BlockAllocator()
|
||||||
{
|
{
|
||||||
for (auto* block : m_blocks) {
|
for (auto* block : m_blocks) {
|
||||||
|
#ifdef __serenity__
|
||||||
if (munmap(block, HeapBlock::block_size) < 0) {
|
if (munmap(block, HeapBlock::block_size) < 0) {
|
||||||
perror("munmap");
|
perror("munmap");
|
||||||
VERIFY_NOT_REACHED();
|
VERIFY_NOT_REACHED();
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
free(block);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,10 +49,14 @@ void BlockAllocator::deallocate_block(void* block)
|
||||||
{
|
{
|
||||||
VERIFY(block);
|
VERIFY(block);
|
||||||
if (m_blocks.size() >= max_cached_blocks) {
|
if (m_blocks.size() >= max_cached_blocks) {
|
||||||
|
#ifdef __serenity__
|
||||||
if (munmap(block, HeapBlock::block_size) < 0) {
|
if (munmap(block, HeapBlock::block_size) < 0) {
|
||||||
perror("munmap");
|
perror("munmap");
|
||||||
VERIFY_NOT_REACHED();
|
VERIFY_NOT_REACHED();
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
free(block);
|
||||||
|
#endif
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue