safec  3.0
Safe C Library - ISO TR24731 Bounds Checking Interface
memchr_s.c File Reference
#include "safe_mem_lib.h"
+ Include dependency graph for memchr_s.c:

Functions

EXPORT errno_t memchr_s (const void *restrict dest, rsize_t dlen, const int ch, void **result)
 Finds the first occurrence of ch (after conversion to unsigned char as if by (unsigned char)ch) in the null-terminated buffer pointed to by dest (each character interpreted as unsigned char). More...
 

Function Documentation

◆ memchr_s()

EXPORT errno_t memchr_s ( const void *restrict  dest,
rsize_t  dlen,
const int  ch,
void **  result 
)

Finds the first occurrence of ch (after conversion to unsigned char as if by (unsigned char)ch) in the null-terminated buffer pointed to by dest (each character interpreted as unsigned char).

Remarks
IMPLEMENTED IN
Parameters
[in]destpointer to buffer to compare against
[in]dlenlength of dest to search in
[in]chcharacter to search for
[out]resultpointer to result in dest
Precondition
Neither dest nor result shall be a null pointer.
dlen shall not be 0.
dlen shall not be greater than RSIZE_MAX_MEM.
ch shall not be greater than 255
Return values
EOKwhen successfully character found.
ESNULLPwhen dest/result is a NULL pointer
ESZEROLwhen dlen = 0
ESLEMAXwhen dlen > RSIZE_MAX_STR
ESLEMAXwhen ch > 255
ESNOTFNDwhen ch not found in dest
See also
strchr_s(), strspn_s(), strcspn_s(), strpbrk_s(), strstr_s()