diff options
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); } |