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

Functions

errno_t strfirstdiff_s (const char *dest, rsize_t dmax, const char *src, rsize_t *index)
 Returns the index of the first character that is different between dest and src. More...
 

Function Documentation

◆ strfirstdiff_s()

errno_t strfirstdiff_s ( const char *  dest,
rsize_t  dmax,
const char *  src,
rsize_t index 
)

Returns the index of the first character that is different between dest and src.

Index is valid only for OK. The scanning stops at the first null 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]indexpointer to returned index to first difference
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 first difference, when the return code is OK
Return values
EOKwhen index to first diff is returned
ESNODIFFwhen no difference
ESNULLPwhen dest/src/index is NULL pointer
ESZEROLwhen dmax = 0
ESLEMAXwhen dmax > RSIZE_MAX_STR
See also
strfirstchar_s(), strfirstsame_s(), strlastchar_s(), strlastdiff_s(), strlastsame_s()