Skip to content

Commit 159747e

Browse files
authored
Update README.md
1 parent d8dae34 commit 159747e

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

README.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,21 @@
11
# Memory.Extensions [![NuGet](https://img.shields.io/nuget/v/Yotic.Memory.Extensions.svg)](https://www.nuget.org/packages/Yotic.Memory.Extensions)
22

33
Memory utils for convenient work with memory, arrays and pointers.
4+
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
45

5-
<h2>Examples</h2>
6+
Allocating memory
7+
------------------------------
8+
```C#
9+
void* ptr = MemEx.Alloc(6); // Allocates 6 bytes in memory
10+
// ...
11+
MemEx.Free(ptr); // Free pointer
12+
```
13+
You can use other overloads of Alloc method for convenient work
14+
```C#
15+
int* ptr = MemEx.Alloc<int>(6); // Allocates sizeof(int) * 6 bytes in memory and returns int*
16+
```
17+
```C#
18+
int value = 7;
19+
int* ptr = MemEx.NewAlloc(value); // Allocates 4 bytes and write value to pointer
20+
// It should be noted that the allocation goes to the heap, not the stack, so this is not the same as &value
21+
```

0 commit comments

Comments
 (0)