Main Page   Modules   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   Related Pages  

TNL::DataChunker Class Reference

Implements a chunked data allocater. More...

#include <tnlDataChunker.h>

Inheritance diagram for TNL::DataChunker:

TNL::ClassChunker< T > List of all members.

Public Types

enum  { ChunkSize = 16376 }

Public Methods

void * alloc (S32 size)
 allocate a pointer to memory of size bytes from the DataChunker

void freeBlocks ()
 free all pages currently allocated in the DataChunker

 DataChunker (S32 size=ChunkSize)
 Construct a DataChunker with a page size of size bytes.

void swap (DataChunker &d)
 Swaps the memory allocated in one data chunker for another.


Detailed Description

Implements a chunked data allocater.

Calling new/malloc all the time is a time consuming operation. Therefore, we provide the DataChunker, which allocates memory in blocks of chunkSize (by default 16k, see ChunkSize, though it can be set in the constructor), then doles it out as requested, in chunks of up to chunkSize in size.

It will assert if you try to get more than ChunkSize bytes at a time, and it deals with the logic of allocating new blocks and giving out word-aligned chunks.

Note that new/free/realloc WILL NOT WORK on memory gotten from the DataChunker. This also only grows (you can call freeBlocks to deallocate and reset things).

Definition at line 51 of file tnlDataChunker.h.


Member Enumeration Documentation

anonymous enum
 

Enumeration values:
ChunkSize  Default size of each DataBlock page in the DataChunker.

Definition at line 54 of file tnlDataChunker.h.


Member Function Documentation

void TNL::DataChunker::swap DataChunker &    d [inline]
 

Swaps the memory allocated in one data chunker for another.

This can be used to implement packing of memory stored in a DataChunker.

Definition at line 81 of file tnlDataChunker.h.

References curBlock.


The documentation for this class was generated from the following files:
Generated on Thu Aug 18 16:03:37 2005 for Robin Hood: Thieves & Knights by doxygen1.2.18