static class · System.Runtime.InteropServices
NativeMemory
public static class NativeMemory
Native memory blocks (not seen by the collector).
- Kind
- static class
- Namespace
- System.Runtime.InteropServices
- Assembly
- System.Core
- Access
- public, static, abstract
- Source file
Interop.ant
Inheritance
- Base classes
-
AnyNativeMemory
Methods
bytes of native memory, zeroed (Free gives it back).
count elements of size bytes, zeroed.
unsafe Free(void* block)
#
Copies bytes bytes from source to destination (the blocks do not overlap).
Sets bytes bytes at block to value.
Inherited members (5)
GetTypemethod from AnyUndescribedmethod from AnyToStringmethod from AnyHashmethod from Anydestroymethod from Any
Source
NativeMemory as Antril, decompiled from its Larva HIR.
// System.Runtime.InteropServices.NativeMemory — System.Core (decompiled from Larva HIR)
into namespace System.Runtime.InteropServices
{
/// Native memory blocks (not seen by the collector).
public static class NativeMemory
{
public:
/// `bytes` of native memory, zeroed (Free gives it back).
unsafe Alloc(u64 bytes) : void* => (void*)CStrings.Allocate((i64)bytes);
/// `count` elements of `size` bytes, zeroed.
unsafe AllocZeroed(u64 count, u64 size) : void* => (void*)CStrings.Allocate((i64)(count * size));
unsafe Free(void* block)
{
CStrings.Release((u8*)block);
}
/// Copies `bytes` bytes from `source` to `destination` (the blocks do not overlap).
unsafe Copy(void* source, void* destination, u64 bytes)
{
u8* from = (u8*)source;
u8* to = (u8*)destination;
loop (u64 i = 0; i < bytes; i++)
*(to + (i64)i) = *(from + (i64)i);
}
/// Sets `bytes` bytes at `block` to `value`.
unsafe Fill(void* block, u64 bytes, u8 value)
{
u8* at = (u8*)block;
loop (u64 i = 0; i < bytes; i++)
*(at + (i64)i) = value;
}
unsafe Clear(void* block, u64 bytes)
{
Fill(block, bytes, 0);
}
}
}