aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFelipe Oliveira Carvalho <felipekde@gmail.com>2014-05-28 20:23:41 -0300
committerFelipe Oliveira Carvalho <felipekde@gmail.com>2014-06-16 01:31:35 -0300
commit129db629dd9e2911a191e23899d4c055df61fab5 (patch)
tree31ccebf68a0729af94101c2078a010629dc11b6e /src
parentdd57e647942ff7e468ef299f5873638b51ccaad4 (diff)
downloadrneovim-129db629dd9e2911a191e23899d4c055df61fab5.tar.gz
rneovim-129db629dd9e2911a191e23899d4c055df61fab5.tar.bz2
rneovim-129db629dd9e2911a191e23899d4c055df61fab5.zip
No OOM in list_insert_tv() and list_extend()
Diffstat (limited to 'src')
-rw-r--r--src/nvim/eval.c22
1 files changed, 8 insertions, 14 deletions
diff --git a/src/nvim/eval.c b/src/nvim/eval.c
index 440c5391cf..6d900683a9 100644
--- a/src/nvim/eval.c
+++ b/src/nvim/eval.c
@@ -5102,15 +5102,13 @@ static void list_append_number(list_T *l, varnumber_T n)
/*
* Insert typval_T "tv" in list "l" before "item".
* If "item" is NULL append at the end.
- * Return FAIL when out of memory.
*/
-int list_insert_tv(list_T *l, typval_T *tv, listitem_T *item)
+void list_insert_tv(list_T *l, typval_T *tv, listitem_T *item)
{
listitem_T *ni = listitem_alloc();
copy_tv(tv, &ni->li_tv);
list_insert(l, ni, item);
- return OK;
}
void list_insert(list_T *l, listitem_T *ni, listitem_T *item)
@@ -5137,19 +5135,17 @@ void list_insert(list_T *l, listitem_T *ni, listitem_T *item)
/*
* Extend "l1" with "l2".
* If "bef" is NULL append at the end, otherwise insert before this item.
- * Returns FAIL when out of memory.
*/
-static int list_extend(list_T *l1, list_T *l2, listitem_T *bef)
+static void list_extend(list_T *l1, list_T *l2, listitem_T *bef)
{
listitem_T *item;
int todo = l2->lv_len;
/* We also quit the loop when we have inserted the original item count of
* the list, avoid a hang when we extend a list with itself. */
- for (item = l2->lv_first; item != NULL && --todo >= 0; item = item->li_next)
- if (list_insert_tv(l1, &item->li_tv, bef) == FAIL)
- return FAIL;
- return OK;
+ for (item = l2->lv_first; item != NULL && --todo >= 0; item = item->li_next) {
+ list_insert_tv(l1, &item->li_tv, bef);
+ }
}
/*
@@ -5171,7 +5167,8 @@ static int list_concat(list_T *l1, list_T *l2, typval_T *tv)
tv->vval.v_list = l;
/* append all items from the second list */
- return list_extend(l, l2, NULL);
+ list_extend(l, l2, NULL);
+ return OK;
}
/*
@@ -11820,10 +11817,7 @@ static void f_repeat(typval_T *argvars, typval_T *rettv)
rettv_list_alloc(rettv);
if (argvars[0].vval.v_list != NULL) {
while (n-- > 0) {
- if (list_extend(rettv->vval.v_list, argvars[0].vval.v_list, NULL)
- == FAIL) {
- break;
- }
+ list_extend(rettv->vval.v_list, argvars[0].vval.v_list, NULL);
}
}
} else {