mirror of
https://github.com/DreamMaoMao/maomaowm.git
synced 2026-07-05 00:06:20 -04:00
opt: Ensure that the client remains in the linked list until it is destroyed
This commit is contained in:
parent
634ca7a51c
commit
22ecd84225
6 changed files with 54 additions and 41 deletions
|
|
@ -205,4 +205,30 @@ void wl_list_swap(struct wl_list *l1, struct wl_list *l2) {
|
|||
tmp2_prev->next = l1;
|
||||
tmp2_next->prev = l1;
|
||||
}
|
||||
}
|
||||
|
||||
void wl_list_safe_reinsert_prev(struct wl_list *l1, struct wl_list *l2) {
|
||||
if (!l1 || !l2)
|
||||
return;
|
||||
if (l1 == l2)
|
||||
return;
|
||||
if (l1->prev == l2)
|
||||
return;
|
||||
|
||||
wl_list_remove(l2);
|
||||
wl_list_init(l2);
|
||||
wl_list_insert(l1->prev, l2);
|
||||
}
|
||||
|
||||
void wl_list_safe_reinsert_next(struct wl_list *l1, struct wl_list *l2) {
|
||||
if (!l1 || !l2)
|
||||
return;
|
||||
if (l1 == l2)
|
||||
return;
|
||||
if (l1->next == l2)
|
||||
return;
|
||||
|
||||
wl_list_remove(l2);
|
||||
wl_list_init(l2);
|
||||
wl_list_insert(l1, l2);
|
||||
}
|
||||
|
|
@ -12,4 +12,6 @@ char *join_strings(char *arr[], const char *sep);
|
|||
char *join_strings_with_suffix(char *arr[], const char *suffix,
|
||||
const char *sep);
|
||||
char *string_printf(const char *fmt, ...);
|
||||
void wl_list_swap(struct wl_list *l1, struct wl_list *l2);
|
||||
void wl_list_swap(struct wl_list *l1, struct wl_list *l2);
|
||||
void wl_list_safe_reinsert_prev(struct wl_list *l1, struct wl_list *l2);
|
||||
void wl_list_safe_reinsert_next(struct wl_list *l1, struct wl_list *l2);
|
||||
Loading…
Add table
Add a link
Reference in a new issue