]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - common.c
physics: fix and refactor unsticking
[xonotic/darkplaces.git] / common.c
index cf2fb248dd2737bc8bf22dd843aaaec88532f494..f4e459af3e104d8a883a3a1447f86f19f044fa2a 100644 (file)
--- a/common.c
+++ b/common.c
@@ -1345,7 +1345,8 @@ copy one byte at a time (even at -O3) and its advantage increases with string le
 #ifdef WIN32
        // memccpy() is standard in POSIX.1-2001, POSIX.1-2008, SVr4, 4.3BSD, C23.
        // Microsoft supports it, but apparently complains if we use it.
-       #pragma warning(disable : 4996)
+       #undef memccpy
+       #define memccpy _memccpy
 #endif
 
 /** Chain-copies a string with truncation and efficiency (compared to strlcat()).
@@ -1406,9 +1407,12 @@ size_t dp__strlcpy(char *dst, const char *src, size_t dsize, const char *func, u
  */
 size_t dp__strlcat(char *dst, const char *src, size_t dsize, const char *func, unsigned line)
 {
-       char *p = (char *)memchr(dst, '\0', dsize) ?: dst;
-       size_t offset = p - dst;
+       size_t offset;
+       char *p = (char *)memchr(dst, '\0', dsize);
 
+       if (!p)
+               p = dst;
+       offset = p - dst;
        return dp__strlcpy(p, src, dsize - offset, func, line) + offset;
 }