From 200d59f91b71cd2e2fac444b8fa9598e9f7ee3f6 Mon Sep 17 00:00:00 2001 From: Pol Henarejos Date: Sun, 12 Oct 2025 18:47:34 +0200 Subject: [PATCH] ADd strlcpy when necessary. Signed-off-by: Pol Henarejos --- src/compat.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/compat.h b/src/compat.h index e2cb734..a8d784c 100644 --- a/src/compat.h +++ b/src/compat.h @@ -47,4 +47,23 @@ static void f(void) #endif +#include + +#ifdef _MSC_VER +#ifndef HAVE_STRLCPY +static inline size_t strlcpy(char *dst, const char *src, size_t size) +{ + size_t srclen = strlen(src); + + if (size != 0) { + size_t copylen = (srclen >= size) ? size - 1 : srclen; + memcpy(dst, src, copylen); + dst[copylen] = '\0'; + } + + return srclen; +} +#endif +#endif + #endif // _COMPAT_H