Embedded Artistry Framework
Embedded Systems C++ Framework
Functions
strnlen.c File Reference
#include <string.h>
Include dependency graph for strnlen.c:

Functions

size_t strnlen (const char *str, size_t maxlen)
 Returns the length of the given null-terminated byte string. More...
 

Function Documentation

◆ strnlen()

size_t strnlen ( const char *  str,
size_t  maxlen 
)

Returns the length of the given null-terminated byte string.

Same as

See also
strlen, except that the function returns zero if str is a null pointer and returns maxlen if the null character was not found in the first maxlen bytes of str.

The behavior is undefined if str points to a character array which lacks the null character and the size of that character array < maxlen; in other words, an erroneous value of maxlen does not expose impending buffer overflow.

Parameters
strpointer to the null-terminated byte string to be examined
maxlenmaximum number of characters to examine
Returns
The length of the null-terminated byte string str on success, zero if str is a null pointer, maxlen if the null character was not found.

References cp.

Referenced by strncat(), strncpy(), and strnlen_test().

Here is the caller graph for this function: