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

Functions

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

Function Documentation

◆ memrchr_s()

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

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

The terminating null character is considered to be a part of the string and can be found when searching for '\0'.

Remarks
IMPLEMENTED IN
Parameters
[in]destpointer to string to compare against
[in]dlenrestricted maximum length of dest
[in]chcharacter to search for
[out]resultpointer to char* 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_STR.
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
memrchr_s(), strchr_s(), memchr_s(), strspn_s(), strstr_s()