High Performance OPC UA Server SDK  1.7.1.383
memory

Wrapper for common memory operations. More...

Functions

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...
 

Detailed Description

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.

Function Documentation

◆ ua_calloc()

UA_WARN_UNUSED_RESULT PLATFORM_EXPORT void* ua_calloc ( size_t  nmemb,
size_t  size 
)

Allocate memory for an array of elements.

The memory is set to zero.

Parameters
nmembNumber of elements to allocate.
sizeSize of one element.
Returns
Pointer to allocated memory or NULL on failure.

◆ ua_malloc()

UA_WARN_UNUSED_RESULT PLATFORM_EXPORT void* ua_malloc ( size_t  size)

Allocate memory.

Parameters
sizeNumber 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
sPointer to the start of the to be cleaned memory area.
nNumber 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
s1Pointer to the start of the first memory area to be compared.
s2Pointer to the start of the second memory area to be compared.
nNumber 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
destPointer to the destination memory.
srcPointer to the source memory.
nNumber 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()

UA_WARN_UNUSED_RESULT PLATFORM_EXPORT void* ua_realloc ( void *  ptr,
size_t  size 
)

Change the size of allocated memory.

Parameters
ptrPointer to previously allocated memory.
sizeNumber of bytes to change memory size to.
Returns
Pointer to the changed memory or NULL on failure.

◆ ua_strdup()

UA_WARN_UNUSED_RESULT PLATFORM_EXPORT char* ua_strdup ( const char *  s)

Duplicate a zero terminated string.

The memory for the duplicated is allocated with ua_malloc and must be freed with ua_free.

Parameters
sString to duplicate
Returns
Pointer to duplicated string or NULL on failure.