-
Notifications
You must be signed in to change notification settings - Fork 87
API Reference
SYNOPSIS:
#include "safe_mem_lib.h"
errno_t
memcmp_s(const void *dest, rsize_t dmax,
const void *src, rsize_t smax, int *diff)
DESCRIPTION:
Compares memory until they differ, and their difference is returned in diff.
If the block of memory is the same, diff=0.
EXTENSION TO:
ISO/IEC JTC1 SC22 WG14 N1172, Programming languages, environments and system software
interfaces, Extensions to the C Library, Part I: Bounds-checking interfaces
INPUT PARAMETERS:
dest pointer to memory to compare against
dmax maximum length of dest, in bytess
src pointer to the source memory to compare with dest
smax length of the source memory block
diff pointer to the diff which is an integer greater than, equal to or less than zero according to
whether the object pointed to by dest is greater than, equal to or less than the object
pointed to by src.
OUTPUT PARAMETERS:
none
RUNTIME CONSTRAINTS:
- Neither dest nor src shall be a null pointer.
- Neither dmax nor smax shall be zero.
- dmax shall not be greater than RSIZE_MAX_MEM.
- smax shall not be greater than dmax.
RETURN VALUE:
- EOK successful operation
- ESNULLP NULL pointer
- ESZEROL zero length
- ESLEMAX length exceeds max limit
ALSO SEE:
memcmp16_s(), memcmp32_s()
###NAME: memcpy_s
SYNOPSIS:
#include "safe_mem_lib.h"
errno_t
memcpy_s(void *dest, rsize_t dmax, const void *src, rsize_t smax)
DESCRIPTION:
This function copies at most smax bytes from src to dest, up to dmax.
EXTENSION TO:
ISO/IEC JTC1 SC22 WG14 N1172, Programming languages, environments and system software
interfaces, Extensions to the C Library, Part I: Bounds-checking interfaces
INPUT PARAMETERS:
dest pointer to memory that will be replaced by src.
dmax maximum length of the resulting dest
src pointer to the memory that will be copied to dest
smax maximum number bytes of src to copy
OUTPUT PARAMETERS:
dest is updated
RUNTIME CONSTRAINTS:
- Neither dest nor src shall be a null pointer.
- Neither dmax nor smax shall be zero.
- dmax shall not be greater than RSIZE_MAX_MEM.
- smax shall not be greater than dmax.
- Copying shall not take place between regions that overlap.
- If there is a runtime-constraint violation, the memcpy_s function stores zeros in the �rst dmax bytes of the region pointed to by dest if dest is not a null pointer and smax is valid.
RETURN VALUE:
- EOK successful operation
- ESNULLP NULL pointer
- ESZEROL zero length
- ESLEMAX length exceeds max limit
- ESOVRLP source memory overlaps destination
ALSO SEE:
memcpy16_s(), memcpy32_s(), memmove_s(), memmove16_s(), memmove32_s()