From: TimePath Date: Sat, 5 Dec 2015 10:49:57 +0000 (+1100) Subject: LinkedList: rebase delete method on clear X-Git-Tag: xonotic-v0.8.2~1545 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=2c2c6512bd90d0946077fb61911fa6021c5f0cf1;p=xonotic%2Fxonotic-data.pk3dir.git LinkedList: rebase delete method on clear --- diff --git a/qcsrc/lib/linkedlist.qh b/qcsrc/lib/linkedlist.qh index b2aabd229..3f57fdbc7 100644 --- a/qcsrc/lib/linkedlist.qh +++ b/qcsrc/lib/linkedlist.qh @@ -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)