Wrapper for common memory operations.
More...
|
UA_WARN_UNUSED_RESULT PLATFORM_EXPORT void * | ua_malloc (size_t size) |
| Allocate memory. More...
|
|
UA_WARN_UNUSED_RESULT PLATFORM_EXPORT void * | ua_calloc (size_t nmemb, size_t size) |
| Allocate memory for an array of elements. More...
|
|
UA_WARN_UNUSED_RESULT PLATFORM_EXPORT void * | ua_realloc (void *ptr, size_t size) |
| Change the size of allocated memory. More...
|
|
PLATFORM_EXPORT void | ua_free (void *ptr) |
| Free allocated memory.
|
|
UA_WARN_UNUSED_RESULT PLATFORM_EXPORT char * | ua_strdup (const char *s) |
| Duplicate a zero terminated string. More...
|
|
PLATFORM_EXPORT void * | ua_memset (void *s, int c, size_t n) |
|
PLATFORM_EXPORT void * | ua_mem_clear_s (void *s, size_t n) |
| Clears n bytes from the memory area s . More...
|
|
PLATFORM_EXPORT int | ua_memcmp (const void *s1, const void *s2, size_t n) |
| Compares n bytes from the memory area s1 and s2 . More...
|
|
PLATFORM_EXPORT void * | ua_memmove (void *dest, const void *src, size_t n) |
| The ua_memmove() function copies n bytes from memory area src to memory area dest . More...
|
|
PLATFORM_EXPORT void * | ua_memmem (const void *haystack, size_t haystacklen, const void *needle, size_t needlelen) |
| The ua_memmem() function finds the start of the first occurence of the substring c needle of length needlelen in the memory area haystack of the length haystacklen . More...
|
|
PLATFORM_EXPORT void * | ua_memcpy (void *dest, const void *src, size_t n) |
| Copy n bytes from the memory area src to dest . More...
|
|
PLATFORM_EXPORT void * | ua_mempcpy (void *dest, const void *src, size_t n) |
| Copy n bytes from the memory area src to dest . More...
|
|
Wrapper for common memory operations.
In case a platform doesn't support standard malloc or has an optimized version of memset it can be forwarded to the custom implementation.
◆ ua_calloc()
Allocate memory for an array of elements.
The memory is set to zero.
- Parameters
-
nmemb | Number of elements to allocate. |
size | Size of one element. |
- Returns
- Pointer to allocated memory or NULL on failure.
◆ ua_malloc()
Allocate memory.
- Parameters
-
size | Number of bytes to allocate. |
- Returns
- Pointer to allocated memory or NULL on failure.
◆ ua_mem_clear_s()
PLATFORM_EXPORT void* ua_mem_clear_s |
( |
void * |
s, |
|
|
size_t |
n |
|
) |
| |
Clears n
bytes from the memory area s
.
- Parameters
-
s | Pointer to the start of the to be cleaned memory area. |
n | Number of bytes to be cleared. |
◆ ua_memcmp()
PLATFORM_EXPORT int ua_memcmp |
( |
const void * |
s1, |
|
|
const void * |
s2, |
|
|
size_t |
n |
|
) |
| |
Compares n
bytes from the memory area s1
and s2
.
- Parameters
-
s1 | Pointer to the start of the first memory area to be compared. |
s2 | Pointer to the start of the second memory area to be compared. |
n | Number of bytes to be compared. |
◆ ua_memcpy()
PLATFORM_EXPORT void* ua_memcpy |
( |
void * |
dest, |
|
|
const void * |
src, |
|
|
size_t |
n |
|
) |
| |
Copy n
bytes from the memory area src
to dest
.
The memory areas must not overlap.
- Parameters
-
dest | Pointer to the destination memory. |
src | Pointer to the source memory. |
n | Number of bytes to be copied. |
- Returns
- Pointer to the byte after the last written byte of
dest
.
◆ ua_memmem()
PLATFORM_EXPORT void* ua_memmem |
( |
const void * |
haystack, |
|
|
size_t |
haystacklen, |
|
|
const void * |
needle, |
|
|
size_t |
needlelen |
|
) |
| |
The ua_memmem() function finds the start of the first occurence of the substring c needle of length needlelen
in the memory area haystack
of the length haystacklen
.
- Returns
- Pointer to the beginning of the substring, or NULL if the substring is not found.
◆ ua_memmove()
PLATFORM_EXPORT void* ua_memmove |
( |
void * |
dest, |
|
|
const void * |
src, |
|
|
size_t |
n |
|
) |
| |
The ua_memmove() function copies n
bytes from memory area src
to memory area dest
.
The memory areas may overlap: copying takes place as though the bytes in src
are first copied into a temporary array that does not overlap src
or dest
, and the bytes are then copied from the temporary array to dest.
◆ ua_mempcpy()
PLATFORM_EXPORT void* ua_mempcpy |
( |
void * |
dest, |
|
|
const void * |
src, |
|
|
size_t |
n |
|
) |
| |
Copy n
bytes from the memory area src
to dest
.
The memory areas must not overlap.
- Returns
- Pointer to the byte after the last written byte of
dest
.
◆ ua_realloc()
Change the size of allocated memory.
- Parameters
-
ptr | Pointer to previously allocated memory. |
size | Number of bytes to change memory size to. |
- Returns
- Pointer to the changed memory or NULL on failure.
◆ ua_strdup()
Duplicate a zero terminated string.
The memory for the duplicated is allocated with ua_malloc and must be freed with ua_free.
- Parameters
-
- Returns
- Pointer to duplicated string or NULL on failure.