HeapReAlloc

HeapReAlloc reallocates a block of memory from a heap. This function enables you to resize a memory block and change other memory block properties.

Syntax

LPVOID HeapReAlloc(
    HANDLE hHeap,
    DWORD dwFlags,
    LPVOID lpMem,
    SIZE_T dwBytes
);

Parameters

hHeap

The heap from which the memory will be reallocated. This is the handle returned by GetProcessHeap.

Flags

The controllable aspects of heap reallocation. You can specify one or both of the following flags:

Value Description

HEAP_ZERO_MEMORY

If the reallocation request is for a larger size, this flag specifies that the additional region of memory beyond the original size will be initialized to zero. The contents of the memory block—up to its original size—are unaffected.

lpMem

A pointer to the block of memory that the function reallocates. This pointer is returned by an earlier call to HeapAlloc or HeapReAlloc.

Bytes

The new size of the memory block, in bytes. A memory block's size can be increased or decreased by using this function.

Return Value

A pointer to the reallocated memory block if the function succeeds, NULL if the function fails

On failure, the function calls SetLastError. To get extended error information, call GetLastError.

Remarks

If HeapReAlloc succeeds, it allocates at least the amount of memory requested. If the actual amount allocated is greater than the amount requested, the process can use the entire amount. To determine the actual size of the reallocated block, use HeapSize.

To free a block of memory allocated by HeapReAlloc, use HeapFree.

Requirements

Minimum Supported Version

RTX64 2013

API changes for RTX64 4.0

  • Changed DWORD Bytes to SIZE_T dwBytes
Header windows.h
Library Rtx_Rtss.lib

See Also:

GetProcessHeap

HeapAlloc

HeapFree

HeapSize

SetLastError