This documentation is archived and is not being maintained.

CHeapPtr::Allocate 

Call this method to allocate memory on the heap to store objects.


bool Allocate(
   size_t nElements = 1 
) throw( );

Parameters

nElements

The number of elements used to calculate the amount of memory to allocate. The default value is 1.

Returns true if the memory was successfully allocated, false on failure.

The allocator routines are used to reserve enough memory on the heap to store nElement objects of a type defined in the constructor.

// Create a new CHeapPtr object
CHeapPtr <int> myHP;
// Allocate space for 10 integers on the heap
myHP.Allocate(10);

For another example, see the ISAPIFilter Sample.

Show: