OmniSciDB  94e8789169
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 92 of file ArenaAllocator.h.

Constructor & Destructor Documentation

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

Definition at line 94 of file ArenaAllocator.h.

94 {}
Arena::~Arena ( )
inline

Definition at line 96 of file ArenaAllocator.h.

References allocations_, allocator_, and SysAllocator< T >::deallocate().

96  {
97  for (auto ptr : allocations_) {
98  allocator_.deallocate(ptr, 0);
99  }
100  }
std::vector< void * > allocations_
void deallocate(T *p, size_t)
SysAllocator< void > allocator_

+ Here is the call graph for this function:

Member Function Documentation

void* Arena::allocate ( size_t  num_bytes)
inline

Definition at line 102 of file ArenaAllocator.h.

References SysAllocator< T >::allocate(), allocations_, and allocator_.

Referenced by allocateAndZero().

102  {
103  auto ret = allocator_.allocate(num_bytes);
104  allocations_.push_back(ret);
105  return ret;
106  }
std::vector< void * > allocations_
T * allocate(size_t count)
SysAllocator< void > allocator_

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Definition at line 108 of file ArenaAllocator.h.

References allocate().

108  {
109  auto ret = allocate(size);
110  std::memset(ret, 0, size);
111  return ret;
112  }
void * allocate(size_t num_bytes)

+ Here is the call graph for this function:

Member Data Documentation

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

Definition at line 116 of file ArenaAllocator.h.

Referenced by allocate(), and ~Arena().

SysAllocator<void> Arena::allocator_
private

Definition at line 115 of file ArenaAllocator.h.

Referenced by allocate(), and ~Arena().


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