[GDBserver] Replicate src dir in build dir
[deliverable/binutils-gdb.git] / libiberty / strnlen.c
CommitLineData
995b61fe
DD
1/* Portable version of strnlen.
2 This function is in the public domain. */
3
4/*
5
6@deftypefn Supplemental size_t strnlen (const char *@var{s}, size_t @var{maxlen})
7
8Returns the length of @var{s}, as with @code{strlen}, but never looks
9past 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}.
12
13@end deftypefn
14
15*/
16
17#include "config.h"
18
19#include <stddef.h>
20
21size_t
22strnlen (const char *s, size_t maxlen)
23{
24 size_t i;
25
26 for (i = 0; i < maxlen; ++i)
27 if (s[i] == '\0')
28 break;
29 return i;
30}
This page took 0.239228 seconds and 4 git commands to generate.