From 0ddc1f98883661f494e7d231432b6c1c81f7b205 Mon Sep 17 00:00:00 2001 From: TimePath Date: Sat, 5 Dec 2015 21:43:18 +1100 Subject: [PATCH] LinkedList: delete method cleanup parameter --- qcsrc/lib/linkedlist.qh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/qcsrc/lib/linkedlist.qh b/qcsrc/lib/linkedlist.qh index a4200122f..19d72ac27 100644 --- a/qcsrc/lib/linkedlist.qh +++ b/qcsrc/lib/linkedlist.qh @@ -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; \ } \ -- 2.39.2