-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_memmove.c
More file actions
34 lines (31 loc) · 1.22 KB
/
Copy pathft_memmove.c
File metadata and controls
34 lines (31 loc) · 1.22 KB
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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memmove.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: marinago <marinago@student.42madrid.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/09/26 18:17:22 by marinago #+# #+# */
/* Updated: 2023/09/28 13:29:49 by marinago ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_memmove(void *dst, const void *src, size_t n)
{
unsigned char *dst2;
const unsigned char *src2;
dst2 = (unsigned char *)dst;
src2 = (const unsigned char *)src;
if (!src2 && !dst2 && n > 0)
return (0);
if (dst2 > src2)
{
while (n--)
{
dst2[n] = src2[n];
}
}
else
ft_memcpy(dst, src, n);
return (dst2);
}