dime  0.9.1
Portable DXF file library
Loading...
Searching...
No Matches
dimeMemHandler Class Reference

The dimeMemHandler class is a special-purpose memory manager. More...

#include <dime/util/MemHandler.h>

Public Member Functions

 dimeMemHandler ()
 
 ~dimeMemHandler ()
 
void * allocMem (const int size, const int alignment=4)
 
bool initOk () const
 
char * stringAlloc (const char *const string)
 

Detailed Description

The dimeMemHandler class is a special-purpose memory manager.

Using this class will give you efficient memory allocation and extremely efficient deallocation. In addition, there is almost no overhead on the memory allocated. The drawback is that it is not possible to deallocate a block of memory once it is allocated; all the allocated memory must be deallocated in one operation.

If you plan to use DIME in a way that requires lots of dynamic allocation / deallocation of for instance entities, you should not use the memory manager - the standard new / delete operators should be used instead. The most common use of dime is to import and export DXF files, so the data structure is just built and then freed up all at once. For this kind of usage, the special-purpose memory manager is far superior to the system memory manager.

Constructor & Destructor Documentation

◆ dimeMemHandler()

dimeMemHandler::dimeMemHandler ( )

Constructor. Get ready for fast alloc :-)

◆ ~dimeMemHandler()

dimeMemHandler::~dimeMemHandler ( )

Frees all memory used.

Member Function Documentation

◆ allocMem()

void * dimeMemHandler::allocMem ( const int size,
const int alignment = 4 )

Allocates a chunk (size) of memory. Memory is allocated in big blocks. New blocks of memory are allocated whenever needed, and are handled automatically. The returned pointer is aligned according to the alignment argument. The default alignment is four bytes, but when compiled on 64 bit systems the default alignment should probably be changed to eight.

◆ initOk()

bool dimeMemHandler::initOk ( ) const

Bullshit function. Can be called right after constructor to test if initial memory was allocated OK.

◆ stringAlloc()

char * dimeMemHandler::stringAlloc ( const char *const string)

Allocates memory for the string, copies string into memory, and returns the new string pointer.


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