-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_strutil.c
60 lines (54 loc) · 1.65 KB
/
ft_strutil.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strutil.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: lpalacio <lpalacio@student.42madrid> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/09/16 18:58:57 by lpalacio #+# #+# */
/* Updated: 2022/09/23 19:41:52 by lpalacio ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void ft_bzero(void *s, size_t n)
{
ft_memset(s, 0, n);
}
void *ft_memcpy(void *dst, const void *src, size_t n)
{
char *buff;
const char *src_b;
buff = (char *)dst;
src_b = (const char *)src;
if (n > 0 && (dst != 0 || src != 0))
{
while (n--)
buff[n] = src_b[n];
}
return (dst);
}
void *ft_memmove(void *dst, const void *src, size_t len)
{
const char *src_buff;
char *dst_buff;
size_t i;
i = len;
dst_buff = (char *)dst;
src_buff = (const char *)src;
if (dst_buff == NULL && src_buff == NULL)
return (NULL);
else if (len > 0)
{
if (dst < src && (dst + len) > src)
{
while (len--)
dst_buff[i - len - 1] = src_buff[i - len - 1];
}
else if (dst != src)
{
while (len--)
dst_buff[len] = src_buff[len];
}
}
return (dst);
}