CLocalHeap Class

 

For the latest documentation on Visual Studio 2017 RC, see Visual Studio 2017 RC Documentation.

This class implements IAtlMemMgr using the Win32 local heap functions.

System_CAPS_ICON_important.jpg Important

This class and its members cannot be used in applications that execute in the Windows Runtime.

class CLocalHeap : public IAtlMemMgr

Public Methods

NameDescription
CLocalHeap::AllocateCall this method to allocate a block of memory.
CLocalHeap::FreeCall this method to free a block of memory allocated by this memory manager.
CLocalHeap::GetSizeCall this method to get the allocated size of a memory block allocated by this memory manager.
CLocalHeap::ReallocateCall this method to reallocate memory allocated by this memory manager.

CLocalHeap implements memory allocation functions using the Win32 local heap functions.

System_CAPS_ICON_note.jpg Note

The local heap functions are slower than other memory management functions and do not provide as many features. Therefore, new applications should use the heap functions. These are available in the CWin32Heap class.

See the example for IAtlMemMgr.

IAtlMemMgr

CLocalHeap

Header: atlmem.h

Call this method to allocate a block of memory.

virtual __declspec(allocator) void* Allocate(size_t nBytes) throw();

Parameters

nBytes
The requested number of bytes in the new memory block.

Return Value

Returns a pointer to the start of the newly allocated memory block.

Remarks

Call CLocalHeap::Free or CLocalHeap::Reallocate to free the memory allocated by this method.

Implemented using LocalAlloc with a flag parameter of LMEM_FIXED.

Call this method to free a block of memory allocated by this memory manager.

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

Parameters

p
Pointer to memory previously allocated by this memory manager. NULL is a valid value and does nothing.

Remarks

Implemented using LocalFree.

Call this method to get the allocated size of a memory block allocated by this memory manager.

virtual size_t GetSize(void* p) throw();

Parameters

p
Pointer to memory previously allocated by this memory manager.

Return Value

Returns the size of the allocated memory block in bytes.

Remarks

Implemented using LocalSize.

Call this method to reallocate memory allocated by this memory manager.

virtual __declspec(allocator) void* Reallocate(void* p, size_t nBytes) throw();

Parameters

p
Pointer to memory previously allocated by this memory manager.

nBytes
The requested number of bytes in the new memory block.

Return Value

Returns a pointer to the start of the newly allocated memory block.

Remarks

Call CLocalHeap::Free to free the memory allocated by this method.

Implemented using LocalReAlloc.

Class Overview
CComHeap Class
CWin32Heap Class
CGlobalHeap Class
CCRTHeap Class
IAtlMemMgr Class

Show: