Memory utils for convenient work with memory, arrays and pointers.
The library is mainly intended for use with native code, such as C++ or in conjunction with Native AOT. All actions are carried out with the heap, all allocated pointers do not change the address, so they can be safely used from any part of the code
void* ptr = MemEx.Alloc(6); // Allocates 6 bytes in memory
// ...
MemEx.Free(ptr); // Free pointer
You can use other overloads of Alloc method for convenient work
int* ptr = MemEx.Alloc<int>(6); // Allocates sizeof(int) * 6 bytes in memory
int value = 7;
int* ptr = MemEx.NewAlloc(value); // Allocates 4 bytes and write value to pointer
// It should be noted that the allocation goes to the heap, not the stack, so this is not the same as &value
int[] nums = { 1, 2, 3 };
int* ptr = MemEx.AllocFrom(nums); // Allocates sizeof(int) * nums.Length bytes in memory and write array to pointer
string managedString = "Some unicode string";
using CoMem strCo = new CoMem(managedString, CoStrType.Uni);
ushort* unmanagedStringPtr = (ushort*)strCo;
//...
Start ordinal | Framework | Description | Date |
---|---|---|---|
2.0.1 | .net8.0 | Added MIT License | Apr 28, 2024 |
2.0.0 | .net8.0 | Switched to DotnetNativeBase | Apr 25, 2024 |
1.1.0 | .net8.0 | Changed framework | Nov 15, 2023 |
1.0.0 | .net7.0 | Sep 5, 2024 |