In globextend(), take advantage of the fact that realloc(NULL, size) is

equivalent to malloc(size). This eliminates the conditional expression
used for calling either realloc() or malloc() when realloc() will do
all the time.
This commit is contained in:
marcel 2012-12-01 17:50:39 +00:00
parent 5192abbac6
commit e0cbca43aa

View File

@ -715,9 +715,8 @@ globextend(const Char *path, glob_t *pglob, size_t *limit)
}
newsize = sizeof(*pathv) * (2 + pglob->gl_pathc + pglob->gl_offs);
pathv = pglob->gl_pathv ?
realloc((char *)pglob->gl_pathv, newsize) :
malloc(newsize);
/* realloc(NULL, newsize) is equivalent to malloc(newsize). */
pathv = realloc((void *)pglob->gl_pathv, newsize);
if (pathv == NULL)
return (GLOB_NOSPACE);