]> pd.if.org Git - pdclib/blob - functions/string/memcpy.c
Removed the $Name$ tags (not supported by SVN). Added $Id$ to Makefile / text files.
[pdclib] / functions / string / memcpy.c
1 /* $Id$ */
2
3 /* memcpy( void *, const void *, size_t )
4
5    This file is part of the Public Domain C Library (PDCLib).
6    Permission is granted to use, modify, and / or redistribute at will.
7 */
8
9 #include <string.h>
10
11 #ifndef REGTEST
12
13 void * memcpy( void * _PDCLIB_restrict s1, const void * _PDCLIB_restrict s2, size_t n )
14 {
15     char * dest = (char *) s1;
16     const char * src = (const char *) s2;
17     while ( n-- )
18     {
19         *dest++ = *src++;
20     }
21     return s1;
22 }
23
24 #endif
25
26 #ifdef TEST
27 #include <_PDCLIB_test.h>
28
29 int main( void )
30 {
31     char s[] = "xxxxxxxxxxx";
32     TESTCASE( memcpy( s, abcde, 6 ) == s );
33     TESTCASE( s[4] == 'e' );
34     TESTCASE( s[5] == '\0' );
35     TESTCASE( memcpy( s + 5, abcde, 5 ) == s + 5 );
36     TESTCASE( s[9] == 'e' );
37     TESTCASE( s[10] == 'x' );
38     return TEST_RESULTS;
39 }
40 #endif