removed calloc calls from lib/
This commit is contained in:
parent
db2f540414
commit
36fac00149
@ -59,7 +59,6 @@
|
|||||||
/* **************************************************************
|
/* **************************************************************
|
||||||
* Includes
|
* Includes
|
||||||
****************************************************************/
|
****************************************************************/
|
||||||
#include <stdlib.h> /* malloc, free, qsort */
|
|
||||||
#include <string.h> /* memcpy, memset */
|
#include <string.h> /* memcpy, memset */
|
||||||
#include <stdio.h> /* printf (debug) */
|
#include <stdio.h> /* printf (debug) */
|
||||||
#include "huf_static.h"
|
#include "huf_static.h"
|
||||||
|
@ -108,13 +108,7 @@ ZBUFF_CCtx* ZBUFF_createCCtx_advanced(ZSTD_customMem customMem)
|
|||||||
ZBUFF_CCtx* zbc;
|
ZBUFF_CCtx* zbc;
|
||||||
|
|
||||||
if (!customMem.customAlloc && !customMem.customFree)
|
if (!customMem.customAlloc && !customMem.customFree)
|
||||||
{
|
customMem = defaultCustomMem;
|
||||||
zbc = (ZBUFF_CCtx*)calloc(1, sizeof(ZBUFF_CCtx));
|
|
||||||
if (zbc==NULL) return NULL;
|
|
||||||
memcpy(&zbc->customMem, &defaultCustomMem, sizeof(ZSTD_customMem));
|
|
||||||
zbc->zc = ZSTD_createCCtx();
|
|
||||||
return zbc;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!customMem.customAlloc || !customMem.customFree)
|
if (!customMem.customAlloc || !customMem.customFree)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -51,7 +51,6 @@
|
|||||||
/*-*************************************
|
/*-*************************************
|
||||||
* Dependencies
|
* Dependencies
|
||||||
***************************************/
|
***************************************/
|
||||||
#include <stdlib.h> /* malloc */
|
|
||||||
#include <string.h> /* memset */
|
#include <string.h> /* memset */
|
||||||
#include "mem.h"
|
#include "mem.h"
|
||||||
#define XXH_STATIC_LINKING_ONLY /* XXH64_state_t */
|
#define XXH_STATIC_LINKING_ONLY /* XXH64_state_t */
|
||||||
@ -130,12 +129,7 @@ ZSTD_CCtx* ZSTD_createCCtx_advanced(ZSTD_customMem customMem)
|
|||||||
ZSTD_CCtx* ctx;
|
ZSTD_CCtx* ctx;
|
||||||
|
|
||||||
if (!customMem.customAlloc && !customMem.customFree)
|
if (!customMem.customAlloc && !customMem.customFree)
|
||||||
{
|
customMem = defaultCustomMem;
|
||||||
ctx = (ZSTD_CCtx*) calloc(1, sizeof(ZSTD_CCtx));
|
|
||||||
if (!ctx) return NULL;
|
|
||||||
memcpy(&ctx->customMem, &defaultCustomMem, sizeof(ZSTD_customMem));
|
|
||||||
return ctx;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!customMem.customAlloc || !customMem.customFree)
|
if (!customMem.customAlloc || !customMem.customFree)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -59,7 +59,6 @@
|
|||||||
/* **************************************************************
|
/* **************************************************************
|
||||||
* Includes
|
* Includes
|
||||||
****************************************************************/
|
****************************************************************/
|
||||||
#include <stdlib.h> /* malloc, free, qsort */
|
|
||||||
#include <string.h> /* memcpy, memset */
|
#include <string.h> /* memcpy, memset */
|
||||||
#include <stdio.h> /* printf (debug) */
|
#include <stdio.h> /* printf (debug) */
|
||||||
#include "huf_static.h"
|
#include "huf_static.h"
|
||||||
|
@ -96,14 +96,7 @@ ZBUFF_DCtx* ZBUFF_createDCtx_advanced(ZSTD_customMem customMem)
|
|||||||
ZBUFF_DCtx* zbd;
|
ZBUFF_DCtx* zbd;
|
||||||
|
|
||||||
if (!customMem.customAlloc && !customMem.customFree)
|
if (!customMem.customAlloc && !customMem.customFree)
|
||||||
{
|
customMem = defaultCustomMem;
|
||||||
zbd = (ZBUFF_DCtx*)calloc(1, sizeof(ZBUFF_DCtx));
|
|
||||||
if (zbd==NULL) return NULL;
|
|
||||||
memcpy(&zbd->customMem, &defaultCustomMem, sizeof(ZSTD_customMem));
|
|
||||||
zbd->zd = ZSTD_createDCtx();
|
|
||||||
zbd->stage = ZBUFFds_init;
|
|
||||||
return zbd;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!customMem.customAlloc || !customMem.customFree)
|
if (!customMem.customAlloc || !customMem.customFree)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -53,7 +53,6 @@
|
|||||||
/*-*******************************************************
|
/*-*******************************************************
|
||||||
* Dependencies
|
* Dependencies
|
||||||
*********************************************************/
|
*********************************************************/
|
||||||
#include <stdlib.h> /* calloc */
|
|
||||||
#include <string.h> /* memcpy, memmove */
|
#include <string.h> /* memcpy, memmove */
|
||||||
#include <stdio.h> /* debug only : printf */
|
#include <stdio.h> /* debug only : printf */
|
||||||
#include "mem.h" /* low level memory routines */
|
#include "mem.h" /* low level memory routines */
|
||||||
@ -152,13 +151,8 @@ ZSTD_DCtx* ZSTD_createDCtx_advanced(ZSTD_customMem customMem)
|
|||||||
{
|
{
|
||||||
ZSTD_DCtx* dctx;
|
ZSTD_DCtx* dctx;
|
||||||
|
|
||||||
if (!customMem.customAlloc && !customMem.customFree) {
|
if (!customMem.customAlloc && !customMem.customFree)
|
||||||
dctx = (ZSTD_DCtx*) malloc(sizeof(ZSTD_DCtx));
|
customMem = defaultCustomMem;
|
||||||
if (!dctx) return NULL;
|
|
||||||
memcpy(&dctx->customMem, &defaultCustomMem, sizeof(ZSTD_customMem));
|
|
||||||
ZSTD_decompressBegin(dctx);
|
|
||||||
return dctx;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!customMem.customAlloc || !customMem.customFree)
|
if (!customMem.customAlloc || !customMem.customFree)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -521,6 +521,7 @@ int main(int argc, const char** argv)
|
|||||||
U32 mainPause = 0;
|
U32 mainPause = 0;
|
||||||
const char* programName = argv[0];
|
const char* programName = argv[0];
|
||||||
ZSTD_customMem customMem = { ZBUFF_allocFunction, ZBUFF_freeFunction, NULL };
|
ZSTD_customMem customMem = { ZBUFF_allocFunction, ZBUFF_freeFunction, NULL };
|
||||||
|
ZSTD_customMem customNULL = { NULL, NULL, NULL };
|
||||||
|
|
||||||
/* Check command line */
|
/* Check command line */
|
||||||
for(argNb=1; argNb<argc; argNb++) {
|
for(argNb=1; argNb<argc; argNb++) {
|
||||||
@ -620,7 +621,7 @@ int main(int argc, const char** argv)
|
|||||||
if (nbTests<=0) nbTests=1;
|
if (nbTests<=0) nbTests=1;
|
||||||
|
|
||||||
if (testNb==0) {
|
if (testNb==0) {
|
||||||
result = basicUnitTests(0, ((double)proba) / 100, defaultCustomNULL); /* constant seed for predictability */
|
result = basicUnitTests(0, ((double)proba) / 100, customNULL); /* constant seed for predictability */
|
||||||
if (!result) {
|
if (!result) {
|
||||||
DISPLAYLEVEL(4, "Unit tests using customMem :\n")
|
DISPLAYLEVEL(4, "Unit tests using customMem :\n")
|
||||||
result = basicUnitTests(0, ((double)proba) / 100, customMem); /* use custom memory allocation functions */
|
result = basicUnitTests(0, ((double)proba) / 100, customMem); /* use custom memory allocation functions */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user