NativeMemory.Alloc Metod

Definition

Överlagringar

Name Description
Alloc(UIntPtr)

Allokerar ett minnesblock av den angivna storleken i byte.

Alloc(UIntPtr, UIntPtr)

Allokerar ett minnesblock av den angivna storleken i element.

Alloc(UIntPtr)

Källa:
NativeMemory.Unix.cs
Källa:
NativeMemory.Unix.cs
Källa:
NativeMemory.Unix.cs
Källa:
NativeMemory.Unix.cs
Källa:
NativeMemory.Unix.cs

Viktigt!

Detta API uppfyller inte CLS.

Allokerar ett minnesblock av den angivna storleken i byte.

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

Parametrar

byteCount
UIntPtr

nuint

unativeint

Storleken, i byte, på blocket som ska allokeras.

Returer

Void*

En pekare till det allokerade minnesblocket.

Attribut

Undantag

Det gick inte att allokera byteCount minne.

Kommentarer

Den här metoden tillåter byteCount att vara 0 och returnerar en giltig pekare som inte ska avrefereras och som ska skickas utan kostnad för att undvika minnesläckor.

Den här metoden är en tunn omslutning över C-API malloc :et.

Gäller för

Alloc(UIntPtr, UIntPtr)

Källa:
NativeMemory.cs
Källa:
NativeMemory.cs
Källa:
NativeMemory.cs
Källa:
NativeMemory.cs
Källa:
NativeMemory.cs

Viktigt!

Detta API uppfyller inte CLS.

Allokerar ett minnesblock av den angivna storleken i element.

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

Parametrar

elementCount
UIntPtr

nuint

unativeint

Antalet, i element, för blocket som ska allokeras.

elementSize
UIntPtr

nuint

unativeint

Storleken i byte för varje element i allokeringen.

Returer

Void*

En pekare till det allokerade minnesblocket.

Attribut

Undantag

Det gick inte att allokera elementCount * elementSize byte minne.

Kommentarer

Den här metoden tillåter elementCount och/eller elementSize0 returnerar en giltig pekare som inte ska derefereras och som ska skickas utan kostnad för att undvika minnesläckor.

Den här metoden är en tunn omslutning över C-API malloc :et.

Gäller för