From 2c4eedb94faa1b08bbd49a6642aa17a38744de05 Mon Sep 17 00:00:00 2001 From: Jack Halford Date: Tue, 21 Mar 2017 15:49:51 +0100 Subject: [PATCH] changed malloc, to ft_malloc. what have I done... --- 42sh/libft/Makefile | 1 + 42sh/libft/includes/libft.h | 4 +++- 42sh/libft/src/btree/btree_create_node.c | 4 ++-- 42sh/libft/src/btree/btree_map.c | 4 ++-- 42sh/libft/src/dlst/ft_dlstnew.c | 6 +++--- 42sh/libft/src/ft_printf/ft_conversion.c | 4 ++-- 42sh/libft/src/ft_printf/ft_printf.c | 2 +- 42sh/libft/src/ft_printf/ft_vprintf.c | 6 +++--- 42sh/libft/src/ft_printf/lib_fmt.c | 4 ++-- 42sh/libft/src/get_next_line/get_next_line.c | 2 +- 42sh/libft/src/lst/ft_lstmap.c | 4 ++-- 42sh/libft/src/lst/ft_lstnew.c | 4 ++-- 42sh/libft/src/mem/ft_memalloc.c | 4 ++-- 42sh/libft/src/mem/ft_realloc.c | 2 +- 42sh/libft/src/sstr/ft_sstradd.c | 2 +- 42sh/libft/src/sstr/ft_sstrdup.c | 4 ++-- 42sh/libft/src/str/ft_split_whitespaces.c | 6 +++--- 42sh/libft/src/str/ft_strdup.c | 4 ++-- 42sh/libft/src/str/ft_strdupchr.c | 2 +- 42sh/libft/src/str/ft_strduptr.c | 2 +- 42sh/libft/src/str/ft_strmap.c | 4 ++-- 42sh/libft/src/str/ft_strmapi.c | 4 ++-- 42sh/libft/src/str/ft_strnew.c | 4 ++-- 42sh/libft/src/str/ft_strsplit.c | 4 ++-- 42sh/libft/src/str/ft_strsub.c | 4 ++-- 42sh/libft/src/time/ft_mytime_get.c | 4 ++-- 42sh/libft/src/time/ft_time_isrecent.c | 2 +- 42sh/src/builtin/builtin_cd.c | 2 +- 42sh/src/builtin/builtin_exit.c | 5 ++--- 42sh/src/parser/tree_wrapper.c | 2 +- 30 files changed, 54 insertions(+), 52 deletions(-) diff --git a/42sh/libft/Makefile b/42sh/libft/Makefile index 66124ab9..726fddbc 100644 --- a/42sh/libft/Makefile +++ b/42sh/libft/Makefile @@ -121,6 +121,7 @@ math/ft_uitoa_base.c\ math/ft_ulltoa_base.c\ math/id.c\ mem/ft_bzero.c\ +mem/ft_malloc.c\ mem/ft_memalloc.c\ mem/ft_memccpy.c\ mem/ft_memchr.c\ diff --git a/42sh/libft/includes/libft.h b/42sh/libft/includes/libft.h index e34e6c54..55cd9537 100644 --- a/42sh/libft/includes/libft.h +++ b/42sh/libft/includes/libft.h @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/07 13:49:04 by jhalford #+# #+# */ -/* Updated: 2017/03/20 09:37:38 by jhalford ### ########.fr */ +/* Updated: 2017/03/21 15:44:51 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -14,6 +14,7 @@ # define LIBFT_H # include +# include # include # include # include @@ -64,6 +65,7 @@ int ft_vdprintf(int fd, const char *format, va_list ap); int ft_asprintf(char **ret, const char *format, ...); int ft_vasprintf(char **ret, const char *format, va_list ap); +void *ft_malloc(size_t size); void *ft_memset(void *b, int c, size_t len); void ft_bzero(void *s, size_t n); void *ft_memcpy(void *dst, const void *src, size_t n); diff --git a/42sh/libft/src/btree/btree_create_node.c b/42sh/libft/src/btree/btree_create_node.c index 53a90bf7..cc365537 100644 --- a/42sh/libft/src/btree/btree_create_node.c +++ b/42sh/libft/src/btree/btree_create_node.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/08/16 13:43:51 by jhalford #+# #+# */ -/* Updated: 2017/03/08 00:35:44 by ariard ### ########.fr */ +/* Updated: 2017/03/21 15:43:50 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -16,7 +16,7 @@ t_btree *btree_create_node(void const *item, size_t content_size) { t_btree *new; - if (!(new = (t_btree *)malloc(sizeof(t_btree)))) + if (!(new = (t_btree *)ft_malloc(sizeof(t_btree)))) return (NULL); new->left = 0; new->right = 0; diff --git a/42sh/libft/src/btree/btree_map.c b/42sh/libft/src/btree/btree_map.c index 42fd89a5..85439a1a 100644 --- a/42sh/libft/src/btree/btree_map.c +++ b/42sh/libft/src/btree/btree_map.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/08 11:50:46 by jhalford #+# #+# */ -/* Updated: 2017/03/20 14:09:06 by jhalford ### ########.fr */ +/* Updated: 2017/03/21 15:42:18 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -18,7 +18,7 @@ t_btree *btree_map(t_btree *root, void *(*f)(void *)) if (!root) return (NULL); - if (!(new = (t_btree *)malloc(sizeof(*new)))) + if (!(new = (t_btree *)ft_malloc(sizeof(*new)))) return (NULL); new->item = (*f)(root->item); new->left = btree_map(root->left, f); diff --git a/42sh/libft/src/dlst/ft_dlstnew.c b/42sh/libft/src/dlst/ft_dlstnew.c index f97ab6fb..411bffca 100644 --- a/42sh/libft/src/dlst/ft_dlstnew.c +++ b/42sh/libft/src/dlst/ft_dlstnew.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/07 13:27:20 by jhalford #+# #+# */ -/* Updated: 2016/12/07 17:35:12 by jhalford ### ########.fr */ +/* Updated: 2017/03/21 15:43:50 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -18,7 +18,7 @@ t_dlist *ft_dlstnew(void const *content, size_t content_size) if (!content) { - new = malloc(sizeof(*new)); + new = ft_malloc(sizeof(*new)); if (!new) return (NULL); new->content_size = 0; @@ -26,7 +26,7 @@ t_dlist *ft_dlstnew(void const *content, size_t content_size) } else { - new = (t_dlist *)malloc(sizeof(*new)); + new = (t_dlist *)ft_malloc(sizeof(*new)); if (!new) return (NULL); new->content_size = content_size; diff --git a/42sh/libft/src/ft_printf/ft_conversion.c b/42sh/libft/src/ft_printf/ft_conversion.c index 6303d971..99f0cc08 100644 --- a/42sh/libft/src/ft_printf/ft_conversion.c +++ b/42sh/libft/src/ft_printf/ft_conversion.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/07 13:31:48 by jhalford #+# #+# */ -/* Updated: 2017/03/20 15:50:57 by jhalford ### ########.fr */ +/* Updated: 2017/03/21 15:42:19 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -48,7 +48,7 @@ char *ft_char_conversion(t_fmt *fmt, va_list ap) char *ret; (void)fmt; - ret = (char *)malloc(sizeof(char) + 1); + ret = (char *)ft_malloc(sizeof(char) + 1); ret[0] = (char)va_arg(ap, int); ret[1] = '\0'; return (ret); diff --git a/42sh/libft/src/ft_printf/ft_printf.c b/42sh/libft/src/ft_printf/ft_printf.c index 2ec92b04..d81e505b 100644 --- a/42sh/libft/src/ft_printf/ft_printf.c +++ b/42sh/libft/src/ft_printf/ft_printf.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/07 13:33:27 by jhalford #+# #+# */ -/* Updated: 2017/03/21 15:20:08 by jhalford ### ########.fr */ +/* Updated: 2017/03/21 15:28:56 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/libft/src/ft_printf/ft_vprintf.c b/42sh/libft/src/ft_printf/ft_vprintf.c index 803d4f97..569efdf1 100644 --- a/42sh/libft/src/ft_printf/ft_vprintf.c +++ b/42sh/libft/src/ft_printf/ft_vprintf.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/20 15:52:57 by jhalford #+# #+# */ -/* Updated: 2017/03/21 15:19:56 by jhalford ### ########.fr */ +/* Updated: 2017/03/21 15:29:36 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -56,8 +56,8 @@ int ft_vasprintf(char **ret, const char *format, va_list ap) if (ft_fmtcalc(&final, &str, ap)) return (-1); } - else - final = ft_strjoin(final, (char[]){*str++, 0}); + else if (!(final = ft_strjoin(final, (char[]){*str++, 0}))) + return (-1); ft_strdel(&tmp); } *ret = final; diff --git a/42sh/libft/src/ft_printf/lib_fmt.c b/42sh/libft/src/ft_printf/lib_fmt.c index 59caf57a..28b7313d 100644 --- a/42sh/libft/src/ft_printf/lib_fmt.c +++ b/42sh/libft/src/ft_printf/lib_fmt.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/07 13:33:35 by jhalford #+# #+# */ -/* Updated: 2017/03/10 16:54:40 by jhalford ### ########.fr */ +/* Updated: 2017/03/21 15:42:19 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -16,7 +16,7 @@ t_fmt *ft_fmt_init(void) { t_fmt *fmt; - fmt = (t_fmt *)malloc(sizeof(t_fmt) + 1); + fmt = (t_fmt *)ft_malloc(sizeof(t_fmt) + 1); ft_bzero(fmt->flags, 6); ft_bzero(fmt->modifier, 3); fmt->conversion = '\0'; diff --git a/42sh/libft/src/get_next_line/get_next_line.c b/42sh/libft/src/get_next_line/get_next_line.c index f6462feb..3eed0dee 100644 --- a/42sh/libft/src/get_next_line/get_next_line.c +++ b/42sh/libft/src/get_next_line/get_next_line.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/15 13:12:06 by jhalford #+# #+# */ -/* Updated: 2017/03/21 13:16:15 by jhalford ### ########.fr */ +/* Updated: 2017/03/21 15:43:51 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/libft/src/lst/ft_lstmap.c b/42sh/libft/src/lst/ft_lstmap.c index c233eff0..e0edbbaa 100644 --- a/42sh/libft/src/lst/ft_lstmap.c +++ b/42sh/libft/src/lst/ft_lstmap.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/03 14:57:21 by jhalford #+# #+# */ -/* Updated: 2017/03/20 14:06:55 by jhalford ### ########.fr */ +/* Updated: 2017/03/21 15:42:19 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -18,7 +18,7 @@ t_list *ft_lstmap(t_list *lst, void *(*f)(void *)) if (!lst) return (NULL); - if (!(elem = (t_list *)malloc(sizeof(*elem)))) + if (!(elem = (t_list *)ft_malloc(sizeof(*elem)))) return (NULL); elem->content = (*f)(lst->content); elem->next = ft_lstmap(lst->next, f); diff --git a/42sh/libft/src/lst/ft_lstnew.c b/42sh/libft/src/lst/ft_lstnew.c index 17a43d6f..e72d9ab7 100644 --- a/42sh/libft/src/lst/ft_lstnew.c +++ b/42sh/libft/src/lst/ft_lstnew.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/29 15:57:38 by jhalford #+# #+# */ -/* Updated: 2017/03/20 12:23:44 by jhalford ### ########.fr */ +/* Updated: 2017/03/21 15:43:51 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -16,7 +16,7 @@ t_list *ft_lstnew(void const *content, size_t content_size) { t_list *new; - if (!(new = (t_list *)malloc(sizeof(*new)))) + if (!(new = (t_list *)ft_malloc(sizeof(*new)))) return (NULL); new->next = NULL; new->content_size = content_size; diff --git a/42sh/libft/src/mem/ft_memalloc.c b/42sh/libft/src/mem/ft_memalloc.c index e923d08b..6a4a1112 100644 --- a/42sh/libft/src/mem/ft_memalloc.c +++ b/42sh/libft/src/mem/ft_memalloc.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/03 14:57:25 by jhalford #+# #+# */ -/* Updated: 2017/03/06 15:41:01 by ariard ### ########.fr */ +/* Updated: 2017/03/21 15:43:51 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -17,7 +17,7 @@ void *ft_memalloc(size_t size) void *addr; size_t i; - addr = malloc(size); + addr = ft_malloc(size); if (addr == NULL) return (NULL); i = -1; diff --git a/42sh/libft/src/mem/ft_realloc.c b/42sh/libft/src/mem/ft_realloc.c index 5297a2b6..33f667a8 100644 --- a/42sh/libft/src/mem/ft_realloc.c +++ b/42sh/libft/src/mem/ft_realloc.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/11 17:37:53 by jhalford #+# #+# */ -/* Updated: 2016/12/09 18:31:03 by jhalford ### ########.fr */ +/* Updated: 2017/03/21 15:43:51 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/libft/src/sstr/ft_sstradd.c b/42sh/libft/src/sstr/ft_sstradd.c index 58aa0e32..c81a256d 100644 --- a/42sh/libft/src/sstr/ft_sstradd.c +++ b/42sh/libft/src/sstr/ft_sstradd.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/03 18:03:58 by jhalford #+# #+# */ -/* Updated: 2017/03/07 14:28:29 by ariard ### ########.fr */ +/* Updated: 2017/03/21 15:43:51 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/libft/src/sstr/ft_sstrdup.c b/42sh/libft/src/sstr/ft_sstrdup.c index e68e0d35..8517a125 100644 --- a/42sh/libft/src/sstr/ft_sstrdup.c +++ b/42sh/libft/src/sstr/ft_sstrdup.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/07 14:25:45 by jhalford #+# #+# */ -/* Updated: 2017/03/07 19:58:12 by ariard ### ########.fr */ +/* Updated: 2017/03/21 15:42:19 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -22,7 +22,7 @@ char **ft_sstrdup(char **list) size = 0; while (list[size]) size++; - cpy = (char **)malloc(sizeof(char *) * (size + 1)); + cpy = (char **)ft_malloc(sizeof(char *) * (size + 1)); while (*list) { cpy[i++] = ft_strdup(*list); diff --git a/42sh/libft/src/str/ft_split_whitespaces.c b/42sh/libft/src/str/ft_split_whitespaces.c index 4124878a..ed744d0d 100644 --- a/42sh/libft/src/str/ft_split_whitespaces.c +++ b/42sh/libft/src/str/ft_split_whitespaces.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/02/03 16:07:17 by jhalford #+# #+# */ -/* Updated: 2017/03/20 15:55:29 by jhalford ### ########.fr */ +/* Updated: 2017/03/21 15:42:19 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -20,7 +20,7 @@ char *ft_strdupi_w(char const *s) i = 0; while (s[i] && s[i] != ' ' && s[i] != '\t') i++; - str = (char *)malloc(sizeof(char) * (i + 1)); + str = (char *)ft_malloc(sizeof(char) * (i + 1)); if (str) { str[i--] = '\0'; @@ -59,7 +59,7 @@ char **ft_split_whitespaces(char const *s) str = NULL; if (!(s)) return (str); - str = (char **)malloc(sizeof(char *) * (ft_len_words(s) + 1)); + str = (char **)ft_malloc(sizeof(char *) * (ft_len_words(s) + 1)); i = 0; j = 0; if (!(str)) diff --git a/42sh/libft/src/str/ft_strdup.c b/42sh/libft/src/str/ft_strdup.c index bb3ade4b..556558f4 100644 --- a/42sh/libft/src/str/ft_strdup.c +++ b/42sh/libft/src/str/ft_strdup.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/07 14:25:41 by jhalford #+# #+# */ -/* Updated: 2017/03/20 08:27:05 by jhalford ### ########.fr */ +/* Updated: 2017/03/21 15:42:19 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -16,7 +16,7 @@ char *ft_strdup(const char *s1) { char *dup; - if (!s1 || !(dup = (char*)malloc(sizeof(*dup) * (ft_strlen(s1) + 1)))) + if (!s1 || !(dup = (char*)ft_malloc(sizeof(*dup) * (ft_strlen(s1) + 1)))) return (NULL); ft_strcpy(dup, s1); return (dup); diff --git a/42sh/libft/src/str/ft_strdupchr.c b/42sh/libft/src/str/ft_strdupchr.c index 97340f13..aee98aaf 100644 --- a/42sh/libft/src/str/ft_strdupchr.c +++ b/42sh/libft/src/str/ft_strdupchr.c @@ -6,7 +6,7 @@ /* By: ariard +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/07 11:01:15 by ariard #+# #+# */ -/* Updated: 2017/03/07 11:24:27 by ariard ### ########.fr */ +/* Updated: 2017/03/21 15:43:51 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/libft/src/str/ft_strduptr.c b/42sh/libft/src/str/ft_strduptr.c index ca2f1180..59cfd835 100644 --- a/42sh/libft/src/str/ft_strduptr.c +++ b/42sh/libft/src/str/ft_strduptr.c @@ -6,7 +6,7 @@ /* By: ariard +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/01/06 13:37:12 by ariard #+# #+# */ -/* Updated: 2017/03/07 12:41:20 by ariard ### ########.fr */ +/* Updated: 2017/03/21 15:43:52 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/libft/src/str/ft_strmap.c b/42sh/libft/src/str/ft_strmap.c index 295214f0..5c0353ae 100644 --- a/42sh/libft/src/str/ft_strmap.c +++ b/42sh/libft/src/str/ft_strmap.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/03 14:58:24 by jhalford #+# #+# */ -/* Updated: 2016/11/03 14:58:25 by jhalford ### ########.fr */ +/* Updated: 2017/03/21 15:42:19 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -19,7 +19,7 @@ char *ft_strmap(char const *s, char (*f)(char)) char *out; size = ft_strlen(s); - out = (char *)malloc(sizeof(char) * (size + 1)); + out = (char *)ft_malloc(sizeof(char) * (size + 1)); if (out == NULL) return (NULL); i = -1; diff --git a/42sh/libft/src/str/ft_strmapi.c b/42sh/libft/src/str/ft_strmapi.c index 0d6fab4c..7cc6d089 100644 --- a/42sh/libft/src/str/ft_strmapi.c +++ b/42sh/libft/src/str/ft_strmapi.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/03 14:58:28 by jhalford #+# #+# */ -/* Updated: 2016/11/03 14:58:29 by jhalford ### ########.fr */ +/* Updated: 2017/03/21 15:42:19 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -19,7 +19,7 @@ char *ft_strmapi(char const *s, char (*f)(unsigned int, char)) char *out; size = ft_strlen(s); - out = (char *)malloc(sizeof(char) * (size + 1)); + out = (char *)ft_malloc(sizeof(char) * (size + 1)); if (out == NULL) return (NULL); i = -1; diff --git a/42sh/libft/src/str/ft_strnew.c b/42sh/libft/src/str/ft_strnew.c index 56742a50..2e2ae1d6 100644 --- a/42sh/libft/src/str/ft_strnew.c +++ b/42sh/libft/src/str/ft_strnew.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/03 14:58:34 by jhalford #+# #+# */ -/* Updated: 2017/01/11 16:37:53 by jhalford ### ########.fr */ +/* Updated: 2017/03/21 15:42:19 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -17,7 +17,7 @@ char *ft_strnew(size_t size) char *addr; size_t i; - addr = (char *)malloc(size + 1); + addr = (char *)ft_malloc(size + 1); if (addr == NULL) return (NULL); i = -1; diff --git a/42sh/libft/src/str/ft_strsplit.c b/42sh/libft/src/str/ft_strsplit.c index 10323439..049aa7ed 100644 --- a/42sh/libft/src/str/ft_strsplit.c +++ b/42sh/libft/src/str/ft_strsplit.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/03 14:58:40 by jhalford #+# #+# */ -/* Updated: 2017/03/20 16:10:24 by jhalford ### ########.fr */ +/* Updated: 2017/03/21 15:42:19 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -49,7 +49,7 @@ char **ft_strsplit(char const *s, char c) int k; char **str2; - if (!s || !(str2 = (char **)malloc(sizeof(*str2) * + if (!s || !(str2 = (char **)ft_malloc(sizeof(*str2) * (ft_countwords(s, c) + 1)))) return (NULL); i = -1; diff --git a/42sh/libft/src/str/ft_strsub.c b/42sh/libft/src/str/ft_strsub.c index 3f6c31d0..0c3fb11b 100644 --- a/42sh/libft/src/str/ft_strsub.c +++ b/42sh/libft/src/str/ft_strsub.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/03 14:58:43 by jhalford #+# #+# */ -/* Updated: 2017/03/21 11:38:40 by gwojda ### ########.fr */ +/* Updated: 2017/03/21 15:42:19 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -17,7 +17,7 @@ char *ft_strsub(char const *s, unsigned int start, size_t len) char *out; size_t i; - if (!(out = (char *)malloc(sizeof(char) * (len + 1)))) + if (!(out = (char *)ft_malloc(sizeof(char) * (len + 1)))) return (NULL); i = -1; while (++i < len) diff --git a/42sh/libft/src/time/ft_mytime_get.c b/42sh/libft/src/time/ft_mytime_get.c index f222530e..ab8f25b3 100644 --- a/42sh/libft/src/time/ft_mytime_get.c +++ b/42sh/libft/src/time/ft_mytime_get.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/25 11:34:56 by jhalford #+# #+# */ -/* Updated: 2016/12/03 11:54:16 by jhalford ### ########.fr */ +/* Updated: 2017/03/21 15:42:19 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -17,7 +17,7 @@ t_mytime *ft_mytime_get(time_t epoch) char *date; t_mytime *time; - time = (t_mytime*)malloc(sizeof(*time)); + time = (t_mytime*)ft_malloc(sizeof(*time)); date = ctime(&epoch); date[ft_strlen(date) - 1] = 0; time->year = ft_isdigit(date[20]) ? diff --git a/42sh/libft/src/time/ft_time_isrecent.c b/42sh/libft/src/time/ft_time_isrecent.c index 04712152..ec195653 100644 --- a/42sh/libft/src/time/ft_time_isrecent.c +++ b/42sh/libft/src/time/ft_time_isrecent.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/03 18:01:04 by jhalford #+# #+# */ -/* Updated: 2016/11/25 11:43:52 by jhalford ### ########.fr */ +/* Updated: 2017/03/21 15:44:24 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/builtin/builtin_cd.c b/42sh/src/builtin/builtin_cd.c index f722ac76..1c1f8851 100644 --- a/42sh/src/builtin/builtin_cd.c +++ b/42sh/src/builtin/builtin_cd.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/03 11:57:53 by jhalford #+# #+# */ -/* Updated: 2017/03/21 15:23:49 by jhalford ### ########.fr */ +/* Updated: 2017/03/21 15:28:51 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/builtin/builtin_exit.c b/42sh/src/builtin/builtin_exit.c index f238a25a..f8ab3a61 100644 --- a/42sh/src/builtin/builtin_exit.c +++ b/42sh/src/builtin/builtin_exit.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/28 14:28:41 by jhalford #+# #+# */ -/* Updated: 2017/03/21 14:48:13 by jhalford ### ########.fr */ +/* Updated: 2017/03/21 15:49:14 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -25,8 +25,7 @@ int builtin_exit(const char *path, char *const av[], char *const envp[]) { notified = 1; if (has_stopped_job() || has_running_job()) - SH_ERR("There are running and/or stopped jobs"); - return (0); + return (SH_ERR("There are running and/or stopped jobs")); } if (av && av[1] && !ft_stris(av[1], ft_isdigit)) SH_ERR(EXITERR_0); diff --git a/42sh/src/parser/tree_wrapper.c b/42sh/src/parser/tree_wrapper.c index 51002717..93622211 100644 --- a/42sh/src/parser/tree_wrapper.c +++ b/42sh/src/parser/tree_wrapper.c @@ -6,7 +6,7 @@ /* By: ariard +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/02/15 18:57:44 by ariard #+# #+# */ -/* Updated: 2017/03/20 10:35:11 by jhalford ### ########.fr */ +/* Updated: 2017/03/21 15:46:51 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */