DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
Fast Special-purpose Memory Allocation for C++ - Pool(C++)

The Pool Class

A Pool represents a set of memory blocks that are all the same size. That size must be specified as a byte count when the Pool is created. For example:

   Pool p (16);

creates a Pool called p, which represents a collection of 16-character memory blocks. Once a Pool has been created, it is impossible to change the size of the blocks that can be allocated from it.

To allocate a block from a Pool, use the alloc member function:

   void* mem = p.alloc();

makes mem point at a newly-allocated block.

The free member function releases a block:

   p.free(mem);

releases the block addressed by mem into the pool p . It is the programmer's responsibility to ensure that a block is released into the same pool that originated it.

When a Pool object is destroyed, all the memory in the Pool is freed.


Next topic: Using the Pool Class
Previous topic: Introduction

© 2005 The SCO Group, Inc. All rights reserved.
SCO OpenServer Release 6.0.0 -- 02 June 2005