summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaria Matejka <mq@ucw.cz>2023-01-31 14:30:35 +0100
committerMaria Matejka <mq@ucw.cz>2023-02-02 14:40:00 +0100
commit6e035a9a8c7c943ea5b58932a2bd4c9b733d91ff (patch)
tree2331eba2ba577c997bf70db625124939dc12a905
parente077d0e770f00c98f26ee6b3cdb7905bf9bea4c1 (diff)
Typed lists: shortcut for simple nodes
-rw-r--r--lib/tlists.h7
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/tlists.h b/lib/tlists.h
index e1ed79ea..1437e17e 100644
--- a/lib/tlists.h
+++ b/lib/tlists.h
@@ -147,9 +147,14 @@ static inline void TLIST_NAME(rem_node)(TLIST_LIST_STRUCT *list, TLIST_TYPE *nod
#error "You should first include lib/tlists.h without requesting a TLIST"
#endif
-#define TLIST_NODE(_name, _type) struct _name##_node { _type *next; _type *prev; }
+#define TLIST_NODE_CONTENTS(_type) { _type *next; _type *prev; }
+#define TLIST_NODE(_name, _type) struct _name##_node TLIST_NODE_CONTENTS(_type)
+#define TLIST_DEFAULT_NODE struct MACRO_CONCAT_AFTER(TLIST_PREFIX,_node) \
+ TLIST_NODE_CONTENTS(TLIST_TYPE) TLIST_ITEM
+
#define TLIST_LIST(_name) struct _name##_list
+
/* Use ->first and ->last to access HEAD and TAIL */
#define THEAD(_name, _list) (_list)->first
#define TTAIL(_name, _list) (_list)->last