diff options
author | Drew DeVault <[email protected]> | 2015-08-09 19:27:25 -0400 |
---|---|---|
committer | Drew DeVault <[email protected]> | 2015-08-09 19:27:25 -0400 |
commit | 22315865696264aeef296364c7fc420b972a10fb (patch) | |
tree | 97c2650060252b5966f9f6ec68b51e84e84e40be /sway/list.c | |
parent | 9f554b10bcdf0e74a517e9564ca9764be41d92c0 (diff) |
Implement splith/splitv
Ref #2
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) { list->items[list->length++] = item; } +void list_insert(list_t *list, int index, void *item) { + if (list->length == list->capacity) { + list->capacity += 10; + list->items = realloc(list->items, sizeof(void*) * list->capacity); + } + list->items[list->length++] = item; +} + void list_del(list_t *list, int index) { list->length--; memmove(&list->items[index], &list->items[index + 1], sizeof(void*) * (list->capacity - index - 1)); |