34 char *Allocate(
size_t bytes);
37 char *AllocateAligned(
size_t bytes);
41 size_t MemoryUsage()
const {
return memory_usage_.load(std::memory_order_relaxed); }
44 char *AllocateFallback(
size_t bytes);
45 char *AllocateNewBlock(
size_t block_bytes);
49 size_t alloc_bytes_remaining_;
52 std::vector<char *> blocks_;
58 std::atomic<size_t> memory_usage_;
61inline char *Arena::Allocate(
size_t bytes)
67 if (bytes <= alloc_bytes_remaining_) {
68 char *result = alloc_ptr_;
70 alloc_bytes_remaining_ -= bytes;
73 return AllocateFallback(bytes);
Definition: arena_allocator.h:24