1
0
mirror of https://github.com/facebook/zstd.git synced 2025-08-05 19:15:58 +03:00

unified ctx naming convention

This commit is contained in:
Yann Collet
2015-10-21 14:39:26 +01:00
parent f42803e5b4
commit 353c5d26cf
5 changed files with 69 additions and 84 deletions

View File

@@ -153,8 +153,6 @@ static const size_t ZSTD_frameHeaderSize = 4;
/* ******************************************************* /* *******************************************************
* Memory operations * Memory operations
**********************************************************/ **********************************************************/
static size_t ZSTD_read_ARCH(const void* p) { size_t r; memcpy(&r, p, sizeof(r)); return r; }
static void ZSTD_copy4(void* dst, const void* src) { memcpy(dst, src, 4); } static void ZSTD_copy4(void* dst, const void* src) { memcpy(dst, src, 4); }
static void ZSTD_copy8(void* dst, const void* src) { memcpy(dst, src, 8); } static void ZSTD_copy8(void* dst, const void* src) { memcpy(dst, src, 8); }
@@ -208,7 +206,7 @@ void ZSTD_resetSeqStore(seqStore_t* ssPtr)
} }
struct ZSTD_Cctx_s struct ZSTD_CCtx_s
{ {
const BYTE* base; const BYTE* base;
U32 current; U32 current;
@@ -223,7 +221,7 @@ struct ZSTD_Cctx_s
}; };
void ZSTD_resetCCtx(ZSTD_Cctx* ctx) void ZSTD_resetCCtx(ZSTD_CCtx* ctx)
{ {
ctx->base = NULL; ctx->base = NULL;
ctx->seqStore.buffer = ctx->buffer; ctx->seqStore.buffer = ctx->buffer;
@@ -236,15 +234,15 @@ void ZSTD_resetCCtx(ZSTD_Cctx* ctx)
memset(ctx->hashTable, 0, HASH_TABLESIZE*4); memset(ctx->hashTable, 0, HASH_TABLESIZE*4);
} }
ZSTD_Cctx* ZSTD_createCCtx(void) ZSTD_CCtx* ZSTD_createCCtx(void)
{ {
ZSTD_Cctx* ctx = (ZSTD_Cctx*) malloc( sizeof(ZSTD_Cctx) ); ZSTD_CCtx* ctx = (ZSTD_CCtx*) malloc( sizeof(ZSTD_CCtx) );
if (ctx==NULL) return NULL; if (ctx==NULL) return NULL;
ZSTD_resetCCtx(ctx); ZSTD_resetCCtx(ctx);
return ctx; return ctx;
} }
size_t ZSTD_freeCCtx(ZSTD_Cctx* ctx) size_t ZSTD_freeCCtx(ZSTD_CCtx* ctx)
{ {
free(ctx); free(ctx);
return 0; return 0;
@@ -290,7 +288,14 @@ static unsigned ZSTD_highbit(U32 val)
# endif # endif
} }
static unsigned ZSTD_NbCommonBytes (register size_t val)
/* *************************************
* Function body to include
***************************************/
#include "mem.h"
static size_t ZSTD_read_ARCH(const void* p) { size_t r; memcpy(&r, p, sizeof(r)); return r; }
MEM_STATIC unsigned ZSTD_NbCommonBytes (register size_t val)
{ {
if (MEM_isLittleEndian()) if (MEM_isLittleEndian())
{ {
@@ -300,7 +305,7 @@ static unsigned ZSTD_NbCommonBytes (register size_t val)
unsigned long r = 0; unsigned long r = 0;
_BitScanForward64( &r, (U64)val ); _BitScanForward64( &r, (U64)val );
return (int)(r>>3); return (int)(r>>3);
# elif defined(__GNUC__) && (GCC_VERSION >= 304) && !defined(LZ4_FORCE_SW_BITCOUNT) # elif defined(__GNUC__) && (__GNUC__ >= 3) && !defined(LZ4_FORCE_SW_BITCOUNT)
return (__builtin_ctzll((U64)val) >> 3); return (__builtin_ctzll((U64)val) >> 3);
# else # else
static const int DeBruijnBytePos[64] = { 0, 0, 0, 0, 0, 1, 1, 2, 0, 3, 1, 3, 1, 4, 2, 7, 0, 2, 3, 6, 1, 5, 3, 5, 1, 3, 4, 4, 2, 5, 6, 7, 7, 0, 1, 2, 3, 3, 4, 6, 2, 6, 5, 5, 3, 4, 5, 6, 7, 1, 2, 4, 6, 4, 4, 5, 7, 2, 6, 5, 7, 6, 7, 7 }; static const int DeBruijnBytePos[64] = { 0, 0, 0, 0, 0, 1, 1, 2, 0, 3, 1, 3, 1, 4, 2, 7, 0, 2, 3, 6, 1, 5, 3, 5, 1, 3, 4, 4, 2, 5, 6, 7, 7, 0, 1, 2, 3, 3, 4, 6, 2, 6, 5, 5, 3, 4, 5, 6, 7, 1, 2, 4, 6, 4, 4, 5, 7, 2, 6, 5, 7, 6, 7, 7 };
@@ -313,7 +318,7 @@ static unsigned ZSTD_NbCommonBytes (register size_t val)
unsigned long r; unsigned long r;
_BitScanForward( &r, (U32)val ); _BitScanForward( &r, (U32)val );
return (int)(r>>3); return (int)(r>>3);
# elif defined(__GNUC__) && (GCC_VERSION >= 304) && !defined(LZ4_FORCE_SW_BITCOUNT) # elif defined(__GNUC__) && (__GNUC__ >= 3) && !defined(LZ4_FORCE_SW_BITCOUNT)
return (__builtin_ctz((U32)val) >> 3); return (__builtin_ctz((U32)val) >> 3);
# else # else
static const int DeBruijnBytePos[32] = { 0, 0, 3, 0, 3, 1, 3, 0, 3, 2, 2, 1, 3, 2, 0, 1, 3, 3, 1, 2, 2, 2, 2, 0, 3, 1, 2, 0, 1, 0, 1, 1 }; static const int DeBruijnBytePos[32] = { 0, 0, 3, 0, 3, 1, 3, 0, 3, 2, 2, 1, 3, 2, 0, 1, 3, 3, 1, 2, 2, 2, 2, 0, 3, 1, 2, 0, 1, 0, 1, 1 };
@@ -329,7 +334,7 @@ static unsigned ZSTD_NbCommonBytes (register size_t val)
unsigned long r = 0; unsigned long r = 0;
_BitScanReverse64( &r, val ); _BitScanReverse64( &r, val );
return (unsigned)(r>>3); return (unsigned)(r>>3);
# elif defined(__GNUC__) && (GCC_VERSION >= 304) && !defined(LZ4_FORCE_SW_BITCOUNT) # elif defined(__GNUC__) && (__GNUC__ >= 3) && !defined(LZ4_FORCE_SW_BITCOUNT)
return (__builtin_clzll(val) >> 3); return (__builtin_clzll(val) >> 3);
# else # else
unsigned r; unsigned r;
@@ -346,7 +351,7 @@ static unsigned ZSTD_NbCommonBytes (register size_t val)
unsigned long r = 0; unsigned long r = 0;
_BitScanReverse( &r, (unsigned long)val ); _BitScanReverse( &r, (unsigned long)val );
return (unsigned)(r>>3); return (unsigned)(r>>3);
# elif defined(__GNUC__) && (GCC_VERSION >= 304) && !defined(LZ4_FORCE_SW_BITCOUNT) # elif defined(__GNUC__) && (__GNUC__ >= 3) && !defined(LZ4_FORCE_SW_BITCOUNT)
return (__builtin_clz((U32)val) >> 3); return (__builtin_clz((U32)val) >> 3);
# else # else
unsigned r; unsigned r;
@@ -358,7 +363,8 @@ static unsigned ZSTD_NbCommonBytes (register size_t val)
} }
} }
static unsigned ZSTD_count(const BYTE* pIn, const BYTE* pMatch, const BYTE* pInLimit)
MEM_STATIC size_t ZSTD_count(const BYTE* pIn, const BYTE* pMatch, const BYTE* pInLimit)
{ {
const BYTE* const pStart = pIn; const BYTE* const pStart = pIn;
@@ -367,13 +373,13 @@ static unsigned ZSTD_count(const BYTE* pIn, const BYTE* pMatch, const BYTE* pInL
size_t diff = ZSTD_read_ARCH(pMatch) ^ ZSTD_read_ARCH(pIn); size_t diff = ZSTD_read_ARCH(pMatch) ^ ZSTD_read_ARCH(pIn);
if (!diff) { pIn+=sizeof(size_t); pMatch+=sizeof(size_t); continue; } if (!diff) { pIn+=sizeof(size_t); pMatch+=sizeof(size_t); continue; }
pIn += ZSTD_NbCommonBytes(diff); pIn += ZSTD_NbCommonBytes(diff);
return (unsigned)(pIn - pStart); return (size_t)(pIn - pStart);
} }
if (MEM_32bits()) if ((pIn<(pInLimit-3)) && (MEM_read32(pMatch) == MEM_read32(pIn))) { pIn+=4; pMatch+=4; } if (MEM_32bits()) if ((pIn<(pInLimit-3)) && (MEM_read32(pMatch) == MEM_read32(pIn))) { pIn+=4; pMatch+=4; }
if ((pIn<(pInLimit-1)) && (MEM_read16(pMatch) == MEM_read16(pIn))) { pIn+=2; pMatch+=2; } if ((pIn<(pInLimit-1)) && (MEM_read16(pMatch) == MEM_read16(pIn))) { pIn+=2; pMatch+=2; }
if ((pIn<pInLimit) && (*pMatch == *pIn)) pIn++; if ((pIn<pInLimit) && (*pMatch == *pIn)) pIn++;
return (unsigned)(pIn - pStart); return (size_t)(pIn - pStart);
} }
@@ -735,7 +741,7 @@ static int ZSTD_checkMatch(const BYTE* match, const BYTE* ip)
} }
static size_t ZSTD_compressBlock(ZSTD_Cctx* ctx, void* dst, size_t maxDstSize, const void* src, size_t srcSize) static size_t ZSTD_compressBlock(ZSTD_CCtx* ctx, void* dst, size_t maxDstSize, const void* src, size_t srcSize)
{ {
U32* HashTable = (U32*)(ctx->hashTable); U32* HashTable = (U32*)(ctx->hashTable);
seqStore_t* seqStorePtr = &(ctx->seqStore); seqStore_t* seqStorePtr = &(ctx->seqStore);
@@ -794,7 +800,7 @@ static size_t ZSTD_compressBlock(ZSTD_Cctx* ctx, void* dst, size_t maxDstSize, c
} }
size_t ZSTD_compressBegin(ZSTD_Cctx* ctx, void* dst, size_t maxDstSize) size_t ZSTD_compressBegin(ZSTD_CCtx* ctx, void* dst, size_t maxDstSize)
{ {
/* Sanity check */ /* Sanity check */
if (maxDstSize < ZSTD_frameHeaderSize) return ERROR(dstSize_tooSmall); if (maxDstSize < ZSTD_frameHeaderSize) return ERROR(dstSize_tooSmall);
@@ -809,7 +815,7 @@ size_t ZSTD_compressBegin(ZSTD_Cctx* ctx, void* dst, size_t maxDstSize)
} }
static void ZSTD_scaleDownCtx(ZSTD_Cctx* ctx, const U32 limit) static void ZSTD_scaleDownCtx(ZSTD_CCtx* ctx, const U32 limit)
{ {
int i; int i;
@@ -837,7 +843,7 @@ static void ZSTD_scaleDownCtx(ZSTD_Cctx* ctx, const U32 limit)
} }
static void ZSTD_limitCtx(ZSTD_Cctx* ctx, const U32 limit) static void ZSTD_limitCtx(ZSTD_CCtx* ctx, const U32 limit)
{ {
int i; int i;
@@ -876,7 +882,7 @@ static void ZSTD_limitCtx(ZSTD_Cctx* ctx, const U32 limit)
} }
size_t ZSTD_compressContinue(ZSTD_Cctx* ctx, void* dst, size_t maxDstSize, const void* src, size_t srcSize) size_t ZSTD_compressContinue(ZSTD_CCtx* ctx, void* dst, size_t maxDstSize, const void* src, size_t srcSize)
{ {
const BYTE* const istart = (const BYTE* const)src; const BYTE* const istart = (const BYTE* const)src;
const BYTE* ip = istart; const BYTE* ip = istart;
@@ -943,7 +949,7 @@ size_t ZSTD_compressContinue(ZSTD_Cctx* ctx, void* dst, size_t maxDstSize, const
} }
size_t ZSTD_compressEnd(ZSTD_Cctx* ctx, void* dst, size_t maxDstSize) size_t ZSTD_compressEnd(ZSTD_CCtx* ctx, void* dst, size_t maxDstSize)
{ {
BYTE* op = (BYTE*)dst; BYTE* op = (BYTE*)dst;
@@ -960,7 +966,7 @@ size_t ZSTD_compressEnd(ZSTD_Cctx* ctx, void* dst, size_t maxDstSize)
} }
size_t ZSTD_compressCCtx(ZSTD_Cctx* ctx, void* dst, size_t maxDstSize, const void* src, size_t srcSize) size_t ZSTD_compressCCtx(ZSTD_CCtx* ctx, void* dst, size_t maxDstSize, const void* src, size_t srcSize)
{ {
BYTE* const ostart = (BYTE* const)dst; BYTE* const ostart = (BYTE* const)dst;
BYTE* op = ostart; BYTE* op = ostart;
@@ -991,12 +997,12 @@ size_t ZSTD_compress(void* dst, size_t maxDstSize, const void* src, size_t srcSi
{ {
size_t r; size_t r;
#if defined(ZSTD_HEAPMODE) && (ZSTD_HEAPMODE==1) #if defined(ZSTD_HEAPMODE) && (ZSTD_HEAPMODE==1)
ZSTD_Cctx* ctx; ZSTD_CCtx* ctx;
ctx = ZSTD_createCCtx(); ctx = ZSTD_createCCtx();
if (ctx==NULL) return ERROR(GENERIC); if (ctx==NULL) return ERROR(GENERIC);
# else # else
ZSTD_Cctx ctxBody; ZSTD_CCtx ctxBody;
ZSTD_Cctx* const ctx = &ctxBody; ZSTD_CCtx* const ctx = &ctxBody;
# endif # endif
r = ZSTD_compressCCtx(ctx, dst, maxDstSize, src, srcSize); r = ZSTD_compressCCtx(ctx, dst, maxDstSize, src, srcSize);
@@ -1012,7 +1018,7 @@ size_t ZSTD_compress(void* dst, size_t maxDstSize, const void* src, size_t srcSi
/* ************************************************************* /* *************************************************************
* Decompression section * Decompression section
***************************************************************/ ***************************************************************/
struct ZSTD_Dctx_s struct ZSTD_DCtx_s
{ {
U32 LLTable[FSE_DTABLE_SIZE_U32(LLFSELog)]; U32 LLTable[FSE_DTABLE_SIZE_U32(LLFSELog)];
U32 OffTable[FSE_DTABLE_SIZE_U32(OffFSELog)]; U32 OffTable[FSE_DTABLE_SIZE_U32(OffFSELog)];
@@ -1081,7 +1087,7 @@ static size_t ZSTD_decompressLiterals(void* dst, size_t* maxDstSizePtr,
size_t ZSTD_decodeLiteralsBlock(void* ctx, size_t ZSTD_decodeLiteralsBlock(void* ctx,
const void* src, size_t srcSize) const void* src, size_t srcSize)
{ {
ZSTD_Dctx* dctx = (ZSTD_Dctx*)ctx; ZSTD_DCtx* dctx = (ZSTD_DCtx*)ctx;
const BYTE* const istart = (const BYTE* const)src; const BYTE* const istart = (const BYTE* const)src;
/* any compressed block with literals segment must be at least this size */ /* any compressed block with literals segment must be at least this size */
@@ -1383,7 +1389,7 @@ static size_t ZSTD_decompressSequences(
void* dst, size_t maxDstSize, void* dst, size_t maxDstSize,
const void* seqStart, size_t seqSize) const void* seqStart, size_t seqSize)
{ {
ZSTD_Dctx* dctx = (ZSTD_Dctx*)ctx; ZSTD_DCtx* dctx = (ZSTD_DCtx*)ctx;
const BYTE* ip = (const BYTE*)seqStart; const BYTE* ip = (const BYTE*)seqStart;
const BYTE* const iend = ip + seqSize; const BYTE* const iend = ip + seqSize;
BYTE* const ostart = (BYTE* const)dst; BYTE* const ostart = (BYTE* const)dst;
@@ -1530,7 +1536,7 @@ static size_t ZSTD_decompressDCtx(void* ctx, void* dst, size_t maxDstSize, const
size_t ZSTD_decompress(void* dst, size_t maxDstSize, const void* src, size_t srcSize) size_t ZSTD_decompress(void* dst, size_t maxDstSize, const void* src, size_t srcSize)
{ {
ZSTD_Dctx ctx; ZSTD_DCtx ctx;
ctx.base = dst; ctx.base = dst;
return ZSTD_decompressDCtx(&ctx, dst, maxDstSize, src, srcSize); return ZSTD_decompressDCtx(&ctx, dst, maxDstSize, src, srcSize);
} }
@@ -1540,7 +1546,7 @@ size_t ZSTD_decompress(void* dst, size_t maxDstSize, const void* src, size_t src
* Streaming Decompression API * Streaming Decompression API
*******************************/ *******************************/
size_t ZSTD_resetDCtx(ZSTD_Dctx* dctx) size_t ZSTD_resetDCtx(ZSTD_DCtx* dctx)
{ {
dctx->expected = ZSTD_frameHeaderSize; dctx->expected = ZSTD_frameHeaderSize;
dctx->phase = 0; dctx->phase = 0;
@@ -1549,29 +1555,27 @@ size_t ZSTD_resetDCtx(ZSTD_Dctx* dctx)
return 0; return 0;
} }
ZSTD_Dctx* ZSTD_createDCtx(void) ZSTD_DCtx* ZSTD_createDCtx(void)
{ {
ZSTD_Dctx* dctx = (ZSTD_Dctx*)malloc(sizeof(ZSTD_Dctx)); ZSTD_DCtx* dctx = (ZSTD_DCtx*)malloc(sizeof(ZSTD_DCtx));
if (dctx==NULL) return NULL; if (dctx==NULL) return NULL;
ZSTD_resetDCtx(dctx); ZSTD_resetDCtx(dctx);
return dctx; return dctx;
} }
size_t ZSTD_freeDCtx(ZSTD_Dctx* dctx) size_t ZSTD_freeDCtx(ZSTD_DCtx* dctx)
{ {
free(dctx); free(dctx);
return 0; return 0;
} }
size_t ZSTD_nextSrcSizeToDecompress(ZSTD_Dctx* dctx) size_t ZSTD_nextSrcSizeToDecompress(ZSTD_DCtx* dctx)
{ {
return ((ZSTD_Dctx*)dctx)->expected; return dctx->expected;
} }
size_t ZSTD_decompressContinue(ZSTD_Dctx* dctx, void* dst, size_t maxDstSize, const void* src, size_t srcSize) size_t ZSTD_decompressContinue(ZSTD_DCtx* ctx, void* dst, size_t maxDstSize, const void* src, size_t srcSize)
{ {
ZSTD_Dctx* ctx = (ZSTD_Dctx*)dctx;
/* Sanity check */ /* Sanity check */
if (srcSize != ctx->expected) return ERROR(srcSize_wrong); if (srcSize != ctx->expected) return ERROR(srcSize_wrong);
if (dst != ctx->previousDstEnd) /* not contiguous */ if (dst != ctx->previousDstEnd) /* not contiguous */

View File

@@ -91,15 +91,15 @@ const char* ZSTD_getErrorName(size_t code); /** provides error code string */
/* ************************************* /* *************************************
* Advanced functions * Advanced functions
***************************************/ ***************************************/
typedef struct ZSTD_Cctx_s ZSTD_Cctx; /* incomplete type */ typedef struct ZSTD_CCtx_s ZSTD_CCtx; /* incomplete type */
ZSTD_Cctx* ZSTD_createCCtx(void); ZSTD_CCtx* ZSTD_createCCtx(void);
size_t ZSTD_freeCCtx(ZSTD_Cctx* cctx); size_t ZSTD_freeCCtx(ZSTD_CCtx* cctx);
/** /**
ZSTD_compressCCtx() : ZSTD_compressCCtx() :
Same as ZSTD_compress(), but requires a ZSTD_Cctx working space already allocated Same as ZSTD_compress(), but requires a ZSTD_CCtx working space already allocated
*/ */
size_t ZSTD_compressCCtx(ZSTD_Cctx* ctx, void* dst, size_t maxDstSize, const void* src, size_t srcSize); size_t ZSTD_compressCCtx(ZSTD_CCtx* ctx, void* dst, size_t maxDstSize, const void* src, size_t srcSize);
#if defined (__cplusplus) #if defined (__cplusplus)

View File

@@ -41,27 +41,27 @@
extern "C" { extern "C" {
#endif #endif
/************************************** /* *************************************
* Includes * Includes
**************************************/ ***************************************/
#include "zstd.h" #include "zstd.h"
/************************************** /* *************************************
* Streaming functions * Streaming functions
**************************************/ ***************************************/
size_t ZSTD_compressBegin(ZSTD_Cctx* cctx, void* dst, size_t maxDstSize); size_t ZSTD_compressBegin(ZSTD_CCtx* cctx, void* dst, size_t maxDstSize);
size_t ZSTD_compressContinue(ZSTD_Cctx* cctx, void* dst, size_t maxDstSize, const void* src, size_t srcSize); size_t ZSTD_compressContinue(ZSTD_CCtx* cctx, void* dst, size_t maxDstSize, const void* src, size_t srcSize);
size_t ZSTD_compressEnd(ZSTD_Cctx* cctx, void* dst, size_t maxDstSize); size_t ZSTD_compressEnd(ZSTD_CCtx* cctx, void* dst, size_t maxDstSize);
typedef struct ZSTD_Dctx_s ZSTD_Dctx; typedef struct ZSTD_DCtx_s ZSTD_DCtx;
ZSTD_Dctx* ZSTD_createDCtx(void); ZSTD_DCtx* ZSTD_createDCtx(void);
size_t ZSTD_resetDCtx(ZSTD_Dctx* dctx); size_t ZSTD_resetDCtx(ZSTD_DCtx* dctx);
size_t ZSTD_freeDCtx(ZSTD_Dctx* dctx); size_t ZSTD_freeDCtx(ZSTD_DCtx* dctx);
size_t ZSTD_nextSrcSizeToDecompress(ZSTD_Dctx* dctx); size_t ZSTD_nextSrcSizeToDecompress(ZSTD_DCtx* dctx);
size_t ZSTD_decompressContinue(ZSTD_Dctx* dctx, void* dst, size_t maxDstSize, const void* src, size_t srcSize); size_t ZSTD_decompressContinue(ZSTD_DCtx* dctx, void* dst, size_t maxDstSize, const void* src, size_t srcSize);
/* /*
Use above functions alternatively. Use above functions alternatively.
ZSTD_nextSrcSizeToDecompress() tells how much bytes to provide as 'srcSize' to ZSTD_decompressContinue(). ZSTD_nextSrcSizeToDecompress() tells how much bytes to provide as 'srcSize' to ZSTD_decompressContinue().
@@ -70,15 +70,15 @@ size_t ZSTD_decompressContinue(ZSTD_Dctx* dctx, void* dst, size_t maxDstSize, co
It can be zero, which is not an error; it just means ZSTD_decompressContinue() has decoded some header. It can be zero, which is not an error; it just means ZSTD_decompressContinue() has decoded some header.
*/ */
/************************************** /* *************************************
* Prefix - version detection * Prefix - version detection
**************************************/ ***************************************/
#define ZSTD_magicNumber 0xFD2FB522 /* v0.2 (current)*/ #define ZSTD_magicNumber 0xFD2FB522 /* v0.2 (current)*/
/************************************** /* *************************************
* Error management * Error management
**************************************/ ***************************************/
#include "error.h" #include "error.h"

View File

@@ -232,17 +232,16 @@ unsigned long long FIO_compressFilename(const char* output_filename, const char*
FILE* finput; FILE* finput;
FILE* foutput; FILE* foutput;
size_t sizeCheck, cSize; size_t sizeCheck, cSize;
ZSTD_Cctx* ctx; ZSTD_CCtx* ctx = ZSTD_createCCtx();
/* Init */ /* Init */
FIO_getFileHandles(&finput, &foutput, input_filename, output_filename); FIO_getFileHandles(&finput, &foutput, input_filename, output_filename);
ctx = ZSTD_createCCtx();
/* Allocate Memory */ /* Allocate Memory */
inBuff = (BYTE*)malloc(inBuffSize); inBuff = (BYTE*)malloc(inBuffSize);
outBuff = (BYTE*)malloc(outBuffSize); outBuff = (BYTE*)malloc(outBuffSize);
if (!inBuff || !outBuff) EXM_THROW(21, "Allocation error : not enough memory"); if (!inBuff || !outBuff || !ctx) EXM_THROW(21, "Allocation error : not enough memory");
inSlot = inBuff; inSlot = inBuff;
inEnd = inBuff + inBuffSize; inEnd = inBuff + inBuffSize;
@@ -371,7 +370,7 @@ unsigned long long FIOv01_decompressFrame(FILE* foutput, FILE* finput)
unsigned long long FIO_decompressFrame(FILE* foutput, FILE* finput, unsigned long long FIO_decompressFrame(FILE* foutput, FILE* finput,
BYTE* inBuff, size_t inBuffSize, BYTE* inBuff, size_t inBuffSize,
BYTE* outBuff, size_t outBuffSize, BYTE* outBuff, size_t outBuffSize,
ZSTD_Dctx* dctx) ZSTD_DCtx* dctx)
{ {
BYTE* op = outBuff; BYTE* op = outBuff;
BYTE* const oend = outBuff + outBuffSize; BYTE* const oend = outBuff + outBuffSize;
@@ -433,7 +432,7 @@ unsigned long long FIO_decompressFilename(const char* output_filename, const cha
/* Init */ /* Init */
ZSTD_Dctx* dctx = ZSTD_createDCtx(); ZSTD_DCtx* dctx = ZSTD_createDCtx();
FIO_getFileHandles(&finput, &foutput, input_filename, output_filename); FIO_getFileHandles(&finput, &foutput, input_filename, output_filename);
/* for each frame */ /* for each frame */

View File

@@ -49,25 +49,7 @@
#include "zstd_static.h" #include "zstd_static.h"
#include "datagen.h" /* RDG_genBuffer */ #include "datagen.h" /* RDG_genBuffer */
#include "xxhash.h" /* XXH64 */ #include "xxhash.h" /* XXH64 */
#include "mem.h"
/**************************************
* Basic Types
**************************************/
#if defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 */
# include <stdint.h>
typedef uint8_t BYTE;
typedef uint16_t U16;
typedef uint32_t U32;
typedef int32_t S32;
typedef uint64_t U64;
#else
typedef unsigned char BYTE;
typedef unsigned short U16;
typedef unsigned int U32;
typedef signed int S32;
typedef unsigned long long U64;
#endif
/************************************** /**************************************