VAPoR
0.1
|
The VetsUtil BlkMemMgr class. More...
#include <BlkMemMgr.h>
Public Member Functions | |
BlkMemMgr () | |
Initialize a memory allocator. More... | |
virtual | ~BlkMemMgr () |
void * | Alloc (size_t num_blks, bool fill=false) |
Alloc space from memory pool. More... | |
void | FreeMem (void *ptr) |
Free memory. More... | |
Public Member Functions inherited from VetsUtil::MyBase | |
MyBase () | |
const string & | getClassName () const |
Static Public Member Functions | |
static int | RequestMemSize (size_t blk_size, size_t num_blks, bool page_aligned=true) |
Set the size of the memory pool used by the memory allocator. More... | |
static size_t | GetBlkSize () |
Static Public Member Functions inherited from VetsUtil::MyBase | |
static void | SetErrMsg (const char *format,...) |
Record a formatted error message. More... | |
static void | SetErrMsg (int errcode, const char *format,...) |
Record a formatted error message and an error code. More... | |
static const char * | GetErrMsg () |
static void | SetErrCode (int err_code) |
Record an error code. More... | |
static int | GetErrCode () |
Retrieve the current error code. More... | |
static void | SetErrMsgCB (ErrMsgCB_T cb) |
static ErrMsgCB_T | GetErrMsgCB () |
static void | SetErrMsgFilePtr (FILE *fp) |
static const FILE * | SetErrMsgFilePtr () |
static void | SetDiagMsg (const char *format,...) |
Record a formatted diagnostic message. More... | |
static const char * | GetDiagMsg () |
static void | SetDiagMsgCB (DiagMsgCB_T cb) |
static DiagMsgCB_T | GetDiagMsgCB () |
static void | SetDiagMsgFilePtr (FILE *fp) |
static bool | EnableErrMsg (bool enable) |
Additional Inherited Members | |
Public Types inherited from VetsUtil::MyBase | |
typedef void(* | ErrMsgCB_T )(const char *msg, int err_code) |
typedef void(* | DiagMsgCB_T )(const char *msg) |
Static Public Attributes inherited from VetsUtil::MyBase | |
static char * | ErrMsg |
static int | ErrCode |
static int | ErrMsgSize |
static FILE * | ErrMsgFilePtr |
static ErrMsgCB_T | ErrMsgCB |
static char * | DiagMsg |
static int | DiagMsgSize |
static FILE * | DiagMsgFilePtr |
static DiagMsgCB_T | DiagMsgCB |
static bool | Enabled |
Protected Member Functions inherited from VetsUtil::MyBase | |
void | SetClassName (const string &name) |
A block-based memory allocator. Allocates contiguous runs of memory blocks from a memory pool of user defined size.
N.B. the memory pool is stored in a static class member and can only be freed by calling RequestMemSize() with a zero value after all instances of this class have been destroyed
Definition at line 26 of file BlkMemMgr.h.
VAPoR::BlkMemMgr::BlkMemMgr | ( | ) |
Initialize a memory allocator.
Initialize a block-based memory allocator
|
virtual |
void* VAPoR::BlkMemMgr::Alloc | ( | size_t | num_blks, |
bool | fill = false |
||
) |
Alloc space from memory pool.
Return a pointer to the specified amount of memory from the memory pool
[in] | num_blks | Size of memory region requested in blocks |
[in] | fill | If true, the allocated memory will be cleared to zero |
ptr | A pointer to the requested memory pool |
void VAPoR::BlkMemMgr::FreeMem | ( | void * | ptr | ) |
|
inlinestatic |
Definition at line 72 of file BlkMemMgr.h.
|
static |
Set the size of the memory pool used by the memory allocator.
Initialize a block-based memory allocator. The static memory pool is not changed until the first instance of an object of this class is created, or if there are no instances of objects the memmory pool is changed immediately. The only way to free memory from the static memory pool is to call this static method with either blk_size
or num_blks
set to zero.
[in] | blk_size | Size of a single memory block in bytes |
[in] | num_blks | Size of memory pool in blocks. This is the maximum amount that will be available through subsequent Alloc() calls. |
[in] | page_aligned | If true, start address of memory pool will be page aligned |