Remove OOM checks: do_string_sub()

This commit is contained in:
Felipe Oliveira Carvalho 2014-05-12 15:14:29 -03:00
parent 1d844dda46
commit f88a2d7e1b

View File

@ -19529,27 +19529,23 @@ repeat:
p = vim_strchr(s, sep); p = vim_strchr(s, sep);
if (p != NULL) { if (p != NULL) {
pat = vim_strnsave(s, (int)(p - s)); pat = vim_strnsave(s, (int)(p - s));
if (pat != NULL) { s = p + 1;
s = p + 1; /* find end of substitution */
/* find end of substitution */ p = vim_strchr(s, sep);
p = vim_strchr(s, sep); if (p != NULL) {
if (p != NULL) { sub = vim_strnsave(s, (int)(p - s));
sub = vim_strnsave(s, (int)(p - s)); str = vim_strnsave(*fnamep, *fnamelen);
str = vim_strnsave(*fnamep, *fnamelen); *usedlen = (int)(p + 1 - src);
*usedlen = (int)(p + 1 - src); s = do_string_sub(str, pat, sub, flags);
s = do_string_sub(str, pat, sub, flags); *fnamep = s;
if (s != NULL) { *fnamelen = (int)STRLEN(s);
*fnamep = s; free(*bufp);
*fnamelen = (int)STRLEN(s); *bufp = s;
free(*bufp); didit = TRUE;
*bufp = s; free(sub);
didit = TRUE; free(str);
}
free(sub);
free(str);
}
free(pat);
} }
free(pat);
} }
/* after using ":s", repeat all the modifiers */ /* after using ":s", repeat all the modifiers */
if (didit) if (didit)
@ -19581,7 +19577,6 @@ char_u *do_string_sub(char_u *str, char_u *pat, char_u *sub, char_u *flags)
int do_all; int do_all;
char_u *tail; char_u *tail;
garray_T ga; garray_T ga;
char_u *ret;
char_u *save_cpo; char_u *save_cpo;
char_u *zero_width = NULL; char_u *zero_width = NULL;
@ -19640,7 +19635,7 @@ char_u *do_string_sub(char_u *str, char_u *pat, char_u *sub, char_u *flags)
vim_regfree(regmatch.regprog); vim_regfree(regmatch.regprog);
} }
ret = vim_strsave(ga.ga_data == NULL ? str : (char_u *)ga.ga_data); char_u *ret = vim_strsave(ga.ga_data == NULL ? str : (char_u *)ga.ga_data);
ga_clear(&ga); ga_clear(&ga);
if (p_cpo == empty_option) if (p_cpo == empty_option)
p_cpo = save_cpo; p_cpo = save_cpo;