BlockAllocator.h 464 B

12345678910111213141516171819202122232425262728
  1. /*
  2. * Copyright (c) 2021, Andreas Kling <kling@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <AK/Vector.h>
  8. #include <LibJS/Forward.h>
  9. namespace JS {
  10. class BlockAllocator {
  11. public:
  12. BlockAllocator();
  13. ~BlockAllocator();
  14. void* allocate_block(char const* name);
  15. void deallocate_block(void*);
  16. private:
  17. static constexpr size_t max_cached_blocks = 64;
  18. Vector<void*, max_cached_blocks> m_blocks;
  19. };
  20. }