}
{ size_t const cSize = ZSTD_compressContinue(cctx, dst, dstCapacity, src, srcSize);
if (ZSTD_isError(cSize)) return cSize;
+
{ size_t const endSize = ZSTD_compressEnd(cctx, (char*)dst+cSize, dstCapacity-cSize);
if (ZSTD_isError(endSize)) return endSize;
return cSize + endSize;
{ /* for srcSize <= 256 KB */
/* W, C, H, S, L, T, strat */
{ 0, 0, 0, 0, 0, 0, ZSTD_fast }, /* level 0 */
- { 18, 14, 15, 1, 6, 4, ZSTD_fast }, /* level 1 */
+ { 18, 13, 14, 1, 6, 4, ZSTD_fast }, /* level 1 */
{ 18, 14, 16, 1, 5, 4, ZSTD_fast }, /* level 2 */
{ 18, 14, 17, 1, 5, 4, ZSTD_fast }, /* level 3.*/
{ 18, 14, 15, 4, 4, 4, ZSTD_greedy }, /* level 4 */
const BYTE* ip = (const BYTE*)seqStart;
const BYTE* const iend = ip + seqSize;
BYTE* const ostart = (BYTE* const)dst;
- BYTE* op = ostart;
BYTE* const oend = ostart + maxDstSize;
+ BYTE* op = ostart;
const BYTE* litPtr = dctx->litPtr;
const BYTE* const litLimit_8 = litPtr + dctx->litBufSize - 8;
const BYTE* const litEnd = litPtr + dctx->litSize;
- U32* DTableLL = dctx->LLTable;
- U32* DTableML = dctx->MLTable;
- U32* DTableOffb = dctx->OffTable;
+ FSE_DTable* DTableLL = dctx->LLTable;
+ FSE_DTable* DTableML = dctx->MLTable;
+ FSE_DTable* DTableOffb = dctx->OffTable;
const BYTE* const base = (const BYTE*) (dctx->base);
const BYTE* const vBase = (const BYTE*) (dctx->vBase);
const BYTE* const dictEnd = (const BYTE*) (dctx->dictEnd);
int nbSeq;
/* Build Decoding Tables */
- { size_t const seqHSize = ZSTD_decodeSeqHeaders(&nbSeq,
- DTableLL, DTableML, DTableOffb,
- ip, seqSize);
+ { size_t const seqHSize = ZSTD_decodeSeqHeaders(&nbSeq, DTableLL, DTableML, DTableOffb, ip, seqSize);
if (ZSTD_isError(seqHSize)) return seqHSize;
ip += seqHSize;
}
memset(&sequence, 0, sizeof(sequence));
sequence.offset = REPCODE_STARTVALUE;
- for (U32 i=0; i<ZSTD_REP_INIT; i++)
- seqState.prevOffset[i] = REPCODE_STARTVALUE;
+ { U32 i; for (i=0; i<ZSTD_REP_INIT; i++) seqState.prevOffset[i] = REPCODE_STARTVALUE; }
{ size_t const errorCode = BIT_initDStream(&(seqState.DStream), ip, iend-ip);
if (ERR_isError(errorCode)) return ERROR(corruption_detected); }
FSE_initDState(&(seqState.stateLL), &(seqState.DStream), DTableLL);
FSE_initDState(&(seqState.stateOffb), &(seqState.DStream), DTableOffb);
FSE_initDState(&(seqState.stateML), &(seqState.DStream), DTableML);
- for ( ; (BIT_reloadDStream(&(seqState.DStream)) <= BIT_DStream_completed) && nbSeq ; ) {
- size_t oneSeqSize;
- nbSeq--;
+ for ( ; (BIT_reloadDStream(&(seqState.DStream)) <= BIT_DStream_completed) && nbSeq-- ; ) {
ZSTD_decodeSequence(&sequence, &seqState);
-#if 0 /* for debug */
- { U32 pos = (U32)(op-base);
- // if ((pos > 200802300) && (pos < 200802400))
- printf("Dpos %6u :%5u literals & match %3u bytes at distance %6u \n",
- pos, (U32)sequence.litLength, (U32)sequence.matchLength, (U32)sequence.offset);
- }
-#endif
- oneSeqSize = ZSTD_execSequence(op, oend, sequence, &litPtr, litLimit_8, base, vBase, dictEnd);
- if (ZSTD_isError(oneSeqSize)) return oneSeqSize;
- op += oneSeqSize;
- }
+ { size_t const oneSeqSize = ZSTD_execSequence(op, oend, sequence, &litPtr, litLimit_8, base, vBase, dictEnd);
+ if (ZSTD_isError(oneSeqSize)) return oneSeqSize;
+ op += oneSeqSize;
+ } }
/* check if reached exact end */
if (nbSeq) return ERROR(corruption_detected);
if (srcSize >= ZSTD_BLOCKSIZE_MAX) return ERROR(srcSize_wrong);
/* Decode literals sub-block */
- { size_t const litCSize = ZSTD_decodeLiteralsBlock(dctx, src, srcSize);
- if (ZSTD_isError(litCSize)) return litCSize;
- ip += litCSize;
- srcSize -= litCSize; }
-
+ { size_t const litCSize = ZSTD_decodeLiteralsBlock(dctx, src, srcSize);
+ if (ZSTD_isError(litCSize)) return litCSize;
+ ip += litCSize;
+ srcSize -= litCSize;
+ }
return ZSTD_decompressSequences(dctx, dst, dstCapacity, ip, srcSize);
}
if (argc<1) { badusage(exename); return 1; }
- for(i=1; i<argc; i++)
- {
+ for(i=1; i<argc; i++) {
char* argument = argv[i];
if(!argument) continue; /* Protection if argument empty */
/* Sample compressibility (when no file provided) */
case 'P':
argument++;
- {
- U32 proba32 = 0;
- while ((argument[0]>= '0') && (argument[0]<= '9')) {
- proba32 *= 10;
- proba32 += argument[0] - '0';
- argument++;
- }
+ { U32 proba32 = 0;
+ while ((argument[0]>= '0') && (argument[0]<= '9'))
+ proba32 = (proba32*10) + (*argument++ - '0');
g_compressibility = (double)proba32 / 100.;
}
break;
g_params.strategy = (ZSTD_strategy)(*argument++ - '0');
continue;
case 'L':
- {
- int cLevel = 0;
+ { int cLevel = 0;
argument++;
while ((*argument>= '0') && (*argument<='9'))
cLevel *= 10, cLevel += *argument++ - '0';
case 'T':
argument++;
g_target = 0;
- while ((*argument >= '0') && (*argument <= '9')) {
- g_target *= 10;
- g_target += *argument - '0';
- argument++;
- }
+ while ((*argument >= '0') && (*argument <= '9'))
+ g_target = (g_target*10) + (*argument++ - '0');
break;
/* cut input into blocks */
case 'B':
- {
- g_blockSize = 0;
- argument++;
- while ((*argument >='0') && (*argument <='9'))
- g_blockSize *= 10, g_blockSize += *argument++ - '0';
- if (*argument=='K') g_blockSize<<=10, argument++; /* allows using KB notation */
- if (*argument=='M') g_blockSize<<=20, argument++;
- if (*argument=='B') argument++;
- DISPLAY("using %u KB block size \n", g_blockSize>>10);
- }
+ g_blockSize = 0;
+ argument++;
+ while ((*argument >='0') && (*argument <='9'))
+ g_blockSize = (g_blockSize*10) + (*argument++ - '0');
+ if (*argument=='K') g_blockSize<<=10, argument++; /* allows using KB notation */
+ if (*argument=='M') g_blockSize<<=20, argument++;
+ if (*argument=='B') argument++;
+ DISPLAY("using %u KB block size \n", g_blockSize>>10);
break;
/* Unknown command */
}
}
continue;
- }
+ } /* if (argument[0]=='-') */
/* first provided filename is input */
if (!input_filename) { input_filename=argument; filenamesStart=i; continue; }