This commit is contained in:
kinou 2020-12-11 18:42:06 +01:00
parent 08a499139a
commit 9c81396225
12 changed files with 36 additions and 33 deletions

View File

@ -6,7 +6,7 @@
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */ /* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2020/11/29 00:10:08 by apommier #+# #+# */ /* Created: 2020/11/29 00:10:08 by apommier #+# #+# */
/* Updated: 2020/11/29 17:04:06 by apommier ### ########.fr */ /* Updated: 2020/12/11 18:10:51 by apommier ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -15,9 +15,9 @@
int ft_isalnum(int c) int ft_isalnum(int c)
{ {
if (c <= 9 && c >= 0) if (c <= 9 && c >= 0)
return (c); return (1);
else if ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z')) else if ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z'))
return (c); return (1);
else else
return (0); return (0);
} }

View File

@ -6,7 +6,7 @@
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */ /* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2020/11/29 00:10:17 by apommier #+# #+# */ /* Created: 2020/11/29 00:10:17 by apommier #+# #+# */
/* Updated: 2020/12/11 15:44:14 by apommier ### ########.fr */ /* Updated: 2020/12/11 18:11:03 by apommier ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -15,7 +15,7 @@
int ft_isalpha(int c) int ft_isalpha(int c)
{ {
if ((c > 64 && c < 90) || (c > 96 && c < 122)) if ((c > 64 && c < 90) || (c > 96 && c < 122))
return (c); return (1);
else else
return (0); return (0);
} }

View File

@ -6,7 +6,7 @@
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */ /* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2020/11/29 00:10:30 by apommier #+# #+# */ /* Created: 2020/11/29 00:10:30 by apommier #+# #+# */
/* Updated: 2020/11/29 17:04:48 by apommier ### ########.fr */ /* Updated: 2020/12/11 18:11:18 by apommier ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -15,7 +15,7 @@
int ft_isascii(int c) int ft_isascii(int c)
{ {
if (c >= 0 && c <= 127) if (c >= 0 && c <= 127)
return (c); return (1);
else else
return (0); return (0);
} }

View File

@ -6,7 +6,7 @@
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */ /* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2020/11/29 00:10:39 by apommier #+# #+# */ /* Created: 2020/11/29 00:10:39 by apommier #+# #+# */
/* Updated: 2020/11/29 17:05:09 by apommier ### ########.fr */ /* Updated: 2020/12/11 18:11:30 by apommier ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -15,7 +15,7 @@
int ft_isdigit(int c) int ft_isdigit(int c)
{ {
if (c <= 9 && c >= 0) if (c <= 9 && c >= 0)
return (c); return (1);
else else
return (0); return (0);
} }

View File

@ -6,7 +6,7 @@
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */ /* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2020/11/29 00:10:55 by apommier #+# #+# */ /* Created: 2020/11/29 00:10:55 by apommier #+# #+# */
/* Updated: 2020/11/29 17:05:23 by apommier ### ########.fr */ /* Updated: 2020/12/11 18:11:43 by apommier ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -15,7 +15,7 @@
int ft_isprint(int c) int ft_isprint(int c)
{ {
if (c > 31 && c < 127) if (c > 31 && c < 127)
return (c); return (1);
else else
return (0); return (0);
} }

View File

@ -6,7 +6,7 @@
/* By: apommier <alexpomms@student.42.fr> +#+ +:+ +#+ */ /* By: apommier <alexpomms@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2020/12/09 19:58:04 by apommier #+# #+# */ /* Created: 2020/12/09 19:58:04 by apommier #+# #+# */
/* Updated: 2020/12/11 17:47:15 by apommier ### ########.fr */ /* Updated: 2020/12/11 18:39:14 by apommier ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -15,15 +15,14 @@
void ft_lstclear(t_list **lst, void (*del)(void*)) void ft_lstclear(t_list **lst, void (*del)(void*))
{ {
t_list *chr; t_list *chr;
t_list *chr2;
chr = *lst; chr = *lst;
while (chr) while (*lst)
{ {
chr2 = chr->next; chr = *lst->next;
del(chr->content); del(*lst->content);
free(chr); free(*lst);
chr = chr2; *lst = chr;
} }
lst = 0; lst = 0;
} }

View File

@ -6,7 +6,7 @@
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */ /* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2020/11/29 00:12:03 by apommier #+# #+# */ /* Created: 2020/11/29 00:12:03 by apommier #+# #+# */
/* Updated: 2020/12/11 18:04:45 by apommier ### ########.fr */ /* Updated: 2020/12/11 18:15:39 by apommier ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -21,7 +21,7 @@ void *ft_memcpy(void *dest, const void *src, size_t n)
i = 0; i = 0;
p = (unsigned char*)dest; p = (unsigned char*)dest;
p2 = (unsigned char*)src; p2 = (unsigned char*)src;
while (n > 0 && p[i] && p2[i]) while (n > 0 && p2[i])
{ {
n--; n--;
p[i] = p2[i]; p[i] = p2[i];

View File

@ -6,7 +6,7 @@
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */ /* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2020/11/29 00:12:14 by apommier #+# #+# */ /* Created: 2020/11/29 00:12:14 by apommier #+# #+# */
/* Updated: 2020/11/29 17:07:14 by apommier ### ########.fr */ /* Updated: 2020/12/11 18:20:38 by apommier ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -14,6 +14,8 @@
void *ft_memmove(void *dest, const void *src, size_t n) void *ft_memmove(void *dest, const void *src, size_t n)
{ {
if (!size || !dest || !src)
return (dest)
size_t i; size_t i;
i = 0; i = 0;
@ -21,7 +23,7 @@ void *ft_memmove(void *dest, const void *src, size_t n)
{ {
while (n) while (n)
{ {
((char*)dest)[n] = ((char*)src)[n]; ((unsigned char*)dest)[n] = ((unsigned char*)src)[n];
n--; n--;
} }
} }
@ -29,7 +31,7 @@ void *ft_memmove(void *dest, const void *src, size_t n)
{ {
while (i < n) while (i < n)
{ {
((char*)dest)[i] = ((char*)src)[i]; ((unsigned char*)dest)[i] = ((unsigned char*)src)[i];
i++; i++;
} }
} }

View File

@ -6,7 +6,7 @@
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */ /* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2020/11/29 00:12:32 by apommier #+# #+# */ /* Created: 2020/11/29 00:12:32 by apommier #+# #+# */
/* Updated: 2020/12/11 16:14:37 by apommier ### ########.fr */ /* Updated: 2020/12/11 18:23:01 by apommier ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -14,9 +14,9 @@
char *ft_strchr(const char *s, int c) char *ft_strchr(const char *s, int c)
{ {
char *str; unsigned char *str;
str = (char*)s; str = (unsigned char*)s;
while ((*str != c) || (*str != 0)) while ((*str != c) || (*str != 0))
str++; str++;
if (*str == c) if (*str == c)

View File

@ -6,7 +6,7 @@
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */ /* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2020/11/29 00:12:43 by apommier #+# #+# */ /* Created: 2020/11/29 00:12:43 by apommier #+# #+# */
/* Updated: 2020/11/29 17:10:17 by apommier ### ########.fr */ /* Updated: 2020/12/11 18:35:10 by apommier ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -20,7 +20,7 @@ char *ft_strdup(const char *s)
i = 0; i = 0;
while (s[i]) while (s[i])
i++; i++;
sdup = malloc(sizeof(char) * i); sdup = malloc(sizeof(char) * (i + 1));
if (sdup == 0) if (sdup == 0)
return (0); return (0);
i = 0; i = 0;
@ -29,5 +29,6 @@ char *ft_strdup(const char *s)
sdup[i] = s[i]; sdup[i] = s[i];
i++; i++;
} }
sdup[i] = 0;
return (sdup); return (sdup);
} }

View File

@ -6,7 +6,7 @@
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */ /* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2020/11/29 00:13:31 by apommier #+# #+# */ /* Created: 2020/11/29 00:13:31 by apommier #+# #+# */
/* Updated: 2020/11/29 17:14:21 by apommier ### ########.fr */ /* Updated: 2020/12/11 18:32:24 by apommier ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -24,5 +24,5 @@ int ft_strncmp(const char *s1, const char *s2, size_t n)
n--; n--;
i++; i++;
} }
return (0); return ((unsigned char)(s1[i] - s2[i]));
} }

View File

@ -6,7 +6,7 @@
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */ /* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2020/11/29 00:13:52 by apommier #+# #+# */ /* Created: 2020/11/29 00:13:52 by apommier #+# #+# */
/* Updated: 2020/12/11 16:15:25 by apommier ### ########.fr */ /* Updated: 2020/12/11 18:24:45 by apommier ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -16,8 +16,9 @@ char *ft_strrchr(const char *s, int c)
{ {
char *str; char *str;
char *last; char *last;
last = 0; if (!s)
return (0);
str = (char*)s; str = (char*)s;
while (*str != 0) while (*str != 0)
{ {