mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-26 07:26:15 +01:00
glib: add internal G_CONTAINER_OF() macro
"container_of()" is a popular macro that works together with G_STRUCT_OFFSET()/offsetof(). For internal use only.
This commit is contained in:
parent
3c09257ea1
commit
501bdb51e4
@ -63,6 +63,18 @@ void __lsan_ignore_object (const void *p) __attribute__ ((weak));
|
||||
|
||||
#endif
|
||||
|
||||
/**
|
||||
* G_CONTAINER_OF:
|
||||
* @ptr: a pointer to a member @field of type @type.
|
||||
* @type: the type of the container in which @field is embedded.
|
||||
* @field: the name of the field in @type.
|
||||
*
|
||||
* Casts away constness of @ptr.
|
||||
*
|
||||
* Returns: a pointer to the container, so that "&(@container)->field == (@ptr)" holds.
|
||||
*/
|
||||
#define G_CONTAINER_OF(ptr, type, field) ((type *) G_STRUCT_MEMBER_P (ptr, -G_STRUCT_OFFSET (type, field)))
|
||||
|
||||
/*
|
||||
* g_leak_sanitizer_is_supported:
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user