diff options
author | Ryan Dwyer <RyanDwyer@users.noreply.github.com> | 2018-07-18 09:32:03 +1000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-07-18 09:32:03 +1000 |
commit | 8ce7e3b44eea0a270ecc35a9da2ae801aaf6bce1 (patch) | |
tree | 6badffb0c6ee33b4e23e914c4c9f9b39a625b5f3 /common/list.c | |
parent | 621d2666b1ac214c63628bbe0ac8f5d6485cb501 (diff) | |
parent | 48b911a4596f50b585a1073d32413236d9defb60 (diff) |
Merge branch 'master' into destroy-output-destroy-empty-workspaces
Diffstat (limited to 'common/list.c')
-rw-r--r-- | common/list.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/common/list.c b/common/list.c index 39cc10e1..66d52f70 100644 --- a/common/list.c +++ b/common/list.c @@ -2,6 +2,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include "log.h" list_t *create_list(void) { list_t *list = malloc(sizeof(list_t)); @@ -82,6 +83,20 @@ void list_swap(list_t *list, int src, int dest) { list->items[dest] = tmp; } +void list_move_to_end(list_t *list, void *item) { + int i; + for (i = 0; i < list->length; ++i) { + if (list->items[i] == item) { + break; + } + } + if (!sway_assert(i < list->length, "Item not found in list")) { + return; + } + list_del(list, i); + list_add(list, item); +} + static void list_rotate(list_t *list, int from, int to) { void *tmp = list->items[to]; |