aboutsummaryrefslogtreecommitdiffstats
path: root/sway/list.c
diff options
context:
space:
mode:
authorLibravatar Drew DeVault <sir@cmpwn.com>2015-08-09 19:27:25 -0400
committerLibravatar Drew DeVault <sir@cmpwn.com>2015-08-09 19:27:25 -0400
commit22315865696264aeef296364c7fc420b972a10fb (patch)
tree97c2650060252b5966f9f6ec68b51e84e84e40be /sway/list.c
parentMerge pull request #3 from jdiez17/log_colors_option (diff)
downloadsway-22315865696264aeef296364c7fc420b972a10fb.tar.gz
sway-22315865696264aeef296364c7fc420b972a10fb.tar.zst
sway-22315865696264aeef296364c7fc420b972a10fb.zip
Implement splith/splitv
Ref #2
Diffstat (limited to 'sway/list.c')
-rw-r--r--sway/list.c8
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
30void 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
30void list_del(list_t *list, int index) { 38void 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));