-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_memmove.c
38 lines (35 loc) · 1.28 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memmove.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: xle-baux <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/11/25 13:56:40 by xle-baux #+# #+# */
/* Updated: 2021/11/30 12:50:29 by xle-baux ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_memmove(void *dest, const void *src, size_t n)
{
size_t i;
char *buffer_dest;
const char *buffer_src;
i = 0;
if (dest == NULL && src == NULL)
return (NULL);
buffer_dest = dest;
buffer_src = src;
if (buffer_dest > buffer_src)
while (n-- > 0)
buffer_dest[n] = buffer_src[n];
else
{
while (i < n)
{
buffer_dest[i] = buffer_src[i];
i++;
}
}
return (dest);
}