Share via


NativeMemory.Realloc(Void*, UIntPtr) 方法

定义

重要

此 API 不符合 CLS。

将内存块重新分配为指定大小(以字节为单位)。

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>

参数

ptr
Void*

以前分配的内存块。

byteCount
UIntPtr

nuint

unativeint

重新分配的块的大小(以字节为单位)。

返回

Void*

指向重新分配的内存块的指针。

属性

例外

重新分配 byteCount 内存失败。

注解

此方法的作用就像 Alloc(UIntPtr, UIntPtr)ptrnull

此方法允许 byteCount0 将返回不应取消引用的有效指针,并且应将其传递给 free 以避免内存泄漏。

此方法是 C realloc API 上的精简包装器。

适用于