HeapReAlloc

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

Syntax

Copy
LPVOID HeapReAlloc(
    [in]    HANDLE hHeap,
    [in]    DWORD dwFlags,
    [in]    LPVOID lpMem,
    [in]    SIZE_T dwBytes
);

Parameters

[in] hHeap

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

[in] Flags

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

Value Meaning

HEAP_ZERO_MEMORY

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

[in] lpMem

A pointer to the block of memory that the function reallocates. An earlier call to HeapAlloc or HeapReAlloc returns this pointer.

[in] Bytes

This function returns the new size of the memory block in bytes. It can be used to increase or decrease the size of a memory block.

Return Value

If the function succeeds, it returns a pointer to the reallocated memory block. If the function fails, it returns NULL.

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

Remarks

If HeapReAlloc succeeds, it allocates the requested amount of memory. If the actual amount allocated is greater than the requested amount, 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 Header Library

wRTOS 1.0 SDK

windows.h

wRTOS_rtss.lib

See Also: