Alexandre Julliard : msvcrt: Move the strncpy_s() implementation to string.c.

Alexandre Julliard julliard at winehq.org
Mon Jun 27 16:14:00 CDT 2022


Module: wine
Branch: master
Commit: 3514e65f261b74beba75be49e1f9b3b292d1e69b
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=3514e65f261b74beba75be49e1f9b3b292d1e69b

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Mon Jun 27 10:48:11 2022 +0200

msvcrt: Move the strncpy_s() implementation to string.c.

Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/msvcrt/heap.c   | 38 --------------------------------------
 dlls/msvcrt/string.c | 38 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 38 insertions(+), 38 deletions(-)

diff --git a/dlls/msvcrt/heap.c b/dlls/msvcrt/heap.c
index 049c4e0cd93..bf06c37e2c5 100644
--- a/dlls/msvcrt/heap.c
+++ b/dlls/msvcrt/heap.c
@@ -827,44 +827,6 @@ int CDECL wmemcpy_s(wchar_t *dest, size_t numberOfElements,
 }
 #endif
 
-/*********************************************************************
- *		strncpy_s (MSVCRT.@)
- */
-int CDECL strncpy_s(char *dest, size_t numberOfElements,
-        const char *src, size_t count)
-{
-    size_t i, end;
-
-    TRACE("(%p %Iu %s %Iu)\n", dest, numberOfElements, debugstr_a(src), count);
-
-    if(!count) {
-        if(dest && numberOfElements)
-            *dest = 0;
-        return 0;
-    }
-
-    if (!MSVCRT_CHECK_PMT(dest != NULL)) return EINVAL;
-    if (!MSVCRT_CHECK_PMT(src != NULL)) return EINVAL;
-    if (!MSVCRT_CHECK_PMT(numberOfElements != 0)) return EINVAL;
-
-    if(count!=_TRUNCATE && count<numberOfElements)
-        end = count;
-    else
-        end = numberOfElements-1;
-
-    for(i=0; i<end && src[i]; i++)
-        dest[i] = src[i];
-
-    if(!src[i] || end==count || count==_TRUNCATE) {
-        dest[i] = '\0';
-        return 0;
-    }
-
-    MSVCRT_INVALID_PMT("dest[numberOfElements] is too small", EINVAL);
-    dest[0] = '\0';
-    return EINVAL;
-}
-
 BOOL msvcrt_init_heap(void)
 {
     heap = HeapCreate(0, 0, 0);
diff --git a/dlls/msvcrt/string.c b/dlls/msvcrt/string.c
index 181a161481c..f0bfcbd591b 100644
--- a/dlls/msvcrt/string.c
+++ b/dlls/msvcrt/string.c
@@ -1268,6 +1268,44 @@ char* __cdecl strncpy(char *dst, const char *src, size_t len)
     return dst;
 }
 
+/******************************************************************
+ *                  strncpy_s (MSVCRT.@)
+ */
+int CDECL strncpy_s(char *dest, size_t numberOfElements,
+        const char *src, size_t count)
+{
+    size_t i, end;
+
+    TRACE("(%p %Iu %s %Iu)\n", dest, numberOfElements, debugstr_a(src), count);
+
+    if(!count) {
+        if(dest && numberOfElements)
+            *dest = 0;
+        return 0;
+    }
+
+    if (!MSVCRT_CHECK_PMT(dest != NULL)) return EINVAL;
+    if (!MSVCRT_CHECK_PMT(src != NULL)) return EINVAL;
+    if (!MSVCRT_CHECK_PMT(numberOfElements != 0)) return EINVAL;
+
+    if(count!=_TRUNCATE && count<numberOfElements)
+        end = count;
+    else
+        end = numberOfElements-1;
+
+    for(i=0; i<end && src[i]; i++)
+        dest[i] = src[i];
+
+    if(!src[i] || end==count || count==_TRUNCATE) {
+        dest[i] = '\0';
+        return 0;
+    }
+
+    MSVCRT_INVALID_PMT("dest[numberOfElements] is too small", EINVAL);
+    dest[0] = '\0';
+    return EINVAL;
+}
+
 /*********************************************************************
  *      strcpy (MSVCRT.@)
  */




More information about the wine-cvs mailing list