อ่านในภาษาอังกฤษ แก้ไข

แชร์ผ่าน


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.

C#
[System.CLSCompliant(false)]
public static void* Realloc(void* ptr, UIntPtr byteCount);
C#
[System.CLSCompliant(false)]
public static void* Realloc(void* ptr, nuint byteCount);

Parameters

ptr
Void*

The previously allocated block of memory.

byteCount

nuint

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

ผลิตภัณฑ์ เวอร์ชัน
.NET 6, 7, 8, 9, 10