Ver Fonte

fix(series): correct item count and ownership in pop_first

- Decrement n_items when removing the root node
- Use owned return to properly transfer ownership of the returned item
Billy Barrow há 1 semana atrás
pai
commit
bb6762edaa
1 ficheiros alterados com 2 adições e 1 exclusões
  1. 2 1
      src/lib/DataStructures/Series.vala

+ 2 - 1
src/lib/DataStructures/Series.vala

@@ -130,6 +130,7 @@ namespace Invercargill.DataStructures {
                     root = root->next;
                     item = old_root->value;
                     delete old_root;
+                    n_items--;
                     if(root == null) {
                         end = null;
                     }
@@ -138,7 +139,7 @@ namespace Invercargill.DataStructures {
             if(e != null) {
                 throw e;
             }
-            return item;
+            return (owned)item;
         }
 
         public void remove_first_where(Invercargill.PredicateDelegate<T> predicate) {