summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordimitri staessens <dimitri.staessens@ugent.be>2017-07-12 09:40:22 +0000
committerSander Vrijders <sander.vrijders@ugent.be>2017-07-12 09:40:22 +0000
commit35b8b38606721b16a2fff52046096b603d7718f7 (patch)
tree833d71da9123b256caa2450b8e5e5f7dda17b486
parentc9c788e4c8d3e16bb5b3a8fdbbfc234eaec93d04 (diff)
parente3c7beb6ea050abbb77da098bdd30a808a8cb2c2 (diff)
downloadouroboros-35b8b38606721b16a2fff52046096b603d7718f7.tar.gz
ouroboros-35b8b38606721b16a2fff52046096b603d7718f7.zip
Merged in dstaesse/ouroboros/be-list (pull request #525)
include: Use offsetof in list.h
-rw-r--r--include/ouroboros/list.h3
1 files changed, 2 insertions, 1 deletions
diff --git a/include/ouroboros/list.h b/include/ouroboros/list.h
index 8811e291..40627651 100644
--- a/include/ouroboros/list.h
+++ b/include/ouroboros/list.h
@@ -26,6 +26,7 @@
#include <stdbool.h>
#include <stdint.h>
+#include <stddef.h>
#include <sys/types.h>
struct list_head {
@@ -34,7 +35,7 @@ struct list_head {
};
#define list_entry(ptr, type, mbr) \
- ((type *)((uint8_t *)(ptr)-(size_t)(&((type *)0)->mbr)))
+ ((type *)((uint8_t *)(ptr) - offsetof(type, mbr)))
#define list_first_entry(ptr, type, mbr) \
list_entry((ptr)->nxt, type, mbr)