aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorZyX <kp-pav@yandex.ru>2015-08-02 19:42:05 +0300
committerZyX <kp-pav@yandex.ru>2015-08-02 20:38:09 +0300
commit401ae724ea57001fb9d1aed520a7a97156c22f08 (patch)
treee261a37f4d9267e869b73ea69eaf8c7808526a6d /src
parent69a42f2d1d0892cfb926314cb990dfa89c75821a (diff)
downloadrneovim-401ae724ea57001fb9d1aed520a7a97156c22f08.tar.gz
rneovim-401ae724ea57001fb9d1aed520a7a97156c22f08.tar.bz2
rneovim-401ae724ea57001fb9d1aed520a7a97156c22f08.zip
eval: Call list_append_allocated_string from list_append_string
Diffstat (limited to 'src')
-rw-r--r--src/nvim/eval.c27
1 files changed, 13 insertions, 14 deletions
diff --git a/src/nvim/eval.c b/src/nvim/eval.c
index 18f7c37449..ed0b6290dc 100644
--- a/src/nvim/eval.c
+++ b/src/nvim/eval.c
@@ -5245,23 +5245,22 @@ void list_append_dict(list_T *list, dict_T *dict)
++dict->dv_refcount;
}
-/*
- * Make a copy of "str" and append it as an item to list "l".
- * When "len" >= 0 use "str[len]".
- */
-void list_append_string(list_T *l, char_u *str, int len)
+/// Make a copy of "str" and append it as an item to list "l"
+///
+/// @param[out] l List to append to.
+/// @param[in] str String to append.
+/// @param[in] len Length of the appended string. May be negative, in this
+/// case string is considered to be usual zero-terminated
+/// string.
+void list_append_string(list_T *l, const char_u *str, int len)
+ FUNC_ATTR_NONNULL_ARG(1)
{
- listitem_T *li = listitem_alloc();
-
- list_append(l, li);
- li->li_tv.v_type = VAR_STRING;
- li->li_tv.v_lock = 0;
-
if (str == NULL) {
- li->li_tv.vval.v_string = NULL;
+ list_append_allocated_string(l, NULL);
} else {
- li->li_tv.vval.v_string = (len >= 0) ? vim_strnsave(str, len)
- : vim_strsave(str);
+ list_append_allocated_string(l, (len >= 0
+ ? xmemdupz((char *) str, len)
+ : xstrdup((char *) str)));
}
}