| http://www.coin3d.org/ http://www.kongsberg.com/kogt/

Public Member Functions | List of all members
dimeMemHandler Class Reference

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

`#include <dime/util/MemHandler.h>`

## Public Member Functions

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

## 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 allocates in big blocks. New blocks of memory is allocated whenever needed, and is handled automatically. The returned pointer is aligned according to the alignment argument. The default alignment is four bytes, but when compiled on 64 bits systems the default alignment should probably be changed to eight.

Referenced by stringAlloc(), and dimeUnknownSection::~dimeUnknownSection().

## ◆ 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.

References allocMem().

Referenced by dimeStringRecord::setValue().

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

- MemHandler.h
- MemHandler.cpp

Copyright © by Kongsberg Oil & Gas Technologies. All rights reserved.