aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoroni-link <knil.ino@gmail.com>2014-04-24 21:38:46 +0200
committerThiago de Arruda <tpadilha84@gmail.com>2014-04-29 15:04:21 -0300
commitdc9b680debed30723bed7ec71b66327377fd0d86 (patch)
tree6bf5c75f97de790dfbef55a0d51857332759ee47 /src
parent6797a3e78887559903e46c5242290d821357f332 (diff)
downloadrneovim-dc9b680debed30723bed7ec71b66327377fd0d86.tar.gz
rneovim-dc9b680debed30723bed7ec71b66327377fd0d86.tar.bz2
rneovim-dc9b680debed30723bed7ec71b66327377fd0d86.zip
Call to list_append_tv cannot fail.
Clean up the use of list_append_tv and remove error checks.
Diffstat (limited to 'src')
-rw-r--r--src/eval.c21
-rw-r--r--src/eval.h2
2 files changed, 8 insertions, 15 deletions
diff --git a/src/eval.c b/src/eval.c
index 7c4e03387d..456ccecd44 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -4759,12 +4759,9 @@ eval_index (
l = list_alloc();
if (l == NULL)
return FAIL;
- for (item = list_find(rettv->vval.v_list, n1);
- n1 <= n2; ++n1) {
- if (list_append_tv(l, &item->li_tv) == FAIL) {
- list_free(l, TRUE);
- return FAIL;
- }
+ item = list_find(rettv->vval.v_list, n1);
+ while (n1++ <= n2) {
+ list_append_tv(l, &item->li_tv);
item = item->li_next;
}
clear_tv(rettv);
@@ -5517,17 +5514,12 @@ void list_append(list_T *l, listitem_T *item)
/*
* Append typval_T "tv" to the end of list "l".
- * Return FAIL when out of memory.
*/
-int list_append_tv(list_T *l, typval_T *tv)
+void list_append_tv(list_T *l, typval_T *tv)
{
listitem_T *li = listitem_alloc();
-
- if (li == NULL)
- return FAIL;
copy_tv(tv, &li->li_tv);
list_append(l, li);
- return OK;
}
/*
@@ -7534,9 +7526,10 @@ static void f_add(typval_T *argvars, typval_T *rettv)
rettv->vval.v_number = 1; /* Default: Failed */
if (argvars[0].v_type == VAR_LIST) {
if ((l = argvars[0].vval.v_list) != NULL
- && !tv_check_lock(l->lv_lock, (char_u *)_("add() argument"))
- && list_append_tv(l, &argvars[1]) == OK)
+ && !tv_check_lock(l->lv_lock, (char_u *)_("add() argument"))) {
+ list_append_tv(l, &argvars[1]);
copy_tv(&argvars[0], rettv);
+ }
} else
EMSG(_(e_listreq));
}
diff --git a/src/eval.h b/src/eval.h
index a15762ea5e..20d6bfe119 100644
--- a/src/eval.h
+++ b/src/eval.h
@@ -63,7 +63,7 @@ dictitem_T *dict_lookup(hashitem_T *hi);
listitem_T *list_find(list_T *l, long n);
char_u *list_find_str(list_T *l, long idx);
void list_append(list_T *l, listitem_T *item);
-int list_append_tv(list_T *l, typval_T *tv);
+void list_append_tv(list_T *l, typval_T *tv);
void list_append_dict(list_T *list, dict_T *dict);
void list_append_string(list_T *l, char_u *str, int len);
int list_insert_tv(list_T *l, typval_T *tv, listitem_T *item);