Rediger

Del via


NativeMemory.Realloc(Void*, UIntPtr) Method

Definition

Important

This API is not CLS-compliant.

Reallocates a block of memory to be the specified size, in bytes.

public:
 static void* Realloc(void* ptr, UIntPtr byteCount);
[System.CLSCompliant(false)]
public static void* Realloc (void* ptr, nuint byteCount);
[System.CLSCompliant(false)]
public static void* Realloc (void* ptr, UIntPtr byteCount);
[<System.CLSCompliant(false)>]
static member Realloc : nativeptr<unit> * unativeint -> nativeptr<unit>

Parameters

ptr
Void*

The previously allocated block of memory.

byteCount
UIntPtr

nuint

unativeint

The size, in bytes, of the reallocated block.

Returns

Void*

A pointer to the reallocated block of memory.

Attributes

Exceptions

Reallocating byteCount of memory failed.

Remarks

This method acts as Alloc(UIntPtr, UIntPtr) if ptr is null.

This method allows byteCount to be 0 and will return a valid pointer that should not be dereferenced and that should be passed to free to avoid memory leaks.

This method is a thin wrapper over the C realloc API.

Applies to