VAPOR3 3.9.4
Classes | Public Member Functions | Static Public Member Functions | List of all members
VAPoR::BlkMemMgr Class Reference

The Wasp BlkMemMgr class. More...

#include <BlkMemMgr.h>

Inheritance diagram for VAPoR::BlkMemMgr:
Wasp::MyBase

Public Member Functions

 BlkMemMgr ()
 Initialize a memory allocator.
 
virtual ~BlkMemMgr ()
 
void * Alloc (size_t num_blks, bool fill=false)
 Alloc space from memory pool.
 
void FreeMem (void *ptr)
 Free memory.
 
- Public Member Functions inherited from Wasp::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.
 
static size_t GetBlkSize ()
 
- Static Public Member Functions inherited from Wasp::MyBase
static void SetErrMsg (const char *format,...)
 Record a formatted error message.
 
static void SetErrMsg (int errcode, const char *format,...)
 Record a formatted error message and an error code.
 
static const char * GetErrMsg ()
 
static void SetErrCode (int err_code)
 Record an error code.
 
static int GetErrCode ()
 Retrieve the current error code.
 
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.
 
static const char * GetDiagMsg ()
 
static void SetDiagMsgCB (DiagMsgCB_T cb)
 
static DiagMsgCB_T GetDiagMsgCB ()
 
static void SetDiagMsgFilePtr (FILE *fp)
 
static bool EnableErrMsg (bool enable)
 
static bool GetEnableErrMsg ()
 

Additional Inherited Members

- Public Types inherited from Wasp::MyBase
typedef void(* ErrMsgCB_T) (const char *msg, int err_code)
 
typedef void(* DiagMsgCB_T) (const char *msg)
 
- Static Public Attributes inherited from Wasp::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 Wasp::MyBase
void SetClassName (const string &name)
 

Detailed Description

The Wasp BlkMemMgr class.

Author
John Clyne
Version
$Revision$
Date
$Date$

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.

Constructor & Destructor Documentation

◆ BlkMemMgr()

VAPoR::BlkMemMgr::BlkMemMgr ( )

Initialize a memory allocator.

Initialize a block-based memory allocator

◆ ~BlkMemMgr()

virtual VAPoR::BlkMemMgr::~BlkMemMgr ( )
virtual

Member Function Documentation

◆ Alloc()

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

Parameters
[in]num_blksSize of memory region requested in blocks
[in]fillIf true, the allocated memory will be cleared to zero
Return values
ptrA pointer to the requested memory pool

◆ FreeMem()

void VAPoR::BlkMemMgr::FreeMem ( void *  ptr)

Free memory.

Frees memory previosly allocated with the Alloc() method.

Parameters
[in]ptrPointer to memory returned by previous call to Alloc().

◆ GetBlkSize()

static size_t VAPoR::BlkMemMgr::GetBlkSize ( )
inlinestatic

Definition at line 69 of file BlkMemMgr.h.

◆ RequestMemSize()

static int VAPoR::BlkMemMgr::RequestMemSize ( size_t  blk_size,
size_t  num_blks,
bool  page_aligned = true 
)
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.

Parameters
[in]blk_sizeSize of a single memory block in bytes
[in]num_blksSize of memory pool in blocks. This is the maximum amount that will be available through subsequent Alloc() calls.
[in]page_alignedIf true, start address of memory pool will be page aligned

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