MT#55283 add "self" container alias

Useful in situation where a pointer is needed, e.g. in another container

Change-Id: I150f4957f128344fad4d832fa95e2554dcfb9cf3
pull/2092/head
Richard Fuchs 3 weeks ago
parent 679eaac570
commit a75430f3be

@ -15,14 +15,16 @@ static inline void g_queue_clear_full(GQueue *q, GDestroyNotify free_func) {
#define TYPED_GHASHTABLE_PROTO(type_name, key_type, value_type) \
typedef union type_name##_iter type_name##_iter; \
typedef union { \
typedef union type_name type_name; \
union type_name { \
GHashTable *ht; \
type_name *self; \
/* unused members to store the contained types */ \
key_type *__key; \
const key_type *__ckey; \
value_type *__value; \
type_name##_iter *__iter; \
} type_name; \
}; \
union type_name##_iter { \
GHashTableIter it; \
/* unused members to store the contained types */ \
@ -35,6 +37,10 @@ static inline void g_queue_clear_full(GQueue *q, GDestroyNotify free_func) {
if (h->ht) \
g_hash_table_destroy(h->ht); \
h->ht = NULL; \
} \
__attribute__((unused)) static inline void type_name##_destroy_self(type_name *h) { \
type_name hh = {.self = h}; \
g_hash_table_destroy(hh.ht); \
}

Loading…
Cancel
Save