aboutsummaryrefslogtreecommitdiffstats
path: root/common/list.c
diff options
context:
space:
mode:
Diffstat (limited to 'common/list.c')
-rw-r--r--common/list.c15
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 @@
2#include <stdio.h> 2#include <stdio.h>
3#include <stdlib.h> 3#include <stdlib.h>
4#include <string.h> 4#include <string.h>
5#include "log.h"
5 6
6list_t *create_list(void) { 7list_t *create_list(void) {
7 list_t *list = malloc(sizeof(list_t)); 8 list_t *list = malloc(sizeof(list_t));
@@ -82,6 +83,20 @@ void list_swap(list_t *list, int src, int dest) {
82 list->items[dest] = tmp; 83 list->items[dest] = tmp;
83} 84}
84 85
86void list_move_to_end(list_t *list, void *item) {
87 int i;
88 for (i = 0; i < list->length; ++i) {
89 if (list->items[i] == item) {
90 break;
91 }
92 }
93 if (!sway_assert(i < list->length, "Item not found in list")) {
94 return;
95 }
96 list_del(list, i);
97 list_add(list, item);
98}
99
85static void list_rotate(list_t *list, int from, int to) { 100static void list_rotate(list_t *list, int from, int to) {
86 void *tmp = list->items[to]; 101 void *tmp = list->items[to];
87 102