From c8ba75c31c949d3b5e5ba44e389550ea10096c5d Mon Sep 17 00:00:00 2001 From: JozanLeClerc Date: Wed, 16 Sep 2020 21:09:14 +0200 Subject: Leak fix --- src/b_h.c | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) (limited to 'src/b_h.c') diff --git a/src/b_h.c b/src/b_h.c index c669fa6..3acee67 100644 --- a/src/b_h.c +++ b/src/b_h.c @@ -12,22 +12,43 @@ #include #include +#include #include #include "d_define.h" +#include "f_fail.h" #include "s_struct.h" #include "u_utils.h" -static void b_print_history_number(const char arg[]) +static void b_print_history(const char arg[], t_msh *msh) { + char *prev_hist; + char *tok; + uint32_t i; + (void)arg; + i = 1; + if (msh->prev_hist != NULL) + { + if ((prev_hist = ft_strdup(msh->prev_hist)) == NULL) + return ; + tok = ft_strtok(prev_hist, "\n"); + ft_printf("qwqwe\n"); + while (tok != NULL) + { + ft_printf("%-5u %s\n", i, tok); + i++; + tok = ft_strtok(NULL, "\n"); + } + ft_memdel((void*)&prev_hist); + } } static t_bool b_check_numeric(const char arg[]) { char *ptr; - ptr = arg; + ptr = (char*)arg; while (*ptr != C_NUL) { if (ft_isdigit(*ptr) == FALSE) @@ -57,7 +78,7 @@ uint8_t b_h(char *args[], t_msh *msh) } else { - b_print_history(*args); + b_print_history(*args, msh); } return (0); } -- cgit v1.2.3