Document the GDB 7.11 release in gdb/ChangeLog
[binutils-gdb.git] / libiberty / strnlen.c
blob4934973adcac15dce91f907915432b7e3b56fe9d
1 /* Portable version of strnlen.
2 This function is in the public domain. */
4 /*
6 @deftypefn Supplemental size_t strnlen (const char *@var{s}, size_t @var{maxlen})
8 Returns the length of @var{s}, as with @code{strlen}, but never looks
9 past the first @var{maxlen} characters in the string. If there is no
10 '\0' character in the first @var{maxlen} characters, returns
11 @var{maxlen}.
13 @end deftypefn
17 #include "config.h"
19 #include <stddef.h>
21 size_t
22 strnlen (const char *s, size_t maxlen)
24 size_t i;
26 for (i = 0; i < maxlen; ++i)
27 if (s[i] == '\0')
28 break;
29 return i;