fix leaks completion

This commit is contained in:
gwojda 2017-03-18 14:12:15 +01:00
parent 112e72d9ab
commit 01461bd036
5 changed files with 34 additions and 11 deletions

View file

@ -6,7 +6,7 @@
# By: wescande <wescande@student.42.fr> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2016/08/29 21:32:58 by wescande #+# #+# #
# Updated: 2017/03/18 11:24:18 by gwojda ### ########.fr #
# Updated: 2017/03/18 12:10:38 by gwojda ### ########.fr #
# #
# **************************************************************************** #

View file

@ -6,7 +6,7 @@
# By: jhalford <jack@crans.org> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2017/02/07 16:09:36 by jhalford #+# #+# #
# Updated: 2017/03/08 01:11:01 by ariard ### ########.fr #
# Updated: 2017/03/18 12:07:29 by gwojda ### ########.fr #
# #
# **************************************************************************** #
@ -17,9 +17,9 @@ AR = ar -rc
MKDIR = mkdir -p
RM = /bin/rm -rf
W_FLAGS = -Wall -Wextra
D_FLAGS =
V_FLAGS = -fvisibility=hidden
W_FLAGS = -Wall -Wextra -Werror
D_FLAGS = -g
V_FLAGS = -g
FLAGS = $(W_FLAGS) $(D_FLAGS) $(V_FLAGS)
DELTA = $$(echo "$$(tput cols)-47"|bc)

View file

@ -6,7 +6,7 @@
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/09 16:54:59 by gwojda #+# #+# */
/* Updated: 2017/03/16 08:27:55 by alao ### ########.fr */
/* Updated: 2017/03/18 14:04:24 by gwojda ### ########.fr */
/* */
/* ************************************************************************** */
@ -22,6 +22,8 @@ void c_seek_abs_path(t_comp *c, char *current_word)
int len;
len = ft_strrchr(c->rcmd, '/') - current_word + 1;
if (len < 0)
return ;
c->cpath = ft_strndup(current_word, len);
if (current_word[0] == '~')
{

View file

@ -6,7 +6,7 @@
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/08 17:20:01 by gwojda #+# #+# */
/* Updated: 2017/03/17 11:20:10 by gwojda ### ########.fr */
/* Updated: 2017/03/18 12:23:18 by gwojda ### ########.fr */
/* */
/* ************************************************************************** */
@ -38,6 +38,7 @@ static void c_replace_globbing(char **glob, size_t start)
free(ref_mid);
free(ref_next);
free(str);
ft_sstrfree(glob);
}
/*
@ -59,6 +60,28 @@ static int c_glob_pos(char *str, size_t pos)
return (pos);
}
/*
** check glob return and free
*/
static int c_check_glob(char **ss_glob, char *current_word,
unsigned char *glob_echap, size_t pos)
{
char *str;
str = data_singleton()->line.input;
free(current_word);
free(glob_echap);
if (!*ss_glob || !**ss_glob)
return (1);
if (!ft_strncmp(str + pos, *ss_glob, ft_strlen(*ss_glob)))
{
ft_sstrfree(ss_glob);
return (1);
}
return (0);
}
/*
** Match for globbing feature.
*/
@ -83,9 +106,7 @@ int c_glob_matching(void)
glob_echap = (unsigned char *)ft_strnew(ft_strlen(str) >> 3);
ft_bzero(glob_echap, ft_strlen(str) >> 3);
ss_glob = glob(current_word, glob_echap, glob_echap, 1);
free(current_word);
if (!*ss_glob || !**ss_glob ||
!ft_strncmp(str + pos, *ss_glob, ft_strlen(*ss_glob)))
if (c_check_glob(ss_glob, current_word, glob_echap, pos))
return (0);
c_replace_globbing(ss_glob, pos);
return (1);

View file

@ -6,7 +6,7 @@
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/14 10:56:08 by gwojda #+# #+# */
/* Updated: 2017/03/17 11:23:49 by gwojda ### ########.fr */
/* Updated: 2017/03/18 12:08:50 by gwojda ### ########.fr */
/* */
/* ************************************************************************** */