Fix ft_mat_insert_col by switching comparison sign
authorLukas Jiriste <ljiriste@student.42prague.com>
Mon, 6 May 2024 18:59:51 +0000 (20:59 +0200)
committerLukas Jiriste <ljiriste@student.42prague.com>
Mon, 6 May 2024 19:01:22 +0000 (21:01 +0200)
The function has to increase capacity in the case the matrix has
insufficient capacity (not the other way around...).

ft_arr/ft_mat_insert_col.c

index 9b92aeeb8c2a221bdd287ed61c32af549e3fc387..d75dae5f1f161a31412f5f0d9235803f4f2115b5 100644 (file)
@@ -6,7 +6,7 @@
 /*   By: ljiriste <ljiriste@student.42prague.com>   +#+  +:+       +#+        */
 /*                                                +#+#+#+#+#+   +#+           */
 /*   Created: 2023/12/12 08:57:22 by ljiriste          #+#    #+#             */
-/*   Updated: 2024/01/17 13:12:34 by ljiriste         ###   ########.fr       */
+/*   Updated: 2024/05/06 20:54:19 by ljiriste         ###   ########.fr       */
 /*                                                                            */
 /* ************************************************************************** */
 
@@ -85,7 +85,7 @@ t_arr_stat    ft_mat_insert_col(t_mat *mat, const t_vec *vec, size_t index)
        else if (mat->rows != vec->size)
                return (invalid_input);
        set_auxiliary_vars(mat, index, &cols_change, &move_index);
-       while ((mat->cols + cols_change) * mat->rows < mat->vec.capacity)
+       while ((mat->cols + cols_change) * mat->rows > mat->vec.capacity)
        {
                res = ft_vec_enlarge(&(mat->vec));
                if (res != success)