-
Notifications
You must be signed in to change notification settings - Fork 2
/
ft_memmove.c
39 lines (35 loc) · 1.42 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memmove.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: adiaz-lo <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/11/21 10:58:49 by adiaz-lo #+# #+# */
/* Updated: 2020/01/13 09:43:22 by adiaz-lo ### ########.fr */
/* */
/* ************************************************************************** */
/*
** This function copies "n" bytes from the memory of "src" to "dest".
** Memories may overlap.
** First, the bytes in "src" are copied into a temporary array and then to
** "dest".
** For further information, please check the Standard C Library function
** 'memmove(void *dst, const void *src, size_t n)'
*/
#include "libft.h"
void *ft_memmove(void *dst, const void *src, size_t n)
{
char *tmp;
char *dest;
tmp = (char *)src;
dest = (char *)dst;
if (tmp < dest)
{
while (n--)
dest[n] = tmp[n];
}
else
ft_memcpy(dest, tmp, n);
return (dst);
}