summaryrefslogtreecommitdiff
path: root/src/common.c
diff options
context:
space:
mode:
authorPřemysl Janouch <p.janouch@gmail.com>2014-07-18 19:51:15 +0200
committerPřemysl Janouch <p.janouch@gmail.com>2014-07-18 19:51:15 +0200
commit43d34d2473917521376f7d56126779f941205105 (patch)
tree15cf7b276d5705923c4dda172786a9a347b98fe6 /src/common.c
parent353230b18ba7c8c225c3b23a759798558fabb7de (diff)
downloadxK-43d34d2473917521376f7d56126779f941205105.tar.gz
xK-43d34d2473917521376f7d56126779f941205105.tar.xz
xK-43d34d2473917521376f7d56126779f941205105.zip
Add a LIST_HEADER macro
To save us from specifying the `next' and `prev' pointers all the time. It's not perfect, just a tiny bit better.
Diffstat (limited to 'src/common.c')
-rw-r--r--src/common.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/common.c b/src/common.c
index 4b72e39..96548d9 100644
--- a/src/common.c
+++ b/src/common.c
@@ -254,7 +254,9 @@ xstrndup (const char *s, size_t n)
// --- Double-linked list helpers ----------------------------------------------
-// The links of the list need to have the members `prev' and `next'.
+#define LIST_HEADER(type) \
+ struct type *next; \
+ struct type *prev;
#define LIST_PREPEND(head, link) \
BLOCK_START \
@@ -562,8 +564,7 @@ error_propagate (struct error **destination, struct error *source)
struct str_map_link
{
- struct str_map_link *next; ///< The next link in a chain
- struct str_map_link *prev; ///< The previous link in a chain
+ LIST_HEADER (str_map_link)
void *data; ///< Payload
size_t key_length; ///< Length of the key without '\0'