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

Functions

EXPORT errno_t strlastsame_s (const char *dest, rsize_t dmax, const char *src, rsize_t *idx)
 Returns the index of the last character that is the same between dest and src. More...
 

Function Documentation

◆ strlastsame_s()

EXPORT errno_t strlastsame_s ( const char *  dest,
rsize_t  dmax,
const char *  src,
rsize_t idx 
)

Returns the index of the last character that is the same between dest and src.

The scanning stops at the first nul in dest or src, or after dmax characters.

Remarks
EXTENSION TO ISO/IEC TR 24731, Programming languages, environments and system software interfaces, Extensions to the C Library, Part I: Bounds-checking interfaces
Parameters
[in]destpointer to string to compare against
[in]dmaxrestricted maximum length of string dest
[in]srcpointer to the string to be compared to dest
[out]idxpointer to returned index
Precondition
Neither dest nor src shall be a null pointer.
indicator shall not be a null pointer.
dmax shall not be 0.
dmax shall not be greater than RSIZE_MAX_STR.
Returns
index to last same char, when the return code is OK
Return values
EOKwhen index to last same char is returned
ESNULLPwhen dst/src/idx is NULL pointer
ESZEROLwhen dmax = 0
ESLEMAXwhen dmax > RSIZE_MAX_STR
ESNOTFNDwhen not found
See also
strfirstchar_s(), strfirstdiff_s(), strfirstsame_s(), strlastchar_s(), strlastdiff_s()