Functions for managing and manipulating memory.
More...
|
void * | sys_malloc (size_t size) |
| Allocates a block of memory. More...
|
|
void | sys_free (void *ptr) |
| Frees a block of memory. More...
|
|
void * | sys_memset (void *ptr, uint8_t value, size_t size) |
| Set memory to a specific value. More...
|
|
void * | sys_memcpy (void *dest, const void *src, size_t size) |
| Copy memory from source to destination. More...
|
|
void * | sys_memmove (void *dest, const void *src, size_t size) |
| Move memory from source to destination (handles overlapping regions) More...
|
|
int | sys_memcmp (const void *ptr1, const void *ptr2, size_t num) |
| Compare two memory blocks. More...
|
|
int | sys_strcmp (const char *str1, const char *str2) |
| Compare two NULL-terminated strings. More...
|
|
Functions for managing and manipulating memory.
These are utility functions for memory allocation, deallocation, and manipulation. They provide a simple interface for dynamic memory management, including allocation, freeing, setting, copying, moving, and comparing memory blocks.
In general your target platform will also provide its own memory management functions, but these are provided for convenience and consistency across platforms, in case some platforms do not provide their own versions.
◆ sys_free()
void sys_free |
( |
void * |
ptr | ) |
|
◆ sys_malloc()
void* sys_malloc |
( |
size_t |
size | ) |
|
◆ sys_memcmp()
int sys_memcmp |
( |
const void * |
ptr1, |
|
|
const void * |
ptr2, |
|
|
size_t |
num |
|
) |
| |
Compare two memory blocks.
- Parameters
-
ptr1 | First memory block |
ptr2 | Second memory block |
num | Number of bytes to compare |
- Returns
- 0 if equal, negative if ptr1 < ptr2, positive if ptr1 > ptr2
◆ sys_memcpy()
void* sys_memcpy |
( |
void * |
dest, |
|
|
const void * |
src, |
|
|
size_t |
size |
|
) |
| |
Copy memory from source to destination.
- Parameters
-
dest | Destination memory block |
src | Source memory block |
size | Number of bytes to copy |
- Returns
- Pointer to destination, or NULL on error
◆ sys_memmove()
void* sys_memmove |
( |
void * |
dest, |
|
|
const void * |
src, |
|
|
size_t |
size |
|
) |
| |
Move memory from source to destination (handles overlapping regions)
- Parameters
-
dest | Destination memory block |
src | Source memory block |
size | Number of bytes to move |
- Returns
- Pointer to destination, or NULL on error
◆ sys_memset()
void* sys_memset |
( |
void * |
ptr, |
|
|
uint8_t |
value, |
|
|
size_t |
size |
|
) |
| |
Set memory to a specific value.
- Parameters
-
ptr | Pointer to the memory block |
value | Value to set each byte to |
size | Number of bytes to set |
- Returns
- Pointer to the memory block, or NULL on error
◆ sys_strcmp()
int sys_strcmp |
( |
const char * |
str1, |
|
|
const char * |
str2 |
|
) |
| |
Compare two NULL-terminated strings.
- Parameters
-
ptr1 | First string |
ptr2 | Second string |
- Returns
- 0 if equal, negative if ptr1 < ptr2, positive if ptr1 > ptr2