Remove OOM error handling code after ga_grow() calls

This commit is contained in:
Felipe Oliveira Carvalho
2014-04-07 22:28:33 -03:00
committed by Thiago de Arruda
parent 457bb26151
commit f6b0e335e1
23 changed files with 315 additions and 401 deletions

View File

@@ -423,9 +423,7 @@ char_u* str_foldcase(char_u *str, int orglen, char_u *buf, int buflen)
if (buf == NULL) {
ga_init(&ga, 1, 10);
if (ga_grow(&ga, len + 1) == FAIL) {
return NULL;
}
ga_grow(&ga, len + 1);
memmove(ga.ga_data, str, (size_t)len);
ga.ga_len = len;
} else {
@@ -461,12 +459,14 @@ char_u* str_foldcase(char_u *str, int orglen, char_u *buf, int buflen)
// characters forward or backward.
if (olen != nlen) {
if (nlen > olen) {
if ((buf == NULL)
? (ga_grow(&ga, nlen - olen + 1) == FAIL)
: (len + nlen - olen >= buflen)) {
// out of memory, keep old char
lc = c;
nlen = olen;
if (buf == NULL) {
ga_grow(&ga, nlen - olen + 1);
} else {
if (len + nlen - olen >= buflen) {
// out of memory, keep old char
lc = c;
nlen = olen;
}
}
}