1
0
mirror of https://github.com/facebook/zstd.git synced 2025-03-06 16:56:49 +02:00

Fixed a few visual analyzer warnings

This commit is contained in:
Yann Collet 2015-07-04 23:10:40 -08:00
parent 7393c5a51d
commit 94f998b1fc
3 changed files with 17 additions and 10 deletions

View File

@ -326,26 +326,25 @@ typedef struct ZSTD_Cctx_s
ZSTD_Cctx* ZSTD_createCCtx(void)
{
cctxi_t* ctx = (cctxi_t*) malloc( sizeof(cctxi_t) );
ZSTD_Cctx* ctx = (ZSTD_Cctx*) malloc( sizeof(ZSTD_Cctx) );
if (ctx==NULL) return NULL;
ctx->seqStore.buffer = malloc(WORKPLACESIZE);
ctx->seqStore.offsetStart = (U32*) (ctx->seqStore.buffer);
ctx->seqStore.litStart = (BYTE*) (ctx->seqStore.offsetStart + (BLOCKSIZE>>2));
ctx->seqStore.litLengthStart = ctx->seqStore.litStart + BLOCKSIZE;
ctx->seqStore.matchLengthStart = ctx->seqStore.litLengthStart + (BLOCKSIZE>>2);
ctx->seqStore.dumpsStart = ctx->seqStore.matchLengthStart + (BLOCKSIZE>>2);
return (ZSTD_Cctx* )ctx;
return ctx;
}
void ZSTD_resetCCtx(ZSTD_Cctx* cctx)
void ZSTD_resetCCtx(ZSTD_Cctx* ctx)
{
cctxi_t* ctx = (cctxi_t*)cctx;
ctx->base = NULL;
memset(ctx->hashTable, 0, HASH_TABLESIZE*4);
}
size_t ZSTD_freeCCtx(ZSTD_Cctx* cctx)
size_t ZSTD_freeCCtx(ZSTD_Cctx* ctx)
{
cctxi_t* ctx = (cctxi_t*) (cctx);
free(ctx->seqStore.buffer);
free(ctx);
return 0;
@ -687,7 +686,6 @@ static size_t ZSTD_compressSequences(BYTE* dst, size_t maxDstSize,
const size_t maxLSize = maxCSize > minSeqSize ? maxCSize - minSeqSize : 0;
BYTE* seqHead;
/* init */
op = dst;
@ -1711,7 +1709,7 @@ size_t ZSTD_decompress(void* dst, size_t maxDstSize, const void* src, size_t src
* Streaming Decompression API
*******************************/
typedef struct ZTSD_Dctx_s
typedef struct ZSTD_Dctx_s
{
U32 ctx[FSE_DTABLE_SIZE_U32(LLFSELog) + FSE_DTABLE_SIZE_U32(OffFSELog) + FSE_DTABLE_SIZE_U32(MLFSELog)];
size_t expected;
@ -1722,10 +1720,11 @@ typedef struct ZTSD_Dctx_s
ZSTD_Dctx* ZSTD_createDCtx(void)
{
dctx_t* dctx = (dctx_t*)malloc(sizeof(dctx_t));
ZSTD_Dctx* dctx = (ZSTD_Dctx*)malloc(sizeof(ZSTD_Dctx));
if (dctx==NULL) return NULL;
dctx->expected = ZSTD_frameHeaderSize;
dctx->phase = 0;
return (ZSTD_Dctx*)dctx;
return dctx;
}
size_t ZSTD_freeDCtx(ZSTD_Dctx* dctx)

View File

@ -206,6 +206,12 @@ static int basicUnitTests(U32 seed, double compressibility)
CNBuffer = malloc(COMPRESSIBLE_NOISE_LENGTH);
compressedBuffer = malloc(ZSTD_compressBound(COMPRESSIBLE_NOISE_LENGTH));
decodedBuffer = malloc(COMPRESSIBLE_NOISE_LENGTH);
if (!CNBuffer || !compressedBuffer || !decodedBuffer)
{
DISPLAY("Not enough memory, aborting\n");
testResult = 1;
goto _end;
}
FUZ_generateSynthetic(CNBuffer, COMPRESSIBLE_NOISE_LENGTH, compressibility, &randState);
// Basic tests

View File

@ -281,6 +281,7 @@ int main(int argc, char** argv)
{
size_t l = strlen(inFileName);
dynNameSpace = (char*)calloc(1,l+5);
if (dynNameSpace==NULL) { DISPLAY("not enough memory\n"); exit(1); }
strcpy(dynNameSpace, inFileName);
strcpy(dynNameSpace+l, ZSTD_EXTENSION);
outFileName = dynNameSpace;
@ -292,6 +293,7 @@ int main(int argc, char** argv)
size_t outl;
size_t inl = strlen(inFileName);
dynNameSpace = (char*)calloc(1,inl+1);
if (dynNameSpace==NULL) { DISPLAY("not enough memory\n"); exit(1); }
outFileName = dynNameSpace;
strcpy(dynNameSpace, inFileName);
outl = inl;