Table of Contents

Method Realloc

Namespace
Zyl.ExSpans
Assembly
ExSpans.dll

Realloc(void*, nuint)

Reallocates a block of memory to be the specified size, in bytes (将内存块重新分配为指定大小(以字节为单位).

[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 (指向重新分配的内存块的指针).

Remarks

This method acts as Alloc(nuint) if ptr is null (如果ptr 是 null, 此方法的作用就像 Alloc(nuint)).

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 (此方法允许 byteCount 和 0 将返回不应取消引用的有效指针,并且应将其传递给 free 以避免内存泄漏).

This method is a thin wrapper over the C realloc API (此方法是 C realloc API 上的精简包装器).

Exceptions

OutOfMemoryException

Reallocating byteCount of memory failed.