aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Ankarström <john@ankarstrom.se>2022-08-13 23:44:31 +0200
committerJohn Ankarström <john@ankarstrom.se>2022-08-13 23:44:31 +0200
commit16c355664bf27e5ec4be5e58bd83d9d1a4752a20 (patch)
tree3c53ebdcf7c2fea5705a117575c1a015b04e1272
parent20db24893b3b2a816bf82954ae9bdef243278b4d (diff)
downloadEpisodeBrowser-16c355664bf27e5ec4be5e58bd83d9d1a4752a20.tar.gz
Strcpy: Use memcpy instead of strcpy_s.
-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)