mirror of
https://github.com/facebook/zstd.git
synced 2024-11-24 01:46:45 +08:00
minor variation of rescale fix
This commit is contained in:
parent
e93f1f5893
commit
c261f71f6a
9
NEWS
9
NEWS
@ -1,14 +1,15 @@
|
||||
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
|
||||
|
@ -33,6 +33,7 @@ typedef enum { ZSTDcs_created=0, ZSTDcs_init, ZSTDcs_ongoing, ZSTDcs_ending } ZS
|
||||
/*-*************************************
|
||||
* 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; }
|
||||
|
||||
|
||||
@ -2274,16 +2275,17 @@ static size_t ZSTD_compress_generic (ZSTD_CCtx* cctx,
|
||||
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;
|
||||
|
@ -1,10 +1,10 @@
|
||||
#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 };
|
||||
@ -57,6 +57,8 @@ int main(int argc, const char** argv) {
|
||||
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];
|
||||
}
|
||||
@ -66,6 +68,7 @@ int main(int argc, const char** argv) {
|
||||
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;
|
||||
}
|
||||
@ -79,6 +82,7 @@ int main(int argc, const char** argv) {
|
||||
pos += block;
|
||||
compressed += block;
|
||||
}
|
||||
printf("Compression completed successfully (no error triggered)\n");
|
||||
free(srcBuffer);
|
||||
free(dstBuffer);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user