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