]> Sergey Matveev's repositories - tofuproxy.git/commitdiff
My current C formatting style differs
authorSergey Matveev <stargrave@stargrave.org>
Sun, 19 Mar 2023 16:44:31 +0000 (19:44 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Sun, 19 Mar 2023 16:44:44 +0000 (19:44 +0300)
cmd/zstd/enzstd.c
cmd/zstd/unzstd.c

index 6dbbe985a6367080b0384a4a89151e512210d78e..34bf3757bb91260c9916df8651ef66435044fabe 100644 (file)
@@ -47,19 +47,19 @@ main(int argc, char **argv)
         return EXIT_FAILURE;
     }
 
-    char *src      = NULL;
-    char *dst      = NULL;
-    int rc         = EXIT_FAILURE;
+    char *src = NULL;
+    char *dst = NULL;
+    int rc = EXIT_FAILURE;
     size_t srcSize = 8;
-    src            = malloc(srcSize);
+    src = malloc(srcSize);
     if (src == NULL) {
         fprintf(stderr, "can not allocate memory: %zu\n", srcSize);
         goto Exit;
     }
-    size_t dstSize     = 0;
+    size_t dstSize = 0;
     size_t srcWantSize = 0;
     size_t dstWantSize = 0;
-    size_t n           = 0;
+    size_t n = 0;
     for (;;) {
         n = fread(src, 1, 8, stdin);
         if (n < 8) {
@@ -76,7 +76,7 @@ main(int argc, char **argv)
         if (srcWantSize > srcSize) {
             free(src);
             srcSize = srcWantSize;
-            src     = malloc(srcSize);
+            src = malloc(srcSize);
             if (src == NULL) {
                 fprintf(stderr, "can not allocate memory: %zu\n", srcSize);
                 goto Exit;
@@ -91,7 +91,7 @@ main(int argc, char **argv)
         if (dstWantSize > dstSize) {
             free(dst);
             dstSize = dstWantSize;
-            dst     = malloc(dstSize);
+            dst = malloc(dstSize);
             if (dst == NULL) {
                 fprintf(stderr, "can not allocate memory: %zu\n", dstSize);
                 goto Exit;
index 823515c1f898585e4065a5d874cfe506f1748ecc..faeda1559fa5c03ac740a177279fe4bf540537cc 100644 (file)
@@ -56,17 +56,17 @@ main(int argc, char **argv)
         fputs("can not initialize ZSTD_DCtx\n", stderr);
         return 1;
     }
-    int rc                 = EXIT_FAILURE;
-    char *bufIn            = NULL;
-    char *bufOut           = NULL;
+    int rc = EXIT_FAILURE;
+    char *bufIn = NULL;
+    char *bufOut = NULL;
     const size_t bufInSize = ZSTD_DStreamInSize();
-    bufIn                  = malloc(bufInSize);
+    bufIn = malloc(bufInSize);
     if (bufIn == NULL) {
         fputs("no memory\n", stderr);
         goto Exit;
     }
     const size_t bufOutSize = ZSTD_DStreamOutSize();
-    bufOut                  = malloc(bufOutSize);
+    bufOut = malloc(bufOutSize);
     if (bufOut == NULL) {
         fputs("no memory\n", stderr);
         goto Exit;
@@ -74,16 +74,16 @@ main(int argc, char **argv)
 
     unsigned long long bufSize = 0;
 
-    ZSTD_inBuffer bIn   = {bufIn, 0, 0};
+    ZSTD_inBuffer bIn = {bufIn, 0, 0};
     ZSTD_outBuffer bOut = {bufOut, 0, 0};
 
-    bool isEmpty      = true;
-    bool lastBlock    = false;
-    size_t n          = 0;
-    size_t written    = 0;
-    size_t offset     = 0;
+    bool isEmpty = true;
+    bool lastBlock = false;
+    size_t n = 0;
+    size_t written = 0;
+    size_t offset = 0;
     size_t offsetPrev = 0;
-    size_t zCode      = 0;
+    size_t zCode = 0;
 ReadAgain:
     for (;;) {
         n = fread(bufIn, 1, bufInSize, stdin);
@@ -98,7 +98,7 @@ ReadAgain:
         if (n >= 8 && le32dec(bufIn) == 0x184D2A5D) {
             // dictionary frame
             size_t dictSize = (size_t)le32dec(bufIn + 4);
-            char *dict      = malloc(dictSize);
+            char *dict = malloc(dictSize);
             if (dict == NULL) {
                 fprintf(stderr, "insufficient memory for dictionary: %zu\n", dictSize);
                 goto Exit;
@@ -106,13 +106,13 @@ ReadAgain:
             const size_t alreadyRead = n - 8;
             memcpy(dict, bufIn + 8, alreadyRead);
             errno = 0;
-            n     = fread(dict + alreadyRead, 1, dictSize - alreadyRead, stdin);
+            n = fread(dict + alreadyRead, 1, dictSize - alreadyRead, stdin);
             if (n != dictSize - alreadyRead) {
                 perror("can not read dictionary data");
                 free(dict);
                 goto Exit;
             }
-            offset     = dictSize + 8;
+            offset = dictSize + 8;
             offsetPrev = offset;
             if (fdOff != NULL) {
                 fprintf(fdOff, "%zu\t0\n", offset);
@@ -172,13 +172,13 @@ ReadAgain:
                 goto Exit;
             }
         }
-        isEmpty  = false;
+        isEmpty = false;
         bIn.size = n;
-        bIn.pos  = 0;
+        bIn.pos = 0;
         while (bIn.pos < bIn.size) {
             bOut.size = bufOutSize;
-            bOut.pos  = 0;
-            zCode     = ZSTD_decompressStream(ctx, &bOut, &bIn);
+            bOut.pos = 0;
+            zCode = ZSTD_decompressStream(ctx, &bOut, &bIn);
             if ((zCode != 0) && (ZSTD_isError(zCode))) {
                 fprintf(stderr, "can not decompress: %s\n", ZSTD_getErrorName(zCode));
                 goto Exit;
@@ -195,7 +195,7 @@ ReadAgain:
                     fprintf(fdOff, "%zu\t%zu\n", offset - offsetPrev, written);
                 }
                 offsetPrev = offset + bIn.pos;
-                written    = 0;
+                written = 0;
             }
         }
         if (lastBlock) {