summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibJS/Heap/BlockAllocator.h
blob: 70c873c10fb9a66583c9757084ce8174b8e9d867 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
/*
 * Copyright (c) 2021, Andreas Kling <kling@serenityos.org>
 *
 * SPDX-License-Identifier: BSD-2-Clause
 */

#pragma once

#include <AK/Vector.h>
#include <LibJS/Forward.h>

namespace JS {

class BlockAllocator {
public:
    BlockAllocator();
    ~BlockAllocator();

    void* allocate_block(char const* name);
    void deallocate_block(void*);

private:
    static constexpr size_t max_cached_blocks = 64;

    Vector<void*, max_cached_blocks> m_blocks;
};

}