mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-21 08:07:01 +00:00

We need this from util.h and posix.h, but the latter includes common.h which includes util.h, which means p_strlen is not defined by the time we get to git__strndup(). Split the definition on p_strlen() off into its own header so we can use it in util.h.
24 lines
579 B
C
24 lines
579 B
C
/*
|
|
* Copyright (C) the libgit2 contributors. All rights reserved.
|
|
*
|
|
* This file is part of libgit2, distributed under the GNU GPL v2 with
|
|
* a Linking Exception. For full terms see the included COPYING file.
|
|
*/
|
|
#ifndef INCLUDE_strlen_h__
|
|
#define INCLUDE_strlen_h__
|
|
|
|
#if defined(__MINGW32__) || defined(__sun) || defined(__APPLE__)
|
|
# define NO_STRNLEN
|
|
#endif
|
|
|
|
#ifdef NO_STRNLEN
|
|
GIT_INLINE(size_t) p_strnlen(const char *s, size_t maxlen) {
|
|
const char *end = memchr(s, 0, maxlen);
|
|
return end ? (size_t)(end - s) : maxlen;
|
|
}
|
|
#else
|
|
# define p_strnlen strnlen
|
|
#endif
|
|
|
|
#endif
|