eval: Call list_append_allocated_string from list_append_string

This commit is contained in:
ZyX
2015-08-02 19:42:05 +03:00
parent 69a42f2d1d
commit 401ae724ea

View File

@@ -5245,23 +5245,22 @@ void list_append_dict(list_T *list, dict_T *dict)
++dict->dv_refcount; ++dict->dv_refcount;
} }
/* /// Make a copy of "str" and append it as an item to list "l"
* Make a copy of "str" and append it as an item to list "l". ///
* When "len" >= 0 use "str[len]". /// @param[out] l List to append to.
*/ /// @param[in] str String to append.
void list_append_string(list_T *l, char_u *str, int len) /// @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) { if (str == NULL) {
li->li_tv.vval.v_string = NULL; list_append_allocated_string(l, NULL);
} else { } else {
li->li_tv.vval.v_string = (len >= 0) ? vim_strnsave(str, len) list_append_allocated_string(l, (len >= 0
: vim_strsave(str); ? xmemdupz((char *) str, len)
: xstrdup((char *) str)));
} }
} }