OCC Main Page | FoundationClasses | Toolkits | Packages | Class Hierarchy | Data Structures | File List | Data Fields | Globals

FoundationClasses
TKernel
NCollection


NCollection_IncAllocator Class Reference

#include <NCollection_IncAllocator.hxx>

Inheritance diagram for NCollection_IncAllocator:

Inheritance graph
[legend]

Public Types

typedef void * aligned_t

Public Member Functions

Standard_EXPORT NCollection_IncAllocator (const size_t theBlockSize=24600)
 Constructor.
virtual Standard_EXPORT void * Allocate (const size_t size)
 Allocate memory with given size. Returns NULL on failure.
virtual Standard_EXPORT void Free (void *anAddress)
 Free a previously allocated memory. Does nothing.
Standard_EXPORT size_t GetMemSize () const
 Diagnostic method, returns the number of bytes totally allocated.
Standard_EXPORT ~NCollection_IncAllocator ()
 Destructor (calls Clean() internally).
Standard_EXPORT void * Reallocate (void *anAddress, const size_t oldSize, const size_t newSize)
 Reallocation: it is always allowed but is only efficient with the last allocated item.
Standard_EXPORT void Reset (const Standard_Boolean doReleaseMem=Standard_True)
 Re-initialize the allocator so that the next Allocate call should start allocating in the very begining as though the allocator is just constructed. Warning: make sure that all previously allocated data are no more used in your code! doReleaseMem True - release all previously allocated memory, False - preserve it for future allocations.

Protected Member Functions

Standard_EXPORT void Clean ()
 Flush all previously allocated data. All pointers returned by Allocate() become invalid -- be very careful with this.
void * allocateNewBlock (const size_t cSize)
 Allocate a new block and return a pointer to it ** only for internal usage **.

Protected Attributes

IBlockmyFirstBlock
size_t mySize

Private Member Functions

 NCollection_IncAllocator (const NCollection_IncAllocator &)
NCollection_IncAllocatoroperator= (const NCollection_IncAllocator &)

Data Structures

struct  IBlock

Detailed Description

Class NCollection_IncAllocator - incremental memory allocator. This class allocates memory on request returning the pointer to an allocated block. This memory is never returned to the system until the allocator is destroyed.

By comparison with the standard new() and malloc() calls, this method is faster and consumes very small additional memory to maintain the heap.

All pointers returned by Allocate() are aligned to the size of the data type "aligned_t". To modify the size of memory blocks requested from the OS, use the parameter of the constructor (measured in bytes); if this parameter is smaller than 25 bytes on 32bit or 49 bytes on 64bit, the block size will be the default 24 kbytes


Member Typedef Documentation

typedef void* NCollection_IncAllocator::aligned_t
 


Constructor & Destructor Documentation

Standard_EXPORT NCollection_IncAllocator::NCollection_IncAllocator const size_t  theBlockSize = 24600  ) 
 

Standard_EXPORT NCollection_IncAllocator::~NCollection_IncAllocator  ) 
 

NCollection_IncAllocator::NCollection_IncAllocator const NCollection_IncAllocator  )  [private]
 


Member Function Documentation

virtual Standard_EXPORT void* NCollection_IncAllocator::Allocate const size_t  size  )  [virtual]
 

Reimplemented from NCollection_BaseAllocator.

void* NCollection_IncAllocator::allocateNewBlock const size_t  cSize  )  [protected]
 

struct Standard_EXPORT void NCollection_IncAllocator::Clean  )  [protected]
 

virtual Standard_EXPORT void NCollection_IncAllocator::Free void *  anAddress  )  [virtual]
 

Reimplemented from NCollection_BaseAllocator.

Standard_EXPORT size_t NCollection_IncAllocator::GetMemSize  )  const
 

NCollection_IncAllocator& NCollection_IncAllocator::operator= const NCollection_IncAllocator  )  [private]
 

Standard_EXPORT void* NCollection_IncAllocator::Reallocate void *  anAddress,
const size_t  oldSize,
const size_t  newSize
 

Standard_EXPORT void NCollection_IncAllocator::Reset const Standard_Boolean  doReleaseMem = Standard_True  ) 
 


Field Documentation

IBlock* NCollection_IncAllocator::myFirstBlock [protected]
 

size_t NCollection_IncAllocator::mySize [protected]
 


The documentation for this class was generated from the following file:
Generated on Mon Aug 25 13:12:56 2008 for OpenCASCADE by  doxygen 1.4.1