diff options
Diffstat (limited to 'src/ft_s_lcom.c')
-rw-r--r-- | src/ft_s_lcom.c | 15 |
1 files changed, 8 insertions, 7 deletions
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); } |