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