1 |
/* Find the length of STRING, but scan at most MAXLEN characters. |
/* Find the length of STRING, but scan at most MAXLEN characters. |
2 |
Copyright (C) 1996, 1997, 1998, 2000 Free Software Foundation, Inc. |
Copyright (C) 1996, 1997, 1998, 2000, 2001 Free Software Foundation, Inc. |
3 |
This file is part of the GNU C Library. |
This file is part of the GNU C Library. |
4 |
|
|
5 |
The GNU C Library is free software; you can redistribute it and/or |
The GNU C Library is free software; you can redistribute it and/or |
51 |
__strnlen (const char *string, size_t maxlen) |
__strnlen (const char *string, size_t maxlen) |
52 |
{ |
{ |
53 |
const char *end = memchr (string, '\0', maxlen); |
const char *end = memchr (string, '\0', maxlen); |
54 |
return end ? end - string : maxlen; |
return end ? (size_t) (end - string) : maxlen; |
55 |
} |
} |
56 |
#ifdef weak_alias |
#ifdef weak_alias |
57 |
weak_alias (__strnlen, strnlen) |
weak_alias (__strnlen, strnlen) |