correction free history + crash potentiel sur la table de hash

This commit is contained in:
gwojda 2017-02-19 12:02:34 +01:00
parent 480c9810c9
commit 923ffa1ea0
5 changed files with 11 additions and 29 deletions

View file

@ -6,7 +6,7 @@
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/02/18 11:10:14 by gwojda #+# #+# */
/* Updated: 2017/02/18 16:35:34 by gwojda ### ########.fr */
/* Updated: 2017/02/19 10:59:19 by gwojda ### ########.fr */
/* */
/* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/02/18 11:32:18 by gwojda #+# #+# */
/* Updated: 2017/02/18 14:38:05 by gwojda ### ########.fr */
/* Updated: 2017/02/19 12:01:37 by gwojda ### ########.fr */
/* */
/* ************************************************************************** */
@ -25,5 +25,11 @@ int ft_hash_str(char *str)
id = id % MAX_HASH;
++i;
}
if (id < 0)
{
id *= -1;
id = id % MAX_HASH;
}
ft_printf("id = %d\n", id);
return (id);
}

View file

@ -6,7 +6,7 @@
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/01/25 14:09:39 by gwojda #+# #+# */
/* Updated: 2017/02/03 17:03:23 by gwojda ### ########.fr */
/* Updated: 2017/02/19 11:55:44 by gwojda ### ########.fr */
/* */
/* ************************************************************************** */
@ -44,12 +44,12 @@ void ft_realloc_str_history(char **str, size_t pos, int nb_his, int len)
if (new_str3)
{
new_str2 = ft_strjoin(new_str, new_str3);
free(new_str);
new_str3 = ft_strjoin(new_str2, (*str) + pos + len);
free(new_str2);
}
else
new_str3 = ft_strjoin(new_str, (*str) + pos + len);
free(new_str);
free(*str);
*str = new_str3;
}
@ -81,12 +81,12 @@ void ft_realloc_str_history_2(char **str, size_t pos, char *s)
if (new_str3)
{
new_str2 = ft_strjoin(new_str, new_str3);
free(new_str);
new_str3 = ft_strjoin(new_str2, (*str) + pos + ft_strlen(s) + 1);
free(new_str2);
}
else
new_str3 = ft_strjoin(new_str, (*str) + pos + ft_strlen(s) + 1);
free(new_str);
free(s);
free(*str);
*str = new_str3;

View file

@ -1,21 +0,0 @@
 shell_init.c 28 interactive shell settings
 main.c 88 start of shell JOBC is ON
 main.c 64 [hash -r] stack=[0] state=[4]
 token_print.c 29 13:[hash]
 token_print.c 29 13:[-r]
 main.c 64 [hash] stack=[0] state=[4]
 token_print.c 29 13:[hash]
 main.c 64 [ls] stack=[0] state=[4]
 token_print.c 29 13:[ls]
 main.c 64 [ls] stack=[0] state=[4]
 token_print.c 29 13:[ls]
 main.c 64 [grep] stack=[0] state=[4]
 token_print.c 29 13:[grep]
 main.c 64 [hash] stack=[0] state=[4]
 token_print.c 29 13:[hash]
 main.c 64 [hash -r] stack=[0] state=[4]
 token_print.c 29 13:[hash]
 token_print.c 29 13:[-r]
 main.c 64 [hash] stack=[0] state=[4]
 token_print.c 29 13:[hash]
 shell_exit.c 17 shell_exit()

View file

@ -1,3 +0,0 @@
 shell_init.c 28 interactive shell settings
 main.c 88 start of shell JOBC is ON
 shell_exit.c 17 shell_exit()