Module: wine Branch: master Commit: cbf5ad74fcf40a56788933d962cb157a0b3bacb8 URL: https://source.winehq.org/git/wine.git/?a=commit;h=cbf5ad74fcf40a56788933d96...
Author: Alexandre Julliard julliard@winehq.org Date: Wed Jun 29 11:52:23 2022 +0200
ntdll: Add memcpy_s and memmove_s.
Implementation copied from msvcrt.
Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/ntdll/ntdll.spec | 2 ++ dlls/ntdll/string.c | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+)
diff --git a/dlls/ntdll/ntdll.spec b/dlls/ntdll/ntdll.spec index 0cda13586f4..2a119c9a508 100644 --- a/dlls/ntdll/ntdll.spec +++ b/dlls/ntdll/ntdll.spec @@ -1581,7 +1581,9 @@ @ cdecl memchr(ptr long long) @ cdecl memcmp(ptr ptr long) @ cdecl memcpy(ptr ptr long) +@ cdecl memcpy_s(ptr long ptr long) @ cdecl memmove(ptr ptr long) +@ cdecl memmove_s(ptr long ptr long) @ cdecl memset(ptr long long) @ cdecl pow(double double) @ cdecl qsort(ptr long long ptr) diff --git a/dlls/ntdll/string.c b/dlls/ntdll/string.c index 1bea000b2bd..c0db6f832ef 100644 --- a/dlls/ntdll/string.c +++ b/dlls/ntdll/string.c @@ -142,6 +142,42 @@ void * __cdecl memmove( void *dst, const void *src, size_t n ) }
+/********************************************************************* + * memcpy_s (MSVCRT.@) + */ +errno_t __cdecl memcpy_s( void *dst, size_t len, const void *src, size_t count ) +{ + if (!count) return 0; + if (!dst) return EINVAL; + if (!src) + { + memset( dst, 0, len ); + return EINVAL; + } + if (count > len) + { + memset( dst, 0, len ); + return ERANGE; + } + memmove( dst, src, count ); + return 0; +} + + +/********************************************************************* + * memmove_s (MSVCRT.@) + */ +errno_t __cdecl memmove_s( void *dst, size_t len, const void *src, size_t count ) +{ + if (!count) return 0; + if (!dst) return EINVAL; + if (!src) return EINVAL; + if (count > len) return ERANGE; + memmove( dst, src, count ); + return 0; +} + + static inline void memset_aligned_32( unsigned char *d, uint64_t v, size_t n ) { unsigned char *end = d + n;