diff options
author | ZyX <kp-pav@yandex.ru> | 2017-12-24 17:52:04 +0300 |
---|---|---|
committer | ZyX <kp-pav@yandex.ru> | 2017-12-24 17:52:24 +0300 |
commit | 7997147245da8c9e9fca4e1862d71bd6b28e1c06 (patch) | |
tree | 07da2e30b7240a69188f278ba394c048a069e644 /src/nvim/eval/typval.c | |
parent | 2923e8533d1e28f9e771d2b4a7d279bfa266a480 (diff) | |
download | rneovim-7997147245da8c9e9fca4e1862d71bd6b28e1c06.tar.gz rneovim-7997147245da8c9e9fca4e1862d71bd6b28e1c06.tar.bz2 rneovim-7997147245da8c9e9fca4e1862d71bd6b28e1c06.zip |
eval: Replace some tv_list_item_remove() calls
There is nothing wrong with them, just it is generally better to remove
a range then to remove items individually.
Diffstat (limited to 'src/nvim/eval/typval.c')
-rw-r--r-- | src/nvim/eval/typval.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/nvim/eval/typval.c b/src/nvim/eval/typval.c index 4f717250cd..5c9005595d 100644 --- a/src/nvim/eval/typval.c +++ b/src/nvim/eval/typval.c @@ -284,6 +284,23 @@ void tv_list_drop_items(list_T *const l, listitem_T *const item, l->lv_idx_item = NULL; } +/// Like tv_list_drop_items, but also frees all removed items +void tv_list_remove_items(list_T *const l, listitem_T *const item, + listitem_T *const item2) + FUNC_ATTR_NONNULL_ALL +{ + tv_list_drop_items(l, item, item2); + for(listitem_T *li = item;;) { + tv_clear(TV_LIST_ITEM_TV(li)); + listitem_T *const nli = li->li_next; + xfree(li); + if (li == item2) { + break; + } + li = nli; + } +} + /// Move items "item" to "item2" from list "l" to the end of the list "tgt_l" /// /// @param[out] l List to move from. |