-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathextra.c
71 lines (62 loc) · 1.58 KB
/
extra.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
61
62
63
64
65
66
67
68
69
70
71
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* extra.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: oltkache <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/04/20 20:54:01 by oltkache #+# #+# */
/* Updated: 2018/04/20 20:54:01 by oltkache ### ########.fr */
/* */
/* ************************************************************************** */
#include "ssl_des.h"
char *ft_strnew(size_t size)
{
char *res;
res = (char*)malloc(sizeof(char) * (size + 1));
if (!res)
return (NULL);
ft_memset(res, 0, size + 1);
return (res);
}
void ft_strdel(char **as)
{
while (as && *as)
{
free(*as);
*as = NULL;
}
}
void ft_memdel(void **ap)
{
while (ap && *ap)
{
free(*ap);
*ap = NULL;
}
}
int ft_strcmp(const char *s1, const char *s2)
{
int i;
i = 0;
while (s1[i] != '\0' || s2[i] != '\0')
{
if (s1[i] != s2[i])
{
if (ft_isascii(s1[i]) && ft_isascii(s2[i]))
return (s1[i] - s2[i]);
else
return (s2[i] - s1[i]);
}
++i;
}
return (0);
}
size_t ft_strlen(const char *str)
{
int i;
i = 0;
while (str[i])
++i;
return (i);
}