v1.1.2
-Improved : faster decompression speed at ultra compression settings and in 32-bits mode
+Improved : faster decompression speed at ultra compression settings and 32-bits mode
cli : new : gzstd, experimental version able to decode .gz files, by Przemyslaw Skibinski
cli : new : preserve file attributes
cli : new : added zstdless and zstdgrep tools
cli : fixed : status displays total amount decoded, even for file consisting of multiple frames (like pzstd)
cli : fixed : zstdcat
+lib : fixed : bug in streaming compression, by Nick Terrell
lib : changed : only public ZSTD_ symbols are now exposed
-API : changed : zbuff prototypes now generate deprecation warnings
-API : changed : streaming decompression implicit reset on starting new frame
-API : added experimental : dictID retrieval functions
+API : zbuff : changed : prototypes now generate deprecation warnings
+API : streaming : decompression : changed : implicit reset on starting new frames without init
+API : experimental : added : dictID retrieval functions
zlib_wrapper : added support for gz* functions, by Przemyslaw Skibinski
Changed : zbuff source files moved to lib/deprecated
Changed : reduced stack memory use
/*-*************************************
* Helper functions
***************************************/
+#define ZSTD_STATIC_ASSERT(c) { enum { ZSTD_static_assert = 1/(int)(!!(c)) }; }
size_t ZSTD_compressBound(size_t srcSize) { return FSE_compressBound(srcSize) + 12; }
if (remaining < blockSize) blockSize = remaining;
/* preemptive overflow correction */
- if (cctx->lowLimit > (1<<30)) {
+ if (cctx->lowLimit > (2U<<30)) {
U32 const btplus = (cctx->params.cParams.strategy == ZSTD_btlazy2) | (cctx->params.cParams.strategy == ZSTD_btopt) | (cctx->params.cParams.strategy == ZSTD_btopt2);
U32 const chainMask = (1 << (cctx->params.cParams.chainLog - btplus)) - 1;
- U32 const supLog = MAX(cctx->params.cParams.windowLog, 17 /* blockSize */);
- U32 const newLowLimit = (cctx->lowLimit & chainMask) + (1 << supLog); /* preserve position % chainSize, ensure current-repcode doesn't underflow */
- U32 const correction = cctx->lowLimit - newLowLimit;
+ U32 const current = (U32)(ip - cctx->base);
+ U32 const newCurrent = (current & chainMask) + (1 << cctx->params.cParams.windowLog);
+ U32 const correction = current - newCurrent;
+ ZSTD_STATIC_ASSERT(ZSTD_WINDOWLOG_MAX_64 <= 30);
ZSTD_reduceIndex(cctx, correction);
cctx->base += correction;
cctx->dictBase += correction;
- cctx->lowLimit = newLowLimit;
+ cctx->lowLimit -= correction;
cctx->dictLimit -= correction;
if (cctx->nextToUpdate < correction) cctx->nextToUpdate = 0;
else cctx->nextToUpdate -= correction;
-#define ZSTD_STATIC_LINKING_ONLY
-#include "zstd.h"
-#include "mem.h"
#include <stdio.h>
#include <stddef.h>
#include <stdlib.h>
#include <stdint.h>
+#include "mem.h"
+#define ZSTD_STATIC_LINKING_ONLY
+#include "zstd.h"
int compress(ZSTD_CStream *ctx, ZSTD_outBuffer out, const void *data, size_t size) {
ZSTD_inBuffer in = { data, size, 0 };
const char match[] = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
const size_t randomData = (1 << windowLog) - 2*sizeof(match);
size_t i;
+ printf("\n === Long Match Test === \n");
+ printf("Creating random data to produce long matches \n");
for (i = 0; i < sizeof(match); ++i) {
srcBuffer[i] = match[i];
}
for (i = 0; i < sizeof(match); ++i) {
srcBuffer[sizeof(match) + randomData + i] = match[i];
}
+ printf("Compressing, trying to generate a segfault \n");
if (compress(ctx, out, srcBuffer, size)) {
return 1;
}
pos += block;
compressed += block;
}
+ printf("Compression completed successfully (no error triggered)\n");
free(srcBuffer);
free(dstBuffer);
}