34 lines
1.5 KiB
Markdown
34 lines
1.5 KiB
Markdown
|
---
|
||
|
title: "memory.h"
|
||
|
summary: "basic memory functionalities"
|
||
|
---
|
||
|
|
||
|
# `memory_copy(source, destination, num)` - function (void)
|
||
|
Copies **_num_** bytes from **_source_** to **_destination_**.
|
||
|
On linux this function is called _memcpy_.
|
||
|
|
||
|
# `memory_set(destination, data, num)` - function (void)
|
||
|
Sets **_num_** bytes at **_destination_** to **_data_**.
|
||
|
On linux this function is called _memset_.
|
||
|
|
||
|
# `memory_compare(a, b, num)` - function (bool)
|
||
|
Compares the first **_num_** bytes at **_a_** and **_b_**.
|
||
|
Returns **false** if there is a different byte.
|
||
|
Returns **true** if the data is the same.
|
||
|
There is a similar function on linux called _memcmp_.
|
||
|
|
||
|
# `memory_allocate(size)` - function (void*)
|
||
|
Returns the address to a buffer, that is at least **_size_** bytes big.
|
||
|
On linux this function is called _malloc_.
|
||
|
|
||
|
# `memory_free(address)` - function (void)
|
||
|
Free the buffer at address and marks it claimable again , this buffer needs to be a buffer, that was created with [memory_allocate](https://nerdcult.net/projects/noxos/docs/codebase/utils/memory.h/#memory_allocatesize---function-void).
|
||
|
On linux this function is called _free_.
|
||
|
|
||
|
# `memory_allocator_init(base)` - function (void)
|
||
|
This initializes the heap, where [memory_allocate](https://nerdcult.net/projects/noxos/docs/codebase/utils/memory.h/#memory_allocatesize---function-void) allocates memory.
|
||
|
|
||
|
# `memory_hexdump(address, num)` - function (void)
|
||
|
Logs **_num_** bytes from **_address_** as 8 byte rows.
|
||
|
The data is represented in hexadecimal and ascii.
|