Skip to content

Commit

Permalink
Use zstd error enum instead of magic number
Browse files Browse the repository at this point in the history
  • Loading branch information
Genwald committed Dec 24, 2019
1 parent 065f517 commit 7e79a25
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion source/mod_installer.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <queue>
#define ZSTD_STATIC_LINKING_ONLY
#include <zstd.h>
#include <zstd_errors.h>
#include "utils.h"
#include "arcReader.h"
#include <stdarg.h>
Expand Down Expand Up @@ -91,7 +92,7 @@ bool compressFile(const char* path, u64 compSize, u64 &dataSize, char* outBuff,
do {
ZSTD_CCtx_setParameter(compContext, ZSTD_c_compressionLevel, compLvl++);
dataSize = ZSTD_compress2(compContext, outBuff, bufSize, inBuff, inSize);
if(ZSTD_isError(dataSize) && dataSize != 0xffffffffffffffba)
if(ZSTD_isError(dataSize) && ZSTD_getErrorCode(dataSize) != ZSTD_error_dstSize_tooSmall)
log("%s Error at lvl %d: %lx %s\n", path, compLvl, dataSize, ZSTD_getErrorName(dataSize));
if(!ZSTD_isError(dataSize) && dataSize > compSize) {
debug_log("Compressed \"%s\" to %lu bytes, %lu bytes away from goal, at level %d.\n", path, dataSize, dataSize - compSize, compLvl-1);
Expand Down

0 comments on commit 7e79a25

Please sign in to comment.