diff options
author | JozanLeClerc <bousset.rudy@gmail.com> | 2020-04-21 16:40:06 +0200 |
---|---|---|
committer | JozanLeClerc <bousset.rudy@gmail.com> | 2020-04-21 16:40:06 +0200 |
commit | f10225a9f29c333d4d49db09f0bf33f034dc2fe2 (patch) | |
tree | 05902024ad2eaaea252af54d0849754bf9bc9151 | |
parent | Linked list works, not memdeling (diff) | |
download | 42-minishell-f10225a9f29c333d4d49db09f0bf33f034dc2fe2.tar.gz 42-minishell-f10225a9f29c333d4d49db09f0bf33f034dc2fe2.tar.bz2 42-minishell-f10225a9f29c333d4d49db09f0bf33f034dc2fe2.tar.xz 42-minishell-f10225a9f29c333d4d49db09f0bf33f034dc2fe2.tar.zst 42-minishell-f10225a9f29c333d4d49db09f0bf33f034dc2fe2.zip |
No more leaks
Diffstat (limited to '')
-rw-r--r-- | src/ft_m_loop.c | 1 | ||||
-rw-r--r-- | src/ft_p_lcom.c | 1 | ||||
-rw-r--r-- | src/ft_s_lcom.c | 15 |
3 files changed, 9 insertions, 8 deletions
diff --git a/src/ft_m_loop.c b/src/ft_m_loop.c index 3a44d05..10a4f5e 100644 --- a/src/ft_m_loop.c +++ b/src/ft_m_loop.c @@ -37,7 +37,6 @@ int32_t ft_memdel((void*)&line); ft_e_lcom(msh); ft_lcom_clear(&msh->curr); - /* TODO: memdel lcom - INSTALL VALGRIND */ } else { diff --git a/src/ft_p_lcom.c b/src/ft_p_lcom.c index f928f5d..15247a2 100644 --- a/src/ft_p_lcom.c +++ b/src/ft_p_lcom.c @@ -36,5 +36,6 @@ int8_t ft_lcom_add_back(&msh->curr, link); i++; } + ft_delwords(words); return (0); } diff --git a/src/ft_s_lcom.c b/src/ft_s_lcom.c index 8b61f69..67ad6a9 100644 --- a/src/ft_s_lcom.c +++ b/src/ft_s_lcom.c @@ -19,8 +19,8 @@ static int8_t ft_fill_lcom(char *words[], t_lcom **lcom) { - int64_t i; - int64_t j; + uint64_t i; + uint64_t j; i = 0; if (!((*lcom)->com = (char*)malloc((ft_strlen(words[0]) + 1) * @@ -29,21 +29,22 @@ static int8_t ft_strlcpy((*lcom)->com, words[0], ft_strlen(words[0]) + 1); while(words[i + 1]) i++; + if (!((*lcom)->args = (char**)malloc((i + 1) * sizeof(char*)))) + return (-1); + j = 0; if (i > 0) { - if (!((*lcom)->args = (char**)malloc((i + 1) * sizeof(char*)))) - return (-1); - j = -1; - while (++j < i) + while (j < i) { if (!((*lcom)->args[j] = (char*)malloc((ft_strlen(words[j + 1]) + 1) * sizeof(char)))) return (-1); ft_strlcpy((*lcom)->args[j], words[j + 1], ft_strlen(words[j + 1]) + 1); + j++; } - (*lcom)->args[j] = 0; } + (*lcom)->args[j] = 0; return (0); } |