]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
fixed up freeCCtx() removed BYTE since it wasn't being used
authorPaul Cruz <paulcruz74@fb.com>
Wed, 12 Jul 2017 23:50:43 +0000 (16:50 -0700)
committerPaul Cruz <paulcruz74@fb.com>
Wed, 12 Jul 2017 23:50:43 +0000 (16:50 -0700)
contrib/adaptive-compression/adapt.c

index 67fb7564690f166ad30e233aff7763635c39b22d..3cafbca3070dc7359e2457008ed3f41762b0206f 100644 (file)
@@ -25,7 +25,6 @@
 #define DEFAULT_DISPLAY_LEVEL 1
 #define DEFAULT_COMPRESSION_LEVEL 6
 #define DEFAULT_ADAPT_PARAM 1
-typedef unsigned char BYTE;
 
 static int g_displayLevel = DEFAULT_DISPLAY_LEVEL;
 static unsigned g_compressionLevel = DEFAULT_COMPRESSION_LEVEL;
@@ -106,23 +105,26 @@ static void freeCompressionJobs(adaptCCtx* ctx)
 static int freeCCtx(adaptCCtx* ctx)
 {
     if (!ctx) return 0;
-    int const compressedMutexError = pthread_mutex_destroy(&ctx->jobCompressed_mutex);
-    int const compressedCondError = pthread_cond_destroy(&ctx->jobCompressed_cond);
-    int const readyMutexError = pthread_mutex_destroy(&ctx->jobReady_mutex);
-    int const readyCondError = pthread_cond_destroy(&ctx->jobReady_cond);
-    int const allJobsMutexError = pthread_mutex_destroy(&ctx->allJobsCompleted_mutex);
-    int const allJobsCondError = pthread_cond_destroy(&ctx->allJobsCompleted_cond);
-    int const jobWriteMutexError = pthread_mutex_destroy(&ctx->jobWrite_mutex);
-    int const jobWriteCondError = pthread_cond_destroy(&ctx->jobWrite_cond);
-    int const fileCloseError =  (ctx->dstFile != NULL && ctx->dstFile != stdout) ? fclose(ctx->dstFile) : 0;
-    int const cctxError = ZSTD_isError(ZSTD_freeCCtx(ctx->cctx)) ? 1 : 0;
-    free(ctx->input.buffer.start);
-    if (ctx->jobs){
-        freeCompressionJobs(ctx);
-        free(ctx->jobs);
-    }
-    free(ctx);
-    return compressedMutexError | compressedCondError | readyMutexError | readyCondError | fileCloseError | allJobsMutexError | allJobsCondError | jobWriteMutexError | jobWriteCondError | cctxError;
+    {
+        int error = 0;
+        error |= pthread_mutex_destroy(&ctx->jobCompressed_mutex);
+        error |= pthread_cond_destroy(&ctx->jobCompressed_cond);
+        error |= pthread_mutex_destroy(&ctx->jobReady_mutex);
+        error |= pthread_cond_destroy(&ctx->jobReady_cond);
+        error |= pthread_mutex_destroy(&ctx->allJobsCompleted_mutex);
+        error |= pthread_cond_destroy(&ctx->allJobsCompleted_cond);
+        error |= pthread_mutex_destroy(&ctx->jobWrite_mutex);
+        error |= pthread_cond_destroy(&ctx->jobWrite_cond);
+        error |=  (ctx->dstFile != NULL && ctx->dstFile != stdout) ? fclose(ctx->dstFile) : 0;
+        error |= ZSTD_isError(ZSTD_freeCCtx(ctx->cctx));
+        free(ctx->input.buffer.start);
+        if (ctx->jobs){
+            freeCompressionJobs(ctx);
+            free(ctx->jobs);
+        }
+        free(ctx);
+        return error;
+    }
 }
 
 static adaptCCtx* createCCtx(unsigned numJobs, const char* const outFilename)