From 1c12f844ad6db504e1435b5e4b633eb87b932180 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 19 Apr 2023 11:29:10 +0800 Subject: [PATCH] refactor(eval): use tv_list_append_allocated_string() --- src/nvim/eval.c | 3 +-- src/nvim/memline.c | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 28ac1f3fbd..35738cdfa9 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -5712,8 +5712,7 @@ void get_xdg_var_list(const XDGVarType xdg, typval_T *rettv) if (dir != NULL && dir_len > 0) { char *dir_with_nvim = xmemdupz(dir, dir_len); dir_with_nvim = concat_fnames_realloc(dir_with_nvim, appname, true); - tv_list_append_string(list, dir_with_nvim, (ssize_t)strlen(dir_with_nvim)); - xfree(dir_with_nvim); + tv_list_append_allocated_string(list, dir_with_nvim); } } while (iter != NULL); xfree(dirs); diff --git a/src/nvim/memline.c b/src/nvim/memline.c index 498b4b5960..2528b5c0d3 100644 --- a/src/nvim/memline.c +++ b/src/nvim/memline.c @@ -1367,8 +1367,7 @@ int recover_names(char *fname, bool do_list, list_T *ret_list, int nr, char **fn for (int i = 0; i < num_files; i++) { char *name = concat_fnames(dir_name, files[i], true); if (name != NULL) { - tv_list_append_string(ret_list, name, -1); - xfree(name); + tv_list_append_allocated_string(ret_list, name); } } } else {