-
Notifications
You must be signed in to change notification settings - Fork 0
/
my_memcpy.c
52 lines (40 loc) · 1.14 KB
/
my_memcpy.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/*
* =====================================================================================
*
* Filename: my_memcpy.c
*
* Description: fucking memcpy
*
* Version: 1.0
* Created: 05/21/2012 06:25:03 PM
* Revision: none
* Compiler: gcc
*
* Author: Leajon First (ln), leajon.first@gmail.com
* Company: None
*
* =====================================================================================
*/
/*add some new fetch*/
#include <stdio.h>
#include <stdlib.h>
void *
my_memcpy ( void * des, void * src, size_t size )
{
size_t len = sizeof (double);
double * pdes = (double *) des;
double * psrc = (double *) src;
for (; size >= len; pdes++, psrc++, size -= len)
*pdes = *psrc;
for (len = size, size = 0; size < len; size++)
*((char *)pdes + size) = *((char *) psrc + size);
return des;
} /* ----- end of function my_memcpy ----- */
int
main ( int argc, char *argv[] )
{
char src[] = "Helloasdfsdfasdasdfsadfsfasdf", des[10] = {'\0'};
my_memcpy (des, src, 9);
printf ( "%s\n", des );
return EXIT_SUCCESS;
} /* ---------- end of function main ---------- */