aboutsummaryrefslogtreecommitdiff
path: root/c/util.h
diff options
context:
space:
mode:
Diffstat (limited to 'c/util.h')
-rw-r--r--c/util.h8
1 files changed, 6 insertions, 2 deletions
diff --git a/c/util.h b/c/util.h
index 51fd020..d58301b 100644
--- a/c/util.h
+++ b/c/util.h
@@ -1,6 +1,8 @@
#ifndef UTIL_H
#define UTIL_H
+#include <algorithm>
+#include <cstring>
#include <memory>
/* Format static wide string. */
@@ -12,9 +14,11 @@ inline int Swprintf(wchar_t (&buf)[N], const wchar_t* const fmt, T... xs)
/* Copy to static narrow string buffer. */
template <size_t N>
-inline int Strcpy(char (&dst)[N], const char* const src)
+inline char* Strcpy(char (&dst)[N], const char* const src)
{
- return strcpy_s(dst, N, src);
+ memcpy(dst, src, std::min(N, strlen(src)));
+ dst[N-1] = 0;
+ return dst;
}
inline int Cmp(const int a, const int b)