summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordimitri staessens <dimitri.staessens@ugent.be>2017-07-12 11:35:08 +0200
committerdimitri staessens <dimitri.staessens@ugent.be>2017-07-12 11:35:08 +0200
commite3c7beb6ea050abbb77da098bdd30a808a8cb2c2 (patch)
tree833d71da9123b256caa2450b8e5e5f7dda17b486
parent662eaf1b0be528020b10311fc9c130f4039d4f81 (diff)
downloadouroboros-e3c7beb6ea050abbb77da098bdd30a808a8cb2c2.tar.gz
ouroboros-e3c7beb6ea050abbb77da098bdd30a808a8cb2c2.zip
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)