1 /*
2  * Copyright (C) the libgit2 contributors. All rights reserved.
3  *
4  * This file is part of libgit2, distributed under the GNU GPL v2 with
5  * a Linking Exception. For full terms see the included COPYING file.
6  */
7 #ifndef INCLUDE_strlen_h__
8 #define INCLUDE_strlen_h__
9 
10 #if defined(__MINGW32__) || defined(__sun) || defined(__APPLE__) || defined(__MidnightBSD__) ||\
11 	(defined(_MSC_VER) && _MSC_VER < 1500)
12 #   define NO_STRNLEN
13 #endif
14 
15 #ifdef NO_STRNLEN
p_strnlen(const char * s,size_t maxlen)16 GIT_INLINE(size_t) p_strnlen(const char *s, size_t maxlen) {
17 	const char *end = memchr(s, 0, maxlen);
18 	return end ? (size_t)(end - s) : maxlen;
19 }
20 #else
21 #   define p_strnlen strnlen
22 #endif
23 
24 #endif
25