MIPS: Add relocation types
[glibc.git] / string / strnlen.c
blobdc23354ec8db08603a2700fa740efbc1821bb493
1 /* Find the length of STRING, but scan at most MAXLEN characters.
2 Copyright (C) 1991-2023 Free Software Foundation, Inc.
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; see the file COPYING.LIB. If
16 not, see <https://www.gnu.org/licenses/>. */
18 #include <string.h>
20 /* Find the length of S, but scan at most MAXLEN characters. If no
21 '\0' terminator is found in that many characters, return MAXLEN. */
23 #ifdef STRNLEN
24 # define __strnlen STRNLEN
25 #endif
27 size_t
28 __strnlen (const char *str, size_t maxlen)
30 const char *found = memchr (str, '\0', maxlen);
31 return found ? found - str : maxlen;
34 #ifndef STRNLEN
35 weak_alias (__strnlen, strnlen)
36 libc_hidden_def (__strnlen)
37 libc_hidden_def (strnlen)
38 #endif