2
This file is part of Warzone 2100.
3
Find the length of STRING + 1, but scan at most MAXLEN bytes.
4
Copyright (C) 2005-2006 Free Software Foundation, Inc.
6
Warzone 2100 is free software; you can redistribute it and/or modify
7
it under the terms of the GNU General Public License as published by
8
the Free Software Foundation; either version 2 of the License, or
9
(at your option) any later version.
11
Warzone 2100 is distributed in the hope that it will be useful,
12
but WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
GNU General Public License for more details.
16
You should have received a copy of the GNU General Public License
17
along with Warzone 2100; if not, write to the Free Software
18
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
22
$Id: strnlen1.c 2765 2007-11-09 23:27:03Z muggenhor $
23
$HeadURL: svn+ssh://per@svn.gna.org/svn/warzone/tags/2.1.3/lib/framework/strnlen1.c $
31
/* Find the length of STRING + 1, but scan at most MAXLEN bytes.
32
If no '\0' terminator is found in that many characters, return MAXLEN. */
33
/* This is the same as strnlen (string, maxlen - 1) + 1. */
34
size_t strnlen1(const char* string, size_t maxlen)
36
// Find the first NUL char
37
const char* end = memchr (string, '\0', maxlen);
40
return end - string + 1;