HeapAlloc
HeapAlloc allocates a block of memory from a heap. The allocated memory is not movable.
Syntax
LPVOID HeapAlloc( HANDLE hHeap, DWORD Flags, DWORD Bytes );
Parameters
hHeap
The heap from which the memory will be allocated. This parameter is a handle returned by GetProcessHeap.
Flags (ignored by RTX64)
The controllable aspects of heap allocation. You can specify the following flag:
HEAP_ZERO_MEMORY
The allocated memory will be initialized to zero.
Bytes
The number of bytes to be allocated.
Return Value
A pointer to the allocated memory block if the function succeeds, NULL if the function fails
Remarks
If HeapAlloc succeeds, it allocates at least the amount of memory requested. If the actual amount allocated is greater than the amount requested, because it is rounded to page boundry, the process can use the entire amount. To determine the actual size of the allocated block, use HeapSize.
To free a block of memory allocated by HeapAlloc, use HeapFree. Memory allocated by HeapAlloc is not movable. Since the memory is not movable, it is possible for the heap to become fragmented. Note that if HEAP_ZERO_MEMORY is not specified, the allocated memory may not be initialized to zero.
Requirements
Minimum Supported Version | RTX64 2013 |
Header | windows.h |
Library | Rtx_Rtss.lib |
See Also: