IBM SYSTEMG G RUNTIME & NATIVE STORE
0.5
IBM Native Graph Computing and Storage System based on IBM Parallel Programming Library
|
#include <short_alloc.h>
Public Member Functions | |
arena (const arena &_other) | |
char * | allocate (std::size_t n) |
void | deallocate (char *p, std::size_t n) |
std::size_t | used () const |
void | reset () |
Static Public Member Functions | |
static std::size_t | size () |
Private Member Functions | |
std::size_t | align_up (std::size_t n) |
bool | pointer_in_buffer (char *p) |
Private Attributes | |
char | buf_ [N] |
char * | ptr_ |
Static Private Attributes | |
static const std::size_t | alignment = 16 |
Short allocator class; Taken from internet in case we need to discuss legal issues at some point in the future;
The allocator first needs an arena of a fixed compiled size; Subsequently memory from this arena is allocated/free; No interaction with malloca afterwards. However when using it with STL vector one needs to be carefull and not resize; The allocation/free needs to happen in a stack like fassion;
E.g., you can't do this vector<int, short_alloc> v1(10) vector<int, short_alloc> v2(10) V1.resize(...);
As a rule of thumb just don't use resize();