Remove simpler cases of OOM error handling (after *alloc calls)

By simpler cases I mean cases where the OOM error is not expected to be handled
by the caller of the function that calls `alloc`, `lalloc`, `xrealloc`,
`xmalloc`, `alloc_clear`, and `lalloc_clear`.

These are the functions that:

 - Do not return an allocated buffer
 - Have OOM as the only error condition

I took note of the functions that expect the caller to handle the OOM error and
will go through them to check all the callers that may be handling OOM error in
future commits.

I'm ignoring eval.c and ex_.c in this series of commits. eval.c will soon be
obsolete and I will deal with ex_.c in later PRs.
This commit is contained in:
Felipe Oliveira Carvalho
2014-04-01 01:41:39 -03:00
committed by Thiago de Arruda
parent 6bbffee0a5
commit 13848aadbf
39 changed files with 944 additions and 1499 deletions

View File

@@ -3434,8 +3434,7 @@ find_decl (
int retval = OK;
int incll;
if ((pat = alloc(len + 7)) == NULL)
return FAIL;
pat = alloc(len + 7);
/* Put "\V" before the pattern to avoid that the special meaning of "."
* and "~" causes trouble. */
@@ -4410,8 +4409,6 @@ static void nv_ident(cmdarg_T *cap)
kp_help = (*kp == NUL || STRCMP(kp, ":he") == 0
|| STRCMP(kp, ":help") == 0);
buf = alloc((unsigned)(n * 2 + 30 + STRLEN(kp)));
if (buf == NULL)
return;
buf[0] = NUL;
switch (cmdchar) {
@@ -4500,11 +4497,6 @@ static void nv_ident(cmdarg_T *cap)
return;
}
newbuf = (char_u *)xrealloc(buf, STRLEN(buf) + STRLEN(p) + 1);
if (newbuf == NULL) {
vim_free(buf);
vim_free(p);
return;
}
buf = newbuf;
STRCAT(buf, p);
vim_free(p);