Merge pull request #2378 from senhuang42/free_cress_ptr

[minor] Pass cRess_t by const ptr instead of by value
This commit is contained in:
sen 2020-11-01 20:33:25 -05:00 committed by GitHub
commit f54109c589
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1007,12 +1007,12 @@ static cRess_t FIO_createCResources(FIO_prefs_t* const prefs,
return ress; return ress;
} }
static void FIO_freeCResources(cRess_t ress) static void FIO_freeCResources(const cRess_t* const ress)
{ {
free(ress.srcBuffer); free(ress->srcBuffer);
free(ress.dstBuffer); free(ress->dstBuffer);
free(ress.dictBuffer); free(ress->dictBuffer);
ZSTD_freeCStream(ress.cctx); /* never fails */ ZSTD_freeCStream(ress->cctx); /* never fails */
} }
@ -1722,7 +1722,7 @@ int FIO_compressFilename(FIO_ctx_t* const fCtx, FIO_prefs_t* const prefs, const
#define DISPLAY_LEVEL_DEFAULT 2 #define DISPLAY_LEVEL_DEFAULT 2
FIO_freeCResources(ress); FIO_freeCResources(&ress);
return result; return result;
} }
@ -1802,7 +1802,7 @@ int FIO_compressMultipleFilenames(FIO_ctx_t* const fCtx,
assert(outFileName != NULL || suffix != NULL); assert(outFileName != NULL || suffix != NULL);
if (outFileName != NULL) { /* output into a single destination (stdout typically) */ if (outFileName != NULL) { /* output into a single destination (stdout typically) */
if (FIO_removeMultiFilesWarning(fCtx, prefs, outFileName, 1 /* displayLevelCutoff */)) { if (FIO_removeMultiFilesWarning(fCtx, prefs, outFileName, 1 /* displayLevelCutoff */)) {
FIO_freeCResources(ress); FIO_freeCResources(&ress);
return 1; return 1;
} }
ress.dstFile = FIO_openDstFile(fCtx, prefs, NULL, outFileName); ress.dstFile = FIO_openDstFile(fCtx, prefs, NULL, outFileName);
@ -1855,7 +1855,7 @@ int FIO_compressMultipleFilenames(FIO_ctx_t* const fCtx,
fCtx->totalBytesInput, fCtx->totalBytesOutput); fCtx->totalBytesInput, fCtx->totalBytesOutput);
} }
FIO_freeCResources(ress); FIO_freeCResources(&ress);
return error; return error;
} }