Change the addition for proper ordering
authorLukáš Jiřiště <gymnazium.jiriste@gmail.com>
Mon, 11 Mar 2024 13:39:21 +0000 (14:39 +0100)
committerLukáš Jiřiště <gymnazium.jiriste@gmail.com>
Mon, 11 Mar 2024 13:39:21 +0000 (14:39 +0100)
The boss addition relied on ft_vec_append which makes the new entry be
at the end. This messes with the ordering as added entries are ready to
be defeated hence should be at the top. This commit uses insert to
insert the new entry to the very top which conserves the ordering
property.

src/main.c

index 9afea1fadc5cf9cf5a49b895c79cb58717dbfbbe..6db370128deb1a9f601b45bd4d9aad1ac0a6ebfa 100644 (file)
@@ -292,7 +292,7 @@ void        carry_out_command(t_command *com, t_vec *database)
        else if (com->basic == basic_remove)
                ft_vec_erase(database, ind, free_entry);
        else if (com->basic == basic_add)
-               ft_vec_append(database, &com->entry);
+               ft_vec_insert(database, &com->entry, 0);
        else if (com->basic == basic_list)
        {
                if (com->entry.name == NULL)