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 Flags,
    LPVOID lpMem,
    DWORD Bytes
);

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_REALLOC_IN_PLACE_ONLY

(Not supported in RTSS.) Specifies that there can be no movement when reallocating a memory block to a larger size. If this flag is not specified and the reallocation request is for a larger size, the function may move the block to a new location. If this flag is specified and the block cannot be enlarged without moving, the function will fail, leaving the original memory block unchanged. Because memory movement always occurs, this flag is not supported in the RTSS environment.
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
Header windows.h
Library Rtx_Rtss.lib

See Also:

GetProcessHeap

HeapAlloc

HeapFree

HeapSize

SetLastError