-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_memmove.c
42 lines (39 loc) · 1.36 KB
/
ft_memmove.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memmove.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ohachim <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/10/09 16:33:53 by ohachim #+# #+# */
/* Updated: 2018/10/21 19:20:48 by ohachim ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_memmove(void *dst, const void *src, size_t len)
{
char *dupst;
char *duprc;
const char *duprc1;
size_t looper;
duprc1 = (const char*)src;
looper = 0;
duprc = (char*)malloc(len);
if (duprc == NULL)
return (NULL);
dupst = ((char*)dst);
while (looper < len)
{
*(duprc + looper) = *(duprc1 + looper);
looper++;
}
looper = 0;
while (looper < len)
{
*(dupst + looper) = *(duprc + looper);
looper++;
}
free(duprc);
duprc = NULL;
return (dst);
}