Merge #6528 from ZyX-I/revise-malloc-attr

Revise places where FUNC_ATTR_MALLOC is present

Closes #6521
This commit is contained in:
Justin M. Keyes 2017-04-15 22:12:31 +02:00 committed by GitHub
commit 5c805f4566
5 changed files with 6 additions and 8 deletions

View File

@ -136,7 +136,7 @@ void tv_list_watch_fix(list_T *const l, const listitem_T *const item)
/// ///
/// @return [allocated] new list. /// @return [allocated] new list.
list_T *tv_list_alloc(void) 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)); list_T *const list = xcalloc(1, sizeof(list_T));
@ -1011,7 +1011,6 @@ void tv_dict_item_free(dictitem_T *const item)
/// @return [allocated] new dictionary item. /// @return [allocated] new dictionary item.
static dictitem_T *tv_dict_item_copy(dictitem_T *const di) 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_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); dictitem_T *const new_di = tv_dict_item_alloc((const char *)di->di_key);
tv_copy(&di->di_tv, &new_di->di_tv); tv_copy(&di->di_tv, &new_di->di_tv);
@ -1040,7 +1039,7 @@ void tv_dict_item_remove(dict_T *const dict, dictitem_T *const item)
/// ///
/// @return [allocated] new dictionary. /// @return [allocated] new dictionary.
dict_T *tv_dict_alloc(void) 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)); dict_T *const d = xmalloc(sizeof(dict_T));
@ -1577,7 +1576,7 @@ void tv_dict_set_keys_readonly(dict_T *const dict)
/// ///
/// @return [allocated] pointer to the created list. /// @return [allocated] pointer to the created list.
list_T *tv_list_alloc_ret(typval_T *const ret_tv) 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(); list_T *const l = tv_list_alloc();
ret_tv->vval.v_list = l; ret_tv->vval.v_list = l;

View File

@ -802,7 +802,6 @@ static bool is_append_register(int regname)
/// Returns a copy of contents in register `name` /// Returns a copy of contents in register `name`
/// for use in do_put. Should be freed by caller. /// for use in do_put. Should be freed by caller.
yankreg_T *copy_register(int name) yankreg_T *copy_register(int name)
FUNC_ATTR_MALLOC
FUNC_ATTR_NONNULL_RET FUNC_ATTR_NONNULL_RET
{ {
yankreg_T *reg = get_yank_register(name, YREG_PASTE); yankreg_T *reg = get_yank_register(name, YREG_PASTE);

View File

@ -6974,7 +6974,7 @@ bool signcolumn_on(win_T *wp)
/// Get window or buffer local options /// Get window or buffer local options
dict_T *get_winbuf_options(const int bufopt) 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(); dict_T *const d = tv_dict_alloc();

View File

@ -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. /// @return [allocated] Opened file or NULL in case of error.
FileDescriptor *file_open_new(int *const error, const char *const fname, FileDescriptor *file_open_new(int *const error, const char *const fname,
const int flags, const int mode) 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)); FileDescriptor *const fp = xmalloc(sizeof(*fp));
if ((*error = file_open(fp, fname, flags, mode)) != 0) { if ((*error = file_open(fp, fname, flags, mode)) != 0) {

View File

@ -47,7 +47,7 @@ typedef struct {
/// @param extra_args Extra arguments to the shell, or NULL. /// @param extra_args Extra arguments to the shell, or NULL.
/// @return Newly allocated argument vector. Must be freed with shell_free_argv. /// @return Newly allocated argument vector. Must be freed with shell_free_argv.
char **shell_build_argv(const char *cmd, const char *extra_args) 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); size_t argc = tokenize(p_sh, NULL) + (cmd ? tokenize(p_shcf, NULL) : 0);
char **rv = xmalloc((argc + 4) * sizeof(*rv)); char **rv = xmalloc((argc + 4) * sizeof(*rv));