diff options
Diffstat (limited to 'sway/list.c')
-rw-r--r-- | sway/list.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/sway/list.c b/sway/list.c index 82d6c144..55052f85 100644 --- a/sway/list.c +++ b/sway/list.c | |||
@@ -27,6 +27,14 @@ void list_add(list_t *list, void *item) { | |||
27 | list->items[list->length++] = item; | 27 | list->items[list->length++] = item; |
28 | } | 28 | } |
29 | 29 | ||
30 | void list_insert(list_t *list, int index, void *item) { | ||
31 | if (list->length == list->capacity) { | ||
32 | list->capacity += 10; | ||
33 | list->items = realloc(list->items, sizeof(void*) * list->capacity); | ||
34 | } | ||
35 | list->items[list->length++] = item; | ||
36 | } | ||
37 | |||
30 | void list_del(list_t *list, int index) { | 38 | void list_del(list_t *list, int index) { |
31 | list->length--; | 39 | list->length--; |
32 | memmove(&list->items[index], &list->items[index + 1], sizeof(void*) * (list->capacity - index - 1)); | 40 | memmove(&list->items[index], &list->items[index + 1], sizeof(void*) * (list->capacity - index - 1)); |