From 0dddd8a27caac1060dedbe55b285e3564e81e995 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sat, 15 Apr 2017 19:13:43 +0300 Subject: os/fileio: Remove FUNC_ATTR_MALLOC for file_open_new fp contains pointer to rbuffer --- src/nvim/os/fileio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/os/fileio.c b/src/nvim/os/fileio.c index 4b7b53fc7f..3c47c66196 100644 --- a/src/nvim/os/fileio.c +++ b/src/nvim/os/fileio.c @@ -100,7 +100,7 @@ int file_open(FileDescriptor *const ret_fp, const char *const fname, /// @return [allocated] Opened file or NULL in case of error. FileDescriptor *file_open_new(int *const error, const char *const fname, const int flags, const int mode) - FUNC_ATTR_NONNULL_ALL FUNC_ATTR_MALLOC FUNC_ATTR_WARN_UNUSED_RESULT + FUNC_ATTR_NONNULL_ALL FUNC_ATTR_WARN_UNUSED_RESULT { FileDescriptor *const fp = xmalloc(sizeof(*fp)); if ((*error = file_open(fp, fname, flags, mode)) != 0) { -- cgit From b08b71c7288ed7bbeae6066ab36a1366d0673bf5 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sat, 15 Apr 2017 19:16:00 +0300 Subject: eval/typval: Remove FUNC_ATTR_MALLOC from tv_list_alloc Allocated list points to previously allocated list. Allocated list is saved to gc_first_list. --- src/nvim/eval/typval.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/eval/typval.c b/src/nvim/eval/typval.c index eb6db9547b..14db330dba 100644 --- a/src/nvim/eval/typval.c +++ b/src/nvim/eval/typval.c @@ -136,7 +136,7 @@ void tv_list_watch_fix(list_T *const l, const listitem_T *const item) /// /// @return [allocated] new list. list_T *tv_list_alloc(void) - FUNC_ATTR_NONNULL_RET FUNC_ATTR_MALLOC + FUNC_ATTR_NONNULL_RET { list_T *const list = xcalloc(1, sizeof(list_T)); -- cgit From b9004d744811f530922fbb194ea02033d332f375 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sat, 15 Apr 2017 19:16:40 +0300 Subject: eval/typval: Remove FUNC_ATTR_MALLOC from tv_dict_item_copy Allocated storage may receive pointer to the list after tv_copy(). --- src/nvim/eval/typval.c | 1 - 1 file changed, 1 deletion(-) (limited to 'src') diff --git a/src/nvim/eval/typval.c b/src/nvim/eval/typval.c index 14db330dba..4d1400484a 100644 --- a/src/nvim/eval/typval.c +++ b/src/nvim/eval/typval.c @@ -1011,7 +1011,6 @@ void tv_dict_item_free(dictitem_T *const item) /// @return [allocated] new dictionary item. static dictitem_T *tv_dict_item_copy(dictitem_T *const di) FUNC_ATTR_NONNULL_RET FUNC_ATTR_NONNULL_ALL FUNC_ATTR_WARN_UNUSED_RESULT - FUNC_ATTR_MALLOC { dictitem_T *const new_di = tv_dict_item_alloc((const char *)di->di_key); tv_copy(&di->di_tv, &new_di->di_tv); -- cgit From af3579d5f7bc86a25fd73e94c6de0e73ae9d8e12 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sat, 15 Apr 2017 19:18:25 +0300 Subject: eval/typval: Remove FUNC_ATTR_MALLOC from tv_dict_alloc Allocated dict points to previously allocated dict. Queue in allocated dict points to itself. Hashtab in allocated dict points to inside itself. Allocated dict is saved to gc_first_dict. --- src/nvim/eval/typval.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/eval/typval.c b/src/nvim/eval/typval.c index 4d1400484a..9e954be9b3 100644 --- a/src/nvim/eval/typval.c +++ b/src/nvim/eval/typval.c @@ -1039,7 +1039,7 @@ void tv_dict_item_remove(dict_T *const dict, dictitem_T *const item) /// /// @return [allocated] new dictionary. dict_T *tv_dict_alloc(void) - FUNC_ATTR_NONNULL_RET FUNC_ATTR_MALLOC FUNC_ATTR_WARN_UNUSED_RESULT + FUNC_ATTR_NONNULL_RET FUNC_ATTR_WARN_UNUSED_RESULT { dict_T *const d = xmalloc(sizeof(dict_T)); -- cgit From 82ba2891ae905fabacafc58daebedc80533b8334 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sat, 15 Apr 2017 19:19:22 +0300 Subject: eval/typval: Remove FUNC_ATTR_MALLOC from tv_list_alloc_ret Same as tv_list_alloc, but additionally ret_tv receives pointer to the newly allocated list. --- src/nvim/eval/typval.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/eval/typval.c b/src/nvim/eval/typval.c index 9e954be9b3..70ec3dfe39 100644 --- a/src/nvim/eval/typval.c +++ b/src/nvim/eval/typval.c @@ -1576,7 +1576,7 @@ void tv_dict_set_keys_readonly(dict_T *const dict) /// /// @return [allocated] pointer to the created list. list_T *tv_list_alloc_ret(typval_T *const ret_tv) - FUNC_ATTR_NONNULL_ALL FUNC_ATTR_MALLOC + FUNC_ATTR_NONNULL_ALL { list_T *const l = tv_list_alloc(); ret_tv->vval.v_list = l; -- cgit From d191ba1db38cf4bad3e4ed3e3346f3f8a9c015cf Mon Sep 17 00:00:00 2001 From: ZyX Date: Sat, 15 Apr 2017 19:23:00 +0300 Subject: option: Remove FUNC_ATTR_MALLOC from get_winbuf_options Same as tv_dict_alloc() and additionally it saves some strings inside a dictionary. --- src/nvim/option.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/option.c b/src/nvim/option.c index 458d80716c..0070a0056d 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -6974,7 +6974,7 @@ bool signcolumn_on(win_T *wp) /// Get window or buffer local options dict_T *get_winbuf_options(const int bufopt) - FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_MALLOC + FUNC_ATTR_WARN_UNUSED_RESULT { dict_T *const d = tv_dict_alloc(); -- cgit From ac47e64ecad6b21d4d29066b37ab4018fcd8da48 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sat, 15 Apr 2017 19:25:00 +0300 Subject: ops: Remove FUNC_ATTR_MALLOC from copy_register Returned storage has a pointer to a newly allocated array. --- src/nvim/ops.c | 1 - 1 file changed, 1 deletion(-) (limited to 'src') diff --git a/src/nvim/ops.c b/src/nvim/ops.c index f11d6b69b2..5212ec45ab 100644 --- a/src/nvim/ops.c +++ b/src/nvim/ops.c @@ -802,7 +802,6 @@ static bool is_append_register(int regname) /// Returns a copy of contents in register `name` /// for use in do_put. Should be freed by caller. yankreg_T *copy_register(int name) - FUNC_ATTR_MALLOC FUNC_ATTR_NONNULL_RET { yankreg_T *reg = get_yank_register(name, YREG_PASTE); -- cgit From d76a13bb65574f4811313ada6454f7d34cde2a2c Mon Sep 17 00:00:00 2001 From: ZyX Date: Sat, 15 Apr 2017 19:39:53 +0300 Subject: os/shell: Remove FUNC_ATTR_MALLOC from shell_build_argv Returns an array of allocated strings. --- src/nvim/os/shell.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/os/shell.c b/src/nvim/os/shell.c index 5cc9d4b79b..29c0431521 100644 --- a/src/nvim/os/shell.c +++ b/src/nvim/os/shell.c @@ -47,7 +47,7 @@ typedef struct { /// @param extra_args Extra arguments to the shell, or NULL. /// @return Newly allocated argument vector. Must be freed with shell_free_argv. char **shell_build_argv(const char *cmd, const char *extra_args) - FUNC_ATTR_NONNULL_RET FUNC_ATTR_MALLOC + FUNC_ATTR_NONNULL_RET { size_t argc = tokenize(p_sh, NULL) + (cmd ? tokenize(p_shcf, NULL) : 0); char **rv = xmalloc((argc + 4) * sizeof(*rv)); -- cgit