Fix memory leak in LinkedList.clear
authorJürg Billeter <j@bitron.ch>
Fri, 28 Jan 2011 17:28:49 +0000 (18:28 +0100)
committerJürg Billeter <j@bitron.ch>
Fri, 28 Jan 2011 17:30:14 +0000 (18:30 +0100)
Based on patch by Travis Reitter, fixes bug 639254.

gee/linkedlist.vala

index cc64f0b..9cb2d0b 100644 (file)
@@ -59,8 +59,7 @@ public class Gee.LinkedList<G> : AbstractList<G>, Queue<G>, Deque<G> {
        }
        
        ~LinkedList () {
-               while (_head != null)
-                       _remove_node (_head);
+               this.clear ();
        }
 
        /**
@@ -136,6 +135,10 @@ public class Gee.LinkedList<G> : AbstractList<G>, Queue<G>, Deque<G> {
         * {@inheritDoc}
         */
        public override void clear () {
+               while (_head != null) {
+                       _remove_node (_head);
+               }
+
                ++this._stamp;
                this._head = null;
                this._tail = null;