]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
minor coding style changes
authorYann Collet <cyan@fb.com>
Mon, 12 Dec 2016 00:03:23 +0000 (01:03 +0100)
committerYann Collet <cyan@fb.com>
Mon, 12 Dec 2016 00:03:23 +0000 (01:03 +0100)
programs/util.h

index fd07c348ab9ce29402aa0b0bc3024b41fc0b2974..012c20c49061a83d22733ad75cb84965d34173a3 100644 (file)
@@ -25,7 +25,7 @@ extern "C" {
 #  define _CRT_SECURE_NO_DEPRECATE   /* VS2005 */
 #  pragma warning(disable : 4127)    /* disable: C4127: conditional expression is constant */
 #if _MSC_VER <= 1800                 /* (1800 = Visual Studio 2013) */
-    #define snprintf sprintf_s       /* snprintf unsupported by Visual <= 2013 */
+#  define snprintf sprintf_s       /* snprintf unsupported by Visual <= 2013 */
 #endif
 #endif
 
@@ -49,11 +49,11 @@ extern "C" {
 #include <sys/types.h>  /* stat, utime */
 #include <sys/stat.h>   /* stat */
 #if defined(_MSC_VER)
-       #include <sys/utime.h>   /* utime */
-       #include <io.h>          /* _chmod */
+#  include <sys/utime.h>   /* utime */
+#  include <io.h>          /* _chmod */
 #else
-       #include <unistd.h>     /* chown, stat */
-       #include <utime.h>      /* utime */
+#  include <unistd.h>     /* chown, stat */
+#  include <utime.h>      /* utime */
 #endif
 #include <time.h>       /* time */
 #include <errno.h>
@@ -406,16 +406,15 @@ UTIL_STATIC const char** UTIL_createFileList(const char **inputNames, unsigned i
 {
     size_t pos;
     unsigned i, nbFiles;
-    char *bufend, *buf;
+    char* buf = (char*)malloc(LIST_SIZE_INCREASE);
+    char* bufend = buf + LIST_SIZE_INCREASE;
     const char** fileTable;
 
-    buf = (char*)malloc(LIST_SIZE_INCREASE);
     if (!buf) return NULL;
-    bufend = buf + LIST_SIZE_INCREASE;
 
     for (i=0, pos=0, nbFiles=0; i<inputNamesNb; i++) {
         if (!UTIL_isDirectory(inputNames[i])) {
-            size_t len = strlen(inputNames[i]);
+            size_t const len = strlen(inputNames[i]);
             if (buf + pos + len >= bufend) {
                 ptrdiff_t newListSize = (bufend - buf) + LIST_SIZE_INCREASE;
                 buf = (char*)UTIL_realloc(buf, newListSize);
@@ -437,8 +436,7 @@ UTIL_STATIC const char** UTIL_createFileList(const char **inputNames, unsigned i
     fileTable = (const char**)malloc((nbFiles+1) * sizeof(const char*));
     if (!fileTable) { free(buf); return NULL; }
 
-    for (i=0, pos=0; i<nbFiles; i++)
-    {
+    for (i=0, pos=0; i<nbFiles; i++) {
         fileTable[i] = buf + pos;
         pos += strlen(fileTable[i]) + 1;
     }