aboutsummaryrefslogtreecommitdiff
path: root/src/compat
diff options
context:
space:
mode:
Diffstat (limited to 'src/compat')
-rw-r--r--src/compat/sanity.h6
-rw-r--r--src/compat/strnlen.cpp18
2 files changed, 21 insertions, 3 deletions
diff --git a/src/compat/sanity.h b/src/compat/sanity.h
index 7016ac0ab7..7f5bc1a4fb 100644
--- a/src/compat/sanity.h
+++ b/src/compat/sanity.h
@@ -2,10 +2,10 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#ifndef BITCON_COMPAT_SANITY_H
-#define BITCON_COMPAT_SANITY_H
+#ifndef BITCOIN_COMPAT_SANITY_H
+#define BITCOIN_COMPAT_SANITY_H
bool glibc_sanity_test();
bool glibcxx_sanity_test();
-#endif // BITCON_COMPAT_SANITY_H
+#endif // BITCOIN_COMPAT_SANITY_H
diff --git a/src/compat/strnlen.cpp b/src/compat/strnlen.cpp
new file mode 100644
index 0000000000..7f3e159887
--- /dev/null
+++ b/src/compat/strnlen.cpp
@@ -0,0 +1,18 @@
+// Copyright (c) 2009-2014 The Bitcoin developers
+// Distributed under the MIT software license, see the accompanying
+// file COPYING or http://www.opensource.org/licenses/mit-license.php.
+
+#if defined(HAVE_CONFIG_H)
+#include "config/bitcoin-config.h"
+#endif
+
+#include <cstring>
+
+#if HAVE_DECL_STRNLEN == 0
+size_t strnlen( const char *start, size_t max_len)
+{
+ const char *end = (const char *)memchr(start, '\0', max_len);
+
+ return end ? (size_t)(end - start) : max_len;
+}
+#endif // HAVE_DECL_STRNLEN