From 5180d45c194e9b05a10713846731a312376a3bef Mon Sep 17 00:00:00 2001 From: TimePath Date: Sat, 5 Dec 2015 21:34:39 +1100 Subject: [PATCH] LinkedList: delete method --- qcsrc/lib/linkedlist.qh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/qcsrc/lib/linkedlist.qh b/qcsrc/lib/linkedlist.qh index 94d26e175..a4200122f 100644 --- a/qcsrc/lib/linkedlist.qh +++ b/qcsrc/lib/linkedlist.qh @@ -45,6 +45,20 @@ entity LL_POP(LinkedList this) return e; } +#define LL_DELETE(this) \ + do \ + { \ + LinkedList _ll = this; \ + assert(_ll); \ + while (_ll.ll_tail) \ + { \ + entity it = LL_POP(_ll); \ + if (it) remove(it); \ + } \ + this = NULL; \ + } \ + while (0) + #define LL_EACH(list, cond, body) \ do \ { \ -- 2.39.2