memccpy_s
copies no more than n bytes from memory area src to memory area dest, stopping when the character c is found.
Throws error if the memory areas overlap. With SAFECLIB_STR_NULL_SLACK defined the rest (max. n bytes, not dmax) is cleared with NULL bytes.
- Parameters
-
[out] | dest | pointer to the memory that will be replaced by src. |
[in] | dmax | maximum length of the resulting dest, in bytes |
[in] | src | pointer to the memory that will be copied to dest |
[in] | c | character to be found |
[in] | n | maximum number bytes of src that can be copied |
- Precondition
- Neither dest nor src shall be a null pointer.
-
dmax shall not be 0.
-
dmax shall not be greater than RSIZE_MAX_MEM.
-
n shall not be greater than dmax.
-
Copying shall not take place between regions that overlap.
- Note
- from FreeBSD
- Returns
- The memccpy() function returns a pointer to the next character in dest after c, or NULL if c was not found in the first n characters of src. If there is a runtime-constraint violation, the memccpy_s function stores zeros in the first dmax bytes of the region pointed to by dest if dest is not a null pointer and n is valid.
- Return values
-
EOK | when operation is successful |
ESNULLP | when dest/src is NULL POINTER |
ESZEROL | when dmax = ZERO. Before C11 also with n = ZERO |
ESLEMAX | when dmax/n > RSIZE_MAX_MEM |
ESNOSPC | when dmax < n |
ESOVRLP | when src memory overlaps dst |
- See also
- memcpy_s(), strncpy_s()