-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_memmove.c
39 lines (36 loc) · 1.4 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: rdragan <[email protected] +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/11/04 10:08:59 by rdragan #+# #+# */
/* Updated: 2022/11/04 10:32:22 by rdragan ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
/*
Copies 'len' bytes from src to destination.
The copy is done in a non-destructive manner.
@param src: source memory address.
@param dst: destination memory address.
@param n: Quantity of bytes.
*/
void *ft_memmove(void *dst, const void *src, size_t len)
{
unsigned char *ldst;
unsigned char *lsrc;
if ((!dst && !src))
return (NULL);
ldst = (unsigned char *)dst;
lsrc = (unsigned char *)src;
if (ldst > lsrc)
{
while (len--)
ldst[len] = lsrc[len];
}
else
ft_memcpy(ldst, lsrc, len);
return (ldst);
}