]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: lists: Implement function to convert list => mt_list and mt_list => list
authorOlivier Houchard <ohouchard@haproxy.com>
Wed, 11 Mar 2020 13:57:52 +0000 (14:57 +0100)
committerOlivier Houchard <cognet@ci0.org>
Wed, 11 Mar 2020 16:10:40 +0000 (17:10 +0100)
Implement mt_list_to_list() and list_to_mt_list(), to be able to convert
from a struct list to a struct mt_list, and vice versa.
This is normally of no use, except for struct connection's list field, that
can go in either a struct list or a struct mt_list.

include/common/mini-clist.h

index a7b5a5dd87067e477e1006a21241931ec1502708..40baf5d2b5fc2fca32b689cf03ec44e10786b3f4 100644 (file)
@@ -662,4 +662,28 @@ struct cond_wordlist {
                        }                                                     \
            }),                                                               \
             &item->member != (list_head);)
+
+static __inline struct list *mt_list_to_list(struct mt_list *list)
+{
+       union {
+               struct mt_list *mt_list;
+               struct list *list;
+       } mylist;
+
+       mylist.mt_list = list;
+       return mylist.list;
+}
+
+static __inline struct mt_list *list_to_mt_list(struct list *list)
+{
+               union {
+               struct mt_list *mt_list;
+               struct list *list;
+       } mylist;
+
+       mylist.list = list;
+       return mylist.mt_list;
+
+}
+
 #endif /* _COMMON_MINI_CLIST_H */