summaryrefslogtreecommitdiffstats
path: root/libft/src
diff options
context:
space:
mode:
authorJozanLeClerc <bousset.rudy@gmail.com>2020-09-29 19:11:10 +0200
committerJozanLeClerc <bousset.rudy@gmail.com>2020-09-29 19:11:10 +0200
commit462e664d0fdfbe2e9eae5c7e093c5a23b202dae8 (patch)
treecff5c7b5852874c8812bfa3dc04cc8df058a2238 /libft/src
parentSome norm (diff)
download42-minishell-462e664d0fdfbe2e9eae5c7e093c5a23b202dae8.tar.gz
42-minishell-462e664d0fdfbe2e9eae5c7e093c5a23b202dae8.tar.bz2
42-minishell-462e664d0fdfbe2e9eae5c7e093c5a23b202dae8.tar.xz
42-minishell-462e664d0fdfbe2e9eae5c7e093c5a23b202dae8.tar.zst
42-minishell-462e664d0fdfbe2e9eae5c7e093c5a23b202dae8.zip
Norm update
Diffstat (limited to 'libft/src')
-rw-r--r--libft/src/ft_itoa.c6
-rw-r--r--libft/src/ft_itoa_base.c8
-rw-r--r--libft/src/ft_itoa_s.c2
-rw-r--r--libft/src/ft_kernel_panic.c7
-rw-r--r--libft/src/ft_lstadd_back.c13
-rw-r--r--libft/src/ft_lstadd_front.c8
-rw-r--r--libft/src/ft_lstclear.c9
-rw-r--r--libft/src/ft_lstdelone.c5
-rw-r--r--libft/src/ft_lstiter.c7
-rw-r--r--libft/src/ft_lstlast.c9
-rw-r--r--libft/src/ft_lstmap.c7
-rw-r--r--libft/src/ft_lstnew.c7
-rw-r--r--libft/src/ft_lstsize.c5
-rw-r--r--libft/src/ft_memccpy.c10
-rw-r--r--libft/src/ft_memchr.c5
-rw-r--r--libft/src/ft_memcmp.c5
-rw-r--r--libft/src/ft_memcpy.c5
-rw-r--r--libft/src/ft_memdel.c3
-rw-r--r--libft/src/ft_memlchr.c3
-rw-r--r--libft/src/ft_memmove.c3
-rw-r--r--libft/src/ft_memset.c5
21 files changed, 69 insertions, 63 deletions
diff --git a/libft/src/ft_itoa.c b/libft/src/ft_itoa.c
index 255d0a8..2c0c14e 100644
--- a/libft/src/ft_itoa.c
+++ b/libft/src/ft_itoa.c
@@ -21,10 +21,12 @@ char *ft_itoa(long n)
uint8_t i;
i = ft_intlen(n) - 1;
- if (!(s = (char*)malloc((i + 2) * sizeof(char))))
+ if ((s = (char*)malloc((i + 2) * sizeof(char))) == NULL)
return (NULL);
- if (!n)
+ if (n == 0)
+ {
s[i] = '0';
+ }
nb = n;
if (n < 0)
{
diff --git a/libft/src/ft_itoa_base.c b/libft/src/ft_itoa_base.c
index f3abe46..2537161 100644
--- a/libft/src/ft_itoa_base.c
+++ b/libft/src/ft_itoa_base.c
@@ -11,19 +11,19 @@
/* ************************************************************************** */
#include <libft.h>
+#include <inttypes.h>
#include <stdlib.h>
-char
- *ft_itoa_base(long n, char *base)
+char *ft_itoa_base(long n, char *base)
{
char *s;
long nb;
uint8_t i;
i = ft_intlen_base(n, base) - 1;
- if (!(s = (char*)malloc((i + 2) * sizeof(char))))
+ if ((s = (char*)malloc((i + 2) * sizeof(char))) == NULL)
return (NULL);
- if (!n)
+ if (n == 0)
s[i] = '0';
if (n < 0)
{
diff --git a/libft/src/ft_itoa_s.c b/libft/src/ft_itoa_s.c
index 68b6ae3..a3469f3 100644
--- a/libft/src/ft_itoa_s.c
+++ b/libft/src/ft_itoa_s.c
@@ -19,7 +19,7 @@ void ft_itoa_s(char str[], long n)
uint8_t i;
i = ft_intlen(n) - 1;
- if (!n)
+ if (n == 0)
str[i] = '0';
nb = n;
if (n < 0)
diff --git a/libft/src/ft_kernel_panic.c b/libft/src/ft_kernel_panic.c
index 437a79a..980d4bc 100644
--- a/libft/src/ft_kernel_panic.c
+++ b/libft/src/ft_kernel_panic.c
@@ -13,12 +13,13 @@
#include <libft.h>
#include <stdlib.h>
-void
- ft_kernel_panic(void)
+void ft_kernel_panic(void)
{
- int *ptr;
+ int *ptr;
while (1)
+ {
ptr = (int *)ft_calloc((1024 * 1024) * sizeof(int), 1);
+ }
free(ptr);
}
diff --git a/libft/src/ft_lstadd_back.c b/libft/src/ft_lstadd_back.c
index 3f031ab..28065c2 100644
--- a/libft/src/ft_lstadd_back.c
+++ b/libft/src/ft_lstadd_back.c
@@ -13,15 +13,18 @@
#include <libft.h>
#include <stddef.h>
-void
- ft_lstadd_back(t_list **alst, t_list *new)
+void ft_lstadd_back(t_list **alst, t_list *new)
{
- t_list *tmp;
+ t_list *tmp;
- if (!alst || !new)
+ if (alst == NULL || new == NULL)
+ {
return ;
- if (!*alst)
+ }
+ if (*alst == NULL)
+ {
*alst = new;
+ }
else
{
tmp = ft_lstlast(*alst);
diff --git a/libft/src/ft_lstadd_front.c b/libft/src/ft_lstadd_front.c
index fac38cc..6e4e725 100644
--- a/libft/src/ft_lstadd_front.c
+++ b/libft/src/ft_lstadd_front.c
@@ -11,12 +11,14 @@
/* ************************************************************************** */
#include <libft.h>
+#include <stddef.h>
-void
- ft_lstadd_front(t_list **alst, t_list *new)
+void ft_lstadd_front(t_list **alst, t_list *new)
{
- if (!alst || !new)
+ if (alst == NULL || new == NULL)
+ {
return ;
+ }
new->next = *alst;
*alst = new;
}
diff --git a/libft/src/ft_lstclear.c b/libft/src/ft_lstclear.c
index 10a6d91..37fec4e 100644
--- a/libft/src/ft_lstclear.c
+++ b/libft/src/ft_lstclear.c
@@ -13,16 +13,17 @@
#include <libft.h>
#include <stdlib.h>
-void
- ft_lstclear(t_list **lst, void (*del)(void *))
+void ft_lstclear(t_list **lst, void (*del)(void *))
{
t_list *tmp;
t_list *renext;
- if (!lst)
+ if (lst == NULL)
+ {
return ;
+ }
tmp = *lst;
- while (tmp)
+ while (tmp != NULL)
{
renext = tmp->next;
del(tmp->content);
diff --git a/libft/src/ft_lstdelone.c b/libft/src/ft_lstdelone.c
index 3653e70..44d807e 100644
--- a/libft/src/ft_lstdelone.c
+++ b/libft/src/ft_lstdelone.c
@@ -13,10 +13,9 @@
#include <libft.h>
#include <stdlib.h>
-void
- ft_lstdelone(t_list *lst, void (*del)(void *))
+void ft_lstdelone(t_list *lst, void (*del)(void *))
{
- if (lst)
+ if (lst != NULL)
{
del(lst->content);
free(lst);
diff --git a/libft/src/ft_lstiter.c b/libft/src/ft_lstiter.c
index 72810c9..eff9736 100644
--- a/libft/src/ft_lstiter.c
+++ b/libft/src/ft_lstiter.c
@@ -13,11 +13,12 @@
#include <libft.h>
#include <stddef.h>
-void
- ft_lstiter(t_list *lst, void (*f)(void *))
+void ft_lstiter(t_list *lst, void (*f)(void *))
{
- if (!lst)
+ if (lst == NULL)
+ {
return ;
+ }
while (lst != NULL)
{
(*f)(lst->content);
diff --git a/libft/src/ft_lstlast.c b/libft/src/ft_lstlast.c
index 85a708b..cf86397 100644
--- a/libft/src/ft_lstlast.c
+++ b/libft/src/ft_lstlast.c
@@ -13,12 +13,15 @@
#include <libft.h>
#include <stddef.h>
-t_list
- *ft_lstlast(t_list *lst)
+t_list *ft_lstlast(t_list *lst)
{
- if (!lst)
+ if (lst == NULL)
+ {
return (NULL);
+ }
while (lst->next != NULL)
+ {
lst = lst->next;
+ }
return (lst);
}
diff --git a/libft/src/ft_lstmap.c b/libft/src/ft_lstmap.c
index b489527..cc2412e 100644
--- a/libft/src/ft_lstmap.c
+++ b/libft/src/ft_lstmap.c
@@ -14,16 +14,15 @@
#include <stddef.h>
#include <stdlib.h>
-t_list
- *ft_lstmap(t_list *lst, void *(*f)(void *), void (*del)(void *))
+t_list *ft_lstmap(t_list *lst, void *(*f)(void *), void (*del)(void *))
{
t_list *nlst;
t_list *new;
- if (!lst)
+ if (lst == NULL)
return (NULL);
nlst = ft_lstnew((*f)(lst->content));
- if (!nlst)
+ if (nlst == NULL)
return (NULL);
lst = lst->next;
while (lst != NULL)
diff --git a/libft/src/ft_lstnew.c b/libft/src/ft_lstnew.c
index 9f66691..bef0704 100644
--- a/libft/src/ft_lstnew.c
+++ b/libft/src/ft_lstnew.c
@@ -12,14 +12,15 @@
#include <libft.h>
-t_list
- *ft_lstnew(void *content)
+t_list *ft_lstnew(void *content)
{
t_list *nlst;
nlst = (t_list*)ft_calloc(1, sizeof(t_list));
- if (!nlst)
+ if (nlst == NULL)
+ {
return (NULL);
+ }
nlst->content = content;
nlst->next = NULL;
return (nlst);
diff --git a/libft/src/ft_lstsize.c b/libft/src/ft_lstsize.c
index 7134a9f..05dbb77 100644
--- a/libft/src/ft_lstsize.c
+++ b/libft/src/ft_lstsize.c
@@ -12,12 +12,11 @@
#include <libft.h>
-int
- ft_lstsize(t_list *lst)
+int ft_lstsize(t_list *lst)
{
int i;
- if (!lst)
+ if (lst == NULL)
return (0);
i = 0;
while (lst != NULL)
diff --git a/libft/src/ft_memccpy.c b/libft/src/ft_memccpy.c
index 70f8226..6f62231 100644
--- a/libft/src/ft_memccpy.c
+++ b/libft/src/ft_memccpy.c
@@ -11,21 +11,19 @@
/* ************************************************************************** */
#include <stddef.h>
-#include <stdio.h>
-void
- *ft_memccpy(void *dst, const void *src, int c, size_t n)
+void *ft_memccpy(void *dst, const void *src, int c, size_t n)
{
unsigned char *dst_ptr;
const unsigned char *src_ptr;
dst_ptr = (unsigned char*)dst;
src_ptr = (unsigned char*)src;
- if (!*dst_ptr && !*src_ptr && n)
+ if (*dst_ptr == '\0' && *src_ptr == '\0' && n != 0)
return (NULL);
- if (n)
+ if (n != 0)
{
- while (n)
+ while (n != 0)
{
if ((*dst_ptr++ = *src_ptr++) == (unsigned char)c)
return (dst_ptr);
diff --git a/libft/src/ft_memchr.c b/libft/src/ft_memchr.c
index 8917427..b85da16 100644
--- a/libft/src/ft_memchr.c
+++ b/libft/src/ft_memchr.c
@@ -12,8 +12,7 @@
#include <stddef.h>
-void
- *ft_memchr(const void *s, int c, size_t n)
+void *ft_memchr(const void *s, int c, size_t n)
{
unsigned char *s_ptr;
unsigned char c_char;
@@ -23,7 +22,9 @@ void
while (n > 0)
{
if (*s_ptr == c_char)
+ {
return ((void*)s_ptr);
+ }
s_ptr++;
n--;
}
diff --git a/libft/src/ft_memcmp.c b/libft/src/ft_memcmp.c
index 39fbdf6..5e1a0e9 100644
--- a/libft/src/ft_memcmp.c
+++ b/libft/src/ft_memcmp.c
@@ -12,15 +12,14 @@
#include <stddef.h>
-int
- ft_memcmp(const void *s1, const void *s2, size_t n)
+int ft_memcmp(const void *s1, const void *s2, size_t n)
{
const unsigned char *s1_ptr;
const unsigned char *s2_ptr;
s1_ptr = (unsigned char*)s1;
s2_ptr = (unsigned char*)s2;
- while (n)
+ while (n != 0)
{
if (*s1_ptr != *s2_ptr)
return (*s1_ptr - *s2_ptr);
diff --git a/libft/src/ft_memcpy.c b/libft/src/ft_memcpy.c
index 1357f2e..92abc47 100644
--- a/libft/src/ft_memcpy.c
+++ b/libft/src/ft_memcpy.c
@@ -14,8 +14,7 @@
#include <stddef.h>
#include <stdio.h>
-void
- *ft_memcpy(void *dst, const void *src, size_t n)
+void *ft_memcpy(void *dst, const void *src, size_t n)
{
unsigned char *dst_ptr;
unsigned char *src_ptr;
@@ -25,7 +24,9 @@ void
src_ptr = (unsigned char*)src;
i = 0;
if (src_ptr == NULL && dst_ptr == NULL && n != 0)
+ {
return (NULL);
+ }
while (i < n)
{
dst_ptr[i] = src_ptr[i];
diff --git a/libft/src/ft_memdel.c b/libft/src/ft_memdel.c
index 38d6e08..6a1aaef 100644
--- a/libft/src/ft_memdel.c
+++ b/libft/src/ft_memdel.c
@@ -12,8 +12,7 @@
#include <stdlib.h>
-void
- ft_memdel(void **ptr)
+void ft_memdel(void **ptr)
{
free(*ptr);
*ptr = NULL;
diff --git a/libft/src/ft_memlchr.c b/libft/src/ft_memlchr.c
index 643affc..b160ca5 100644
--- a/libft/src/ft_memlchr.c
+++ b/libft/src/ft_memlchr.c
@@ -13,8 +13,7 @@
#include <libft.h>
#include <stddef.h>
-long
- ft_memlchr(const void *s, int c, size_t n)
+long ft_memlchr(const void *s, int c, size_t n)
{
const size_t len = ft_strlen((const char *)s);
const size_t rem = ft_strlen((const char *)ft_memchr(s, c, n));
diff --git a/libft/src/ft_memmove.c b/libft/src/ft_memmove.c
index 1aa3588..ec672ef 100644
--- a/libft/src/ft_memmove.c
+++ b/libft/src/ft_memmove.c
@@ -13,8 +13,7 @@
#include <libft.h>
#include <stddef.h>
-void
- *ft_memmove(void *dst, const void *src, size_t len)
+void *ft_memmove(void *dst, const void *src, size_t len)
{
const char *from = (const char*)src;
char *to;
diff --git a/libft/src/ft_memset.c b/libft/src/ft_memset.c
index e53cf38..9cc645d 100644
--- a/libft/src/ft_memset.c
+++ b/libft/src/ft_memset.c
@@ -12,13 +12,12 @@
#include <stddef.h>
-void
- *ft_memset(void *b, int c, size_t len)
+void *ft_memset(void *b, int c, size_t len)
{
unsigned char *str;
str = b;
- if (!len)
+ if (len == 0)
return (b);
while (len > 0)
{