CComAllocator Class

 

The latest version of this topic can be found at CComAllocator Class.

This class provides methods for managing memory using COM memory routines.

Syntax

class CComAllocator

Members

Public Methods

Name Description
CComAllocator::Allocate Call this static method to allocate memory.
CComAllocator::Free Call this static method to free allocated memory.
CComAllocator::Reallocate Call this static method to reallocate memory.

Remarks

This class is used by CComHeapPtr to provide the COM memory allocation routines. The counterpart class, CCRTAllocator, provides the same methods using CRT routines.

Requirements

Header: atlbase.h

CComAllocator::Allocate

Call this static function to allocate memory.

static void* Allocate(size_t nBytes) throw();

Parameters

nBytes
The number of bytes to allocate.

Return Value

Returns a void pointer to the allocated space, or NULL if there is insufficient memory available.

Remarks

Allocates memory. See CoTaskMemAlloc for more details.

CComAllocator::Free

Call this static function to free allocated memory.

static void Free(void* p) throw();

Parameters

p
Pointer to the allocated memory.

Remarks

Frees the allocated memory. See CoTaskMemFree for more details.

CComAllocator::Reallocate

Call this static function to reallocate memory.

static void* Reallocate(void* p, size_t nBytes) throw();

Parameters

p
Pointer to the allocated memory.

nBytes
The number of bytes to reallocate.

Return Value

Returns a void pointer to the allocated space, or NULL if there is insufficient memory

Remarks

Resizes the amount of allocated memory. See CoTaskMemRealloc for more details.

See Also

CComHeapPtr Class
CCRTAllocator Class
Class Overview