#include <string.h>
#include <folly/Malloc.h>
+#include <folly/String.h>
#if FOLLY_HAVE_CPLUS_DEMANGLE_V3_CALLBACK
# include <cxxabi.h>
#endif
-namespace {
-
-// glibc doesn't have strlcpy
-size_t my_strlcpy(char* dest, const char* src, size_t size) {
- size_t len = strlen(src);
- if (size != 0) {
- size_t n = std::min(len, size - 1); // always null terminate!
- memcpy(dest, src, n);
- dest[n] = '\0';
- }
- return len;
-}
-
-} // namespace
-
namespace folly {
#if FOLLY_HAVE_CPLUS_DEMANGLE_V3_CALLBACK
demangleCallback,
&dbuf);
if (status == 0) { // failed, return original
- return my_strlcpy(out, name, outSize);
+ return folly::strlcpy(out, name, outSize);
}
if (outSize != 0) {
*dbuf.dest = '\0';
}
size_t demangle(const char* name, char* out, size_t outSize) {
- return my_strlcpy(out, name, outSize);
+ return folly::strlcpy(out, name, outSize);
}
#endif
}
}
+size_t strlcpy(char* dest, const char* const src, size_t size) {
+ size_t len = strlen(src);
+ if (size != 0) {
+ size_t n = std::min(len, size - 1); // always null terminate!
+ memcpy(dest, src, n);
+ dest[n] = '\0';
+ }
+ return len;
+}
+
namespace detail {
size_t hexDumpLine(const void* ptr, size_t offset, size_t size,
toLowerAscii(str.begin(), str.size());
}
+// glibc doesn't have strlcpy
+size_t strlcpy(char* dest, const char* const src, size_t size);
+
} // namespace folly
// Hook into boost's type traits