]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
[Project] Add linked list reversal procedure
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 11 Jul 2019 14:49:29 +0000 (15:49 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 12 Jul 2019 14:18:17 +0000 (15:18 +0100)
contrib/uthash/utlist.h

index e4d9a4c23d7bc14163730250293a9f8423f20f39..6c72b9fb2ada01f6d8e955d1b405dc075214cb3f 100644 (file)
@@ -365,6 +365,15 @@ do {
   }                                                                                            \
 } while (0)
 
+#define LL_REVERSE2(head,next) do {                                                            \
+    LDECLTYPE(head) _cur = (head), _p = NULL, _n = NULL;                                       \
+    while(_cur != NULL) { _n = _cur->next; _cur->next = _p; _p = _cur; _cur = _n; }            \
+    (head) = _p;                                                                               \
+} while (0)
+
+#define LL_REVERSE(head)                                                                       \
+    LL_REVERSE2(head,next)
+
 /* Here are VS2008 replacements for LL_APPEND and LL_DELETE */
 #define LL_APPEND_VS2008(head,add)                                                             \
     LL_APPEND2_VS2008(head,add,next)