mirror of
https://github.com/neovim/neovim.git
synced 2025-09-16 16:28:17 +00:00
Remove NULL/non-NULL tests after calls to vim_str(n)save()
This commit is contained in:
@@ -2138,11 +2138,9 @@ static char_u *next_fenc(char_u **pp)
|
||||
} else {
|
||||
r = vim_strnsave(*pp, (int)(p - *pp));
|
||||
*pp = p + 1;
|
||||
if (r != NULL) {
|
||||
p = enc_canonize(r);
|
||||
free(r);
|
||||
r = p;
|
||||
}
|
||||
p = enc_canonize(r);
|
||||
free(r);
|
||||
r = p;
|
||||
}
|
||||
if (r == NULL) { /* out of memory */
|
||||
r = (char_u *)"";
|
||||
@@ -5037,7 +5035,7 @@ static int move_lines(buf_T *frombuf, buf_T *tobuf)
|
||||
curbuf = tobuf;
|
||||
for (lnum = 1; lnum <= frombuf->b_ml.ml_line_count; ++lnum) {
|
||||
p = vim_strsave(ml_get_buf(frombuf, lnum, FALSE));
|
||||
if (p == NULL || ml_append(lnum - 1, p, 0, FALSE) == FAIL) {
|
||||
if (ml_append(lnum - 1, p, 0, FALSE) == FAIL) {
|
||||
free(p);
|
||||
retval = FAIL;
|
||||
break;
|
||||
@@ -6037,8 +6035,6 @@ static int au_new_group(char_u *name)
|
||||
}
|
||||
|
||||
AUGROUP_NAME(i) = vim_strsave(name);
|
||||
if (AUGROUP_NAME(i) == NULL)
|
||||
return AUGROUP_ERROR;
|
||||
if (i == augroups.ga_len)
|
||||
++augroups.ga_len;
|
||||
}
|
||||
@@ -6242,18 +6238,14 @@ char_u *au_event_disable(char *what)
|
||||
char_u *save_ei;
|
||||
|
||||
save_ei = vim_strsave(p_ei);
|
||||
if (save_ei != NULL) {
|
||||
new_ei = vim_strnsave(p_ei, (int)(STRLEN(p_ei) + STRLEN(what)));
|
||||
if (new_ei != NULL) {
|
||||
if (*what == ',' && *p_ei == NUL)
|
||||
STRCPY(new_ei, what + 1);
|
||||
else
|
||||
STRCAT(new_ei, what);
|
||||
set_string_option_direct((char_u *)"ei", -1, new_ei,
|
||||
OPT_FREE, SID_NONE);
|
||||
free(new_ei);
|
||||
}
|
||||
}
|
||||
new_ei = vim_strnsave(p_ei, (int)(STRLEN(p_ei) + STRLEN(what)));
|
||||
if (*what == ',' && *p_ei == NUL)
|
||||
STRCPY(new_ei, what + 1);
|
||||
else
|
||||
STRCAT(new_ei, what);
|
||||
set_string_option_direct((char_u *)"ei", -1, new_ei, OPT_FREE, SID_NONE);
|
||||
free(new_ei);
|
||||
|
||||
return save_ei;
|
||||
}
|
||||
|
||||
@@ -6404,7 +6396,7 @@ void do_autocmd(char_u *arg, int forceit)
|
||||
* Find the group ID in a ":autocmd" or ":doautocmd" argument.
|
||||
* The "argp" argument is advanced to the following argument.
|
||||
*
|
||||
* Returns the group ID, AUGROUP_ERROR for error (out of memory).
|
||||
* Returns the group ID or AUGROUP_ALL.
|
||||
*/
|
||||
static int au_get_grouparg(char_u **argp)
|
||||
{
|
||||
@@ -6416,8 +6408,6 @@ static int au_get_grouparg(char_u **argp)
|
||||
p = skiptowhite(arg);
|
||||
if (p > arg) {
|
||||
group_name = vim_strnsave(arg, (int)(p - arg));
|
||||
if (group_name == NULL) /* out of memory */
|
||||
return AUGROUP_ERROR;
|
||||
group = au_find_group(group_name);
|
||||
if (group == AUGROUP_ERROR)
|
||||
group = AUGROUP_ALL; /* no match, use all groups */
|
||||
@@ -6587,10 +6577,6 @@ static int do_autocmd_event(event_T event, char_u *pat, int nested, char_u *cmd,
|
||||
ap = (AutoPat *)alloc((unsigned)sizeof(AutoPat));
|
||||
ap->pat = vim_strnsave(pat, patlen);
|
||||
ap->patlen = patlen;
|
||||
if (ap->pat == NULL) {
|
||||
free(ap);
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
if (is_buflocal) {
|
||||
ap->buflocal_nr = buflocal_nr;
|
||||
@@ -6628,10 +6614,6 @@ static int do_autocmd_event(event_T event, char_u *pat, int nested, char_u *cmd,
|
||||
ac = (AutoCmd *)alloc((unsigned)sizeof(AutoCmd));
|
||||
ac->cmd = vim_strsave(cmd);
|
||||
ac->scriptID = current_SID;
|
||||
if (ac->cmd == NULL) {
|
||||
free(ac);
|
||||
return FAIL;
|
||||
}
|
||||
ac->next = NULL;
|
||||
*prev_ac = ac;
|
||||
ac->nested = nested;
|
||||
@@ -7542,8 +7524,7 @@ int has_autocmd(event_T event, char_u *sfname, buf_T *buf)
|
||||
* autocommand patterns portable between Unix and MS-DOS.
|
||||
*/
|
||||
sfname = vim_strsave(sfname);
|
||||
if (sfname != NULL)
|
||||
forward_slash(sfname);
|
||||
forward_slash(sfname);
|
||||
forward_slash(fname);
|
||||
#endif
|
||||
|
||||
@@ -7681,8 +7662,6 @@ int au_exists(char_u *arg)
|
||||
|
||||
/* Make a copy so that we can change the '#' chars to a NUL. */
|
||||
arg_save = vim_strsave(arg);
|
||||
if (arg_save == NULL)
|
||||
return FALSE;
|
||||
p = vim_strchr(arg_save, '#');
|
||||
if (p != NULL)
|
||||
*p++ = NUL;
|
||||
|
Reference in New Issue
Block a user