OmniSciDB  2e3a973ef4
Arena Class Reference

#include <ArenaAllocator.h>

+ Collaboration diagram for Arena:

Public Member Functions

 Arena (size_t min_block_size=1UL<< 32, size_t size_limit=0)
 
 ~Arena ()
 
void * allocate (size_t num_bytes)
 
void * allocateAndZero (const size_t size)
 

Private Attributes

SysAllocator< void > allocator_
 
std::vector< void * > allocations_
 

Detailed Description

A naive allocator which calls malloc and maintains a list of allocate pointers for freeing. For development and testing only, where folly is not available. Not for production use.

Definition at line 84 of file ArenaAllocator.h.

Constructor & Destructor Documentation

◆ Arena()

Arena::Arena ( size_t  min_block_size = 1UL << 32,
size_t  size_limit = 0 
)
inlineexplicit

Definition at line 86 of file ArenaAllocator.h.

86 {}

◆ ~Arena()

Arena::~Arena ( )
inline

Definition at line 88 of file ArenaAllocator.h.

88  {
89  for (auto ptr : allocations_) {
90  allocator_.deallocate(ptr, 0);
91  }
92  }
std::vector< void * > allocations_
void deallocate(T *p, size_t)
SysAllocator< void > allocator_

Member Function Documentation

◆ allocate()

void* Arena::allocate ( size_t  num_bytes)
inline

Definition at line 94 of file ArenaAllocator.h.

94  {
95  auto ret = allocator_.allocate(num_bytes);
96  allocations_.push_back(ret);
97  return ret;
98  }
std::vector< void * > allocations_
T * allocate(size_t count)
SysAllocator< void > allocator_

◆ allocateAndZero()

void* Arena::allocateAndZero ( const size_t  size)
inline

Definition at line 100 of file ArenaAllocator.h.

References SysAllocator< T >::allocate().

100  {
101  auto ret = allocate(size);
102  std::memset(ret, 0, size);
103  return ret;
104  }
void * allocate(size_t num_bytes)
+ Here is the call graph for this function:

Member Data Documentation

◆ allocations_

std::vector<void*> Arena::allocations_
private

Definition at line 108 of file ArenaAllocator.h.

◆ allocator_

SysAllocator<void> Arena::allocator_
private

Definition at line 107 of file ArenaAllocator.h.


The documentation for this class was generated from the following file: