NativeMemory.Realloc(Void*, UIntPtr) 方法

定義

重要

此 API 不符合 CLS 規範。

將記憶體區塊重新分配到指定大小(以位元組為單位)。

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

參數

ptr
Void*

先前分配的記憶體區塊。

byteCount
UIntPtr

nuint

unativeint

重新配置區塊的大小(以位元組為單位)。

傳回

Void*

指向重新分配的記憶體區塊的指標。

屬性

例外狀況

記憶重新分配 byteCount 失敗了。

備註

此方法表現為 Alloc(UIntPtr, UIntPtr)ptrnull

此方法允許 byteCount0 會回傳一個有效的指標,該指標不應被取消引用,且應傳遞給 free,以避免記憶體洩漏。

此方法是 C realloc API 上的薄包裝。

適用於