-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_memmove.c
36 lines (32 loc) · 1.38 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memmove.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: aviholai <aviholai@student.hive.fi> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/01/26 16:32:14 by aviholai #+# #+# */
/* Updated: 2022/02/08 15:12:05 by aviholai ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
/*
** 'Memmove()' (memory move) function copies 'len' bytes from string 'src' to
** string 'dst' and returns the 'dst'. The two strings may overlap;
** the copy is always done in a non-destructive manner.
*/
void *ft_memmove(void *dst, const void *src, size_t len)
{
unsigned char *tmp;
if (dst == NULL && src == NULL)
return (NULL);
if (src > dst)
ft_memcpy(dst, src, len);
else
{
tmp = (unsigned char *)dst;
while (len--)
tmp[len] = *(unsigned char *)(src + len);
}
return (dst);
}