NativeMemory.AllocZeroed 方法

定义

重载

AllocZeroed(UIntPtr)

分配指定大小(以字节为单位)的内存块并将其归零。

AllocZeroed(UIntPtr, UIntPtr)

在 元素中分配和归零指定大小的内存块。

AllocZeroed(UIntPtr)

Source:
NativeMemory.cs
Source:
NativeMemory.cs
Source:
NativeMemory.cs

重要

此 API 不符合 CLS。

分配指定大小(以字节为单位)的内存块并将其归零。

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

参数

byteCount
UIntPtr

nuint

unativeint

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

返回

Void*

指向已分配和归零内存块的指针。

属性

例外

分配 byteCount 内存失败。

注解

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

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

适用于

AllocZeroed(UIntPtr, UIntPtr)

Source:
NativeMemory.Unix.cs
Source:
NativeMemory.Unix.cs
Source:
NativeMemory.Unix.cs

重要

此 API 不符合 CLS。

在 元素中分配和归零指定大小的内存块。

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

参数

elementCount
UIntPtr

nuint

unativeint

要分配的块的计数(以元素为单位)。

elementSize
UIntPtr

nuint

unativeint

分配中每个元素的大小(以字节为单位)。

返回

Void*

指向已分配和归零内存块的指针。

属性

例外

分配 elementCount * elementSize 内存字节失败。

注解

此方法允许 elementCountelementSize0。 它返回一个有效指针,该指针不应取消引用,应将其传递给释放,以避免内存泄漏。

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

适用于