mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2026-01-02 20:20:19 +01:00
util: add a list helper for handing a pointer to a list
Effectively a combination of list_append() and steal. Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1184>
This commit is contained in:
parent
76c87d2486
commit
829aec8055
1 changed files with 28 additions and 0 deletions
|
|
@ -80,6 +80,34 @@ void list_insert(struct list *list, struct list *elm);
|
|||
*/
|
||||
void list_append(struct list *list, struct list *elm);
|
||||
|
||||
/**
|
||||
* Takes the given pointer ands inserts it to the list with the pointer's field.
|
||||
* The pointer is reset to NULL. Use this to prevent automatic cleanup
|
||||
* of the pointer type.
|
||||
*
|
||||
* @code
|
||||
* list_take_insert(&f->list_of_bars, b, link);
|
||||
* @endcode
|
||||
*/
|
||||
#define list_take_insert(list_, ptr_, field_) do {\
|
||||
list_insert(list_, &(ptr_)->field_); \
|
||||
ptr_ = NULL; \
|
||||
} while(0)
|
||||
|
||||
/**
|
||||
* Takes the given pointer ands adds it to the list with the pointer's field.
|
||||
* The pointer is reset to NULL. Use this to prevent automatic cleanup
|
||||
* of the pointer type.
|
||||
*
|
||||
* @code
|
||||
* list_take_append(&f->list_of_bars, b, link);
|
||||
* @endcode
|
||||
*/
|
||||
#define list_take_append(list_, ptr_, field_) do {\
|
||||
list_append(list_, &(ptr_)->field_); \
|
||||
ptr_ = NULL; \
|
||||
} while(0)
|
||||
|
||||
/**
|
||||
* Remove an element from list.
|
||||
*
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue