X-Git-Url: https://pd.if.org/git/?a=blobdiff_plain;f=functions%2Fwchar%2Fwmemcpy.c;fp=functions%2Fwchar%2Fwmemcpy.c;h=e864dbcd309a24837dd09f3869d109b6c4141b45;hb=14b5b78e19a79f590233caee7848e7cb19084088;hp=0000000000000000000000000000000000000000;hpb=41777e3d5dc655f59a8c3bcd071639e6878e853a;p=pdclib diff --git a/functions/wchar/wmemcpy.c b/functions/wchar/wmemcpy.c new file mode 100644 index 0000000..e864dbc --- /dev/null +++ b/functions/wchar/wmemcpy.c @@ -0,0 +1,39 @@ +/* wmemcpy( wchar_t *, const wchar_t *, size_t ) + + This file is part of the Public Domain C Library (PDCLib). + Permission is granted to use, modify, and / or redistribute at will. +*/ + +#include + +#ifndef REGTEST + +wchar_t * wmemcpy( wchar_t * _PDCLIB_restrict dest, + const wchar_t * _PDCLIB_restrict src, + size_t n ) +{ + wchar_t* rv = dest; + while ( n-- ) + { + *dest++ = *src++; + } + return rv; +} + +#endif + +#ifdef TEST +#include <_PDCLIB_test.h> + +int main( void ) +{ + wchar_t s[] = L"xxxxxxxxxxx"; + TESTCASE( wmemcpy( s, wabcde, 6 ) == s ); + TESTCASE( s[4] == L'e' ); + TESTCASE( s[5] == L'\0' ); + TESTCASE( wmemcpy( s + 5, wabcde, 5 ) == s + 5 ); + TESTCASE( s[9] == L'e' ); + TESTCASE( s[10] == L'x' ); + return TEST_RESULTS; +} +#endif