rwlogo
Rogue Wave Views 5.6

Rogue Wave Views
Foundation Package API Reference Guide

Product Documentation:

Rogue Wave Views
Documentation Home

List of all members | Static Public Member Functions
IlPoolOf(NAME) Class Reference

A generic class that handles memory pools. More...

#include <ilog/pool.h>

Static Public Member Functions

static TYPE * Alloc (IlUInt nElements, IlBoolean lock=IlFalse)
 Allocates a block of memory. More...
 
static TYPE * Lock (TYPE *data)
 Locks a data block. More...
 
static TYPE * ReAlloc (TYPE *data, IlUInt nElements, IlBoolean lock=IlFalse)
 Re-allocates a data block. More...
 
static TYPE * UnLock (TYPE *data)
 Unlocks a data block. More...
 

Detailed Description

A generic class that handles memory pools.

Library: ilog

Memory pools offer the advantage of greatly simplifying the handling the allocation, locking and deallocation of chunks of memory that can be used by your applications.

The complete body of this class is generated by the macros IlDeclarePoolOf(NAME, TYPE) and IlDefinePoolOf(NAME, TYPE), that respectively declare and define a class called IlPoolOf(NAME) that manages a memory pool for objects of the type TYPE.

A given pool can manage only arrays of TYPE, but it can manage as many of those memory blocks as needed. To get an array, you simply call the static member function IlPoolOf(NAME)::Alloc(n);, and a memory block large enough to hold n elements of type TYPE will be returned to you.

Note that if you repeat this call, you may receive the same memory block (because it may already be large enough to fit your needs). If you actually want another block to be allocated and returned to you, you must lock the first block, using the static member function IlPoolOf(NAME)::Lock(data);. This ensures that the next call to Alloc() will not return the same memory block. To unlock a memory block that you have locked, you must call UnLock().

Many functions in Rogue Wave Views will return memory blocks that are managed by pools. Therefore:

Member Function Documentation

static TYPE* IlPoolOf(NAME)::Alloc ( IlUInt  nElements,
IlBoolean  lock = IlFalse 
)
static

Allocates a block of memory.

Parameters
nElementsThe number of elements to allocate.
lockSet this to IlTrue to lock the associated data block.
Returns
A pointer to an array of pointers to TYPE. This pointer is managed by a new data block or a data block that is not locked.
static TYPE* IlPoolOf(NAME)::Lock ( TYPE *  data)
static

Locks a data block.

Locking a data block ensures that no allocation request on this pool will be authorized to return this block.

Parameters
dataThe data block to be locked.
Returns
data The data block.
static TYPE* IlPoolOf(NAME)::ReAlloc ( TYPE *  data,
IlUInt  nElements,
IlBoolean  lock = IlFalse 
)
static

Re-allocates a data block.

Parameters
dataThe data block to be re-allocated.
nElementsThe number of elements that are needed.
lockCan be set to IlTrue to lock the returned data block.
Returns
The re-allocated data block. This may not be equal to data, but the content of data is copied in this new block.
static TYPE* IlPoolOf(NAME)::UnLock ( TYPE *  data)
static

Unlocks a data block.

When you unlock a data block, any allocation request on this pool is authorized to return the same data block.

Parameters
dataThe data block to be unlocked.
Returns
The data block.

© Copyright 2012, Rogue Wave Software, Inc. All Rights Reserved.
Rogue Wave is a registered trademark of Rogue Wave Software, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.