Blame src/strnlen.h

Packit Service 20376f
/*
Packit Service 20376f
 * Copyright (C) the libgit2 contributors. All rights reserved.
Packit Service 20376f
 *
Packit Service 20376f
 * This file is part of libgit2, distributed under the GNU GPL v2 with
Packit Service 20376f
 * a Linking Exception. For full terms see the included COPYING file.
Packit Service 20376f
 */
Packit Service 20376f
#ifndef INCLUDE_strlen_h__
Packit Service 20376f
#define INCLUDE_strlen_h__
Packit Service 20376f
Packit Service 20376f
#if defined(__MINGW32__) || defined(__sun) || defined(__APPLE__) || defined(__MidnightBSD__) ||\
Packit Service 20376f
	(defined(_MSC_VER) && _MSC_VER < 1500)
Packit Service 20376f
#   define NO_STRNLEN
Packit Service 20376f
#endif
Packit Service 20376f
Packit Service 20376f
#ifdef NO_STRNLEN
Packit Service 20376f
GIT_INLINE(size_t) p_strnlen(const char *s, size_t maxlen) {
Packit Service 20376f
	const char *end = memchr(s, 0, maxlen);
Packit Service 20376f
	return end ? (size_t)(end - s) : maxlen;
Packit Service 20376f
}
Packit Service 20376f
#else
Packit Service 20376f
#   define p_strnlen strnlen
Packit Service 20376f
#endif
Packit Service 20376f
Packit Service 20376f
#endif