Author: marcel
Date: Sat Dec  1 17:50:39 2012
New Revision: 243759
URL: http://svnweb.freebsd.org/changeset/base/243759

Log:
  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.

Modified:
  head/lib/libc/gen/glob.c

Modified: head/lib/libc/gen/glob.c
==============================================================================
--- head/lib/libc/gen/glob.c    Sat Dec  1 17:44:06 2012        (r243758)
+++ head/lib/libc/gen/glob.c    Sat Dec  1 17:50:39 2012        (r243759)
@@ -715,9 +715,8 @@ globextend(const Char *path, glob_t *pgl
        }
 
        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);
 
_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "[email protected]"

Reply via email to