diff options
author | marcel <marcel@FreeBSD.org> | 2012-12-01 17:50:39 +0000 |
---|---|---|
committer | marcel <marcel@FreeBSD.org> | 2012-12-01 17:50:39 +0000 |
commit | e0cbca43aafc47c5c47db73820ede29110da0d0d (patch) | |
tree | 7f798b2ef53898e390e710b9493d4e7ad7a44ca8 /lib/libc | |
parent | 5192abbac636f4d423299ad2010b603072124621 (diff) | |
download | FreeBSD-src-e0cbca43aafc47c5c47db73820ede29110da0d0d.zip FreeBSD-src-e0cbca43aafc47c5c47db73820ede29110da0d0d.tar.gz |
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.
Diffstat (limited to 'lib/libc')
-rw-r--r-- | lib/libc/gen/glob.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/lib/libc/gen/glob.c b/lib/libc/gen/glob.c index 07eeaa8..3c5020c 100644 --- a/lib/libc/gen/glob.c +++ b/lib/libc/gen/glob.c @@ -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); |