From 16c355664bf27e5ec4be5e58bd83d9d1a4752a20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Ankarstr=C3=B6m?= Date: Sat, 13 Aug 2022 23:44:31 +0200 Subject: Strcpy: Use memcpy instead of strcpy_s. --- c/util.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'c') 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 +#include #include /* 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 -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) -- cgit v1.2.3