xrealloc(): similar to xmalloc()

Replaced all calls to realloc by xrealloc. All `== NULL` tests can be removed
and the code within `!= NULL` tests can be unwrapped.
This commit is contained in:
Felipe Oliveira Carvalho
2014-03-29 01:05:04 -03:00
committed by Thiago de Arruda
parent 7bdd1f1898
commit 0e998066b2
10 changed files with 39 additions and 11 deletions

View File

@@ -12018,7 +12018,7 @@ static void f_readfile(typval_T *argvars, typval_T *rettv)
/* Change "prev" buffer to be the right size. This way
* the bytes are only copied once, and very long lines are
* allocated only once. */
if ((s = realloc(prev, prevlen + len + 1)) != NULL) {
if ((s = xrealloc(prev, prevlen + len + 1)) != NULL) {
memmove(s + prevlen, start, len);
s[prevlen + len] = NUL;
prev = NULL; /* the list will own the string */
@@ -12103,7 +12103,7 @@ static void f_readfile(typval_T *argvars, typval_T *rettv)
prevsize = grow50pc > growmin ? grow50pc : growmin;
}
newprev = prev == NULL ? alloc(prevsize)
: realloc(prev, prevsize);
: xrealloc(prev, prevsize);
if (newprev == NULL) {
do_outofmem_msg((long_u)prevsize);
failed = TRUE;