mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
Add 'FUNC_ATTR_NONNULL_RET' to nonnull alloc funcs (#14559)
This commit is contained in:
parent
d67dcaba02
commit
6ab83f3572
@ -162,6 +162,7 @@ void channel_init(void)
|
||||
/// Channel is allocated with refcount 1, which should be decreased
|
||||
/// when the underlying stream closes.
|
||||
Channel *channel_alloc(ChannelStreamType type)
|
||||
FUNC_ATTR_NONNULL_RET
|
||||
{
|
||||
Channel *chan = xcalloc(1, sizeof(*chan));
|
||||
if (type == kChannelStreamStdio) {
|
||||
|
@ -2770,10 +2770,9 @@ static void f_get(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||
}
|
||||
} else if (strcmp(what, "args") == 0) {
|
||||
rettv->v_type = VAR_LIST;
|
||||
if (tv_list_alloc_ret(rettv, pt->pt_argc) != NULL) {
|
||||
for (int i = 0; i < pt->pt_argc; i++) {
|
||||
tv_list_append_tv(rettv->vval.v_list, &pt->pt_argv[i]);
|
||||
}
|
||||
tv_list_alloc_ret(rettv, pt->pt_argc);
|
||||
for (int i = 0; i < pt->pt_argc; i++) {
|
||||
tv_list_append_tv(rettv->vval.v_list, &pt->pt_argv[i]);
|
||||
}
|
||||
} else {
|
||||
EMSG2(_(e_invarg2), what);
|
||||
|
@ -2098,7 +2098,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, const ptrdiff_t len)
|
||||
FUNC_ATTR_NONNULL_ALL
|
||||
FUNC_ATTR_NONNULL_ALL FUNC_ATTR_NONNULL_RET
|
||||
{
|
||||
list_T *const l = tv_list_alloc(len);
|
||||
tv_list_set_ret(ret_tv, l);
|
||||
@ -2107,6 +2107,7 @@ list_T *tv_list_alloc_ret(typval_T *const ret_tv, const ptrdiff_t len)
|
||||
}
|
||||
|
||||
dict_T *tv_dict_alloc_lock(VarLockStatus lock)
|
||||
FUNC_ATTR_NONNULL_RET
|
||||
{
|
||||
dict_T *const d = tv_dict_alloc();
|
||||
d->dv_lock = lock;
|
||||
|
@ -3571,6 +3571,7 @@ static void save_cmdline(struct cmdline_info *ccp)
|
||||
* Restore ccline after it has been saved with save_cmdline().
|
||||
*/
|
||||
static void restore_cmdline(struct cmdline_info *ccp)
|
||||
FUNC_ATTR_NONNULL_ALL
|
||||
{
|
||||
ccline = *ccp;
|
||||
}
|
||||
@ -3580,6 +3581,7 @@ static void restore_cmdline(struct cmdline_info *ccp)
|
||||
* passed to restore_cmdline_alloc() later.
|
||||
*/
|
||||
char_u *save_cmdline_alloc(void)
|
||||
FUNC_ATTR_NONNULL_RET
|
||||
{
|
||||
struct cmdline_info *p = xmalloc(sizeof(struct cmdline_info));
|
||||
save_cmdline(p);
|
||||
@ -3590,6 +3592,7 @@ char_u *save_cmdline_alloc(void)
|
||||
* Restore the command line from the return value of save_cmdline_alloc().
|
||||
*/
|
||||
void restore_cmdline_alloc(char_u *p)
|
||||
FUNC_ATTR_NONNULL_ALL
|
||||
{
|
||||
restore_cmdline((struct cmdline_info *)p);
|
||||
xfree(p);
|
||||
|
@ -1677,6 +1677,7 @@ static void int_wordlist_spl(char_u *fname)
|
||||
// Allocate a new slang_T for language "lang". "lang" can be NULL.
|
||||
// Caller must fill "sl_next".
|
||||
slang_T *slang_alloc(char_u *lang)
|
||||
FUNC_ATTR_NONNULL_RET
|
||||
{
|
||||
slang_T *lp = xcalloc(1, sizeof(slang_T));
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user