]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
LinkedList: delete method cleanup parameter
authorTimePath <andrew.hardaker1995@gmail.com>
Sat, 5 Dec 2015 10:43:18 +0000 (21:43 +1100)
committerTimePath <andrew.hardaker1995@gmail.com>
Sat, 5 Dec 2015 10:43:18 +0000 (21:43 +1100)
qcsrc/lib/linkedlist.qh

index a4200122f473452e3c76c4d9ca40c7d71e89c939..19d72ac27e0a1209043b79e76d915d219cb3eeab 100644 (file)
@@ -45,7 +45,9 @@ entity LL_POP(LinkedList this)
        return e;
 }
 
-#define LL_DELETE(this) \
+#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 \
        { \
                LinkedList _ll = this; \
@@ -53,7 +55,9 @@ entity LL_POP(LinkedList this)
                while (_ll.ll_tail) \
                { \
                        entity it = LL_POP(_ll); \
-                       if (it) remove(it); \
+                       if (!it) continue; \
+                       dtor \
+                       remove(it); \
                } \
                this = NULL; \
        } \