mirror of
https://github.com/albfan/miraclecast.git
synced 2025-03-09 23:38:56 +00:00
shl: remove custom offsetof helpers
Use the generic shl_container_of() instead of all the custom helpers. Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
This commit is contained in:
parent
12bf5e026e
commit
4f55a01dc3
3 changed files with 7 additions and 14 deletions
|
|
@ -20,13 +20,7 @@
|
|||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
/* miscellaneous */
|
||||
|
||||
#define shl_dlist_offsetof(pointer, type, member) ({ \
|
||||
const typeof(((type*)0)->member) *__ptr = (pointer); \
|
||||
(type*)(((char*)__ptr) - offsetof(type, member)); \
|
||||
})
|
||||
#include "shl_macro.h"
|
||||
|
||||
/* double linked list */
|
||||
|
||||
|
|
@ -102,7 +96,7 @@ static inline struct shl_dlist *shl_dlist_last(struct shl_dlist *head)
|
|||
}
|
||||
|
||||
#define shl_dlist_entry(ptr, type, member) \
|
||||
shl_dlist_offsetof((ptr), type, member)
|
||||
shl_container_of((ptr), type, member)
|
||||
|
||||
#define shl_dlist_first_entry(head, type, member) \
|
||||
shl_dlist_entry(shl_dlist_first(head), type, member)
|
||||
|
|
|
|||
|
|
@ -24,13 +24,12 @@
|
|||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
#include "shl_macro.h"
|
||||
|
||||
/* miscellaneous */
|
||||
|
||||
#define shl_htable_offsetof(pointer, type, member) ({ \
|
||||
const typeof(((type*)0)->member) *__ptr = (pointer); \
|
||||
(type*)(((char*)__ptr) - offsetof(type, member)); \
|
||||
})
|
||||
#define shl_htable_entry(pointer, type, member) \
|
||||
shl_container_of((pointer), type, member)
|
||||
|
||||
/* htable */
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue