Kernel32HeapReAlloc Method

Reallocates a block of memory from a heap.

This function enables you to resize a memory block and change other memory block properties. The allocated memory is not movable.

Definition

Namespace: DevCase.Win32.NativeMethods
Assembly: DevCase.net48 (in DevCase.net48.dll) Version: 6.0.0.0 (6.0)
XMLNS for XAML: Not mapped to an xmlns.
[DllImportAttribute("Kernel32.dll", SetLastError = true)]
public static IntPtr HeapReAlloc(
	IntPtr hHeap,
	HeapFlags flags,
	IntPtr mem,
	uint bytes
)

Parameters

hHeap  IntPtr
A handle to the heap from which the memory is to be reallocated.

This handle is returned by either the HeapCreate(HeapFlags, UInt32, UInt32) or GetProcessHeap function.

flags  HeapFlags
The heap reallocation options.

Specifying any of the HeapFlags values will override the corresponding value specified when the heap was created with HeapCreate(HeapFlags, UInt32, UInt32).

mem  IntPtr
A pointer to the block of memory that the function reallocates.

This pointer is returned by an earlier call to the HeapAlloc(IntPtr, HeapFlags, UInt32) or HeapReAlloc(IntPtr, HeapFlags, IntPtr, UInt32) function.

bytes  UInt32
The new size of the memory block, in bytes.

A memory block's size can be increased or decreased by using this function.

If the heap specified by the hHeap parameter is a "non-growable" heap, bytes must be less than 0x7FFF8.

You create a non-growable heap by calling the HeapCreate(HeapFlags, UInt32, UInt32) function passing a nonzero value to its maximumSize parameter.

Return Value

IntPtr
If the function succeeds, the return value is a pointer to the reallocated memory block.

If the function fails and you have not specified GenerateExceptions, the return value is Zero.

If the function fails and you have specified GenerateExceptions, the function may generate an exception. The particular exception depends upon the nature of the heap corruption.

Remarks

See Also