]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
LinkedList: rebase delete method on clear
authorTimePath <andrew.hardaker1995@gmail.com>
Sat, 5 Dec 2015 10:49:57 +0000 (21:49 +1100)
committerTimePath <andrew.hardaker1995@gmail.com>
Sat, 5 Dec 2015 10:49:57 +0000 (21:49 +1100)
qcsrc/lib/linkedlist.qh

index b2aabd22999d124d94f2552d8af6705effee0cf4..3f57fdbc7214872dfad24b4de2fb0d10480185a0 100644 (file)
@@ -45,9 +45,9 @@ entity LL_POP(LinkedList this)
        return e;
 }
 
-#define LL_DELETE(...) EVAL(OVERLOAD(LL_DELETE, __VA_ARGS__))
-#define LL_DELETE_1(this) LL_DELETE_2(this, LAMBDA())
-#define LL_DELETE_2(this, dtor) \
+#define LL_CLEAR(...) EVAL(OVERLOAD(LL_CLEAR, __VA_ARGS__))
+#define LL_CLEAR_1(this) LL_CLEAR_2(this, LAMBDA())
+#define LL_CLEAR_2(this, dtor) \
        do \
        { \
                LinkedList _ll = this; \
@@ -59,7 +59,16 @@ entity LL_POP(LinkedList this)
                        dtor \
                        remove(it); \
                } \
-               remove(_ll); \
+       } \
+       while (0)
+
+#define LL_DELETE(...) EVAL(OVERLOAD(LL_DELETE, __VA_ARGS__))
+#define LL_DELETE_1(this) LL_DELETE_2(this, LAMBDA())
+#define LL_DELETE_2(this, dtor) \
+       do \
+       { \
+               LL_CLEAR(this, dtor); \
+               remove(this); \
                this = NULL; \
        } \
        while (0)