/* **************************************************************
* Includes
****************************************************************/
-#include <stdlib.h> /* malloc, free, qsort */
#include <string.h> /* memcpy, memset */
#include <stdio.h> /* printf (debug) */
#include "huf_static.h"
ZBUFF_CCtx* zbc;
if (!customMem.customAlloc && !customMem.customFree)
- {
- 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;
- }
+ customMem = defaultCustomMem;
if (!customMem.customAlloc || !customMem.customFree)
return NULL;
/*-*************************************
* Dependencies
***************************************/
-#include <stdlib.h> /* malloc */
#include <string.h> /* memset */
#include "mem.h"
#define XXH_STATIC_LINKING_ONLY /* XXH64_state_t */
ZSTD_CCtx* ctx;
if (!customMem.customAlloc && !customMem.customFree)
- {
- ctx = (ZSTD_CCtx*) calloc(1, sizeof(ZSTD_CCtx));
- if (!ctx) return NULL;
- memcpy(&ctx->customMem, &defaultCustomMem, sizeof(ZSTD_customMem));
- return ctx;
- }
+ customMem = defaultCustomMem;
if (!customMem.customAlloc || !customMem.customFree)
return NULL;
/* **************************************************************
* Includes
****************************************************************/
-#include <stdlib.h> /* malloc, free, qsort */
#include <string.h> /* memcpy, memset */
#include <stdio.h> /* printf (debug) */
#include "huf_static.h"
ZBUFF_DCtx* zbd;
if (!customMem.customAlloc && !customMem.customFree)
- {
- 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;
- }
+ customMem = defaultCustomMem;
if (!customMem.customAlloc || !customMem.customFree)
return NULL;
/*-*******************************************************
* Dependencies
*********************************************************/
-#include <stdlib.h> /* calloc */
#include <string.h> /* memcpy, memmove */
#include <stdio.h> /* debug only : printf */
#include "mem.h" /* low level memory routines */
{
ZSTD_DCtx* dctx;
- if (!customMem.customAlloc && !customMem.customFree) {
- dctx = (ZSTD_DCtx*) malloc(sizeof(ZSTD_DCtx));
- if (!dctx) return NULL;
- memcpy(&dctx->customMem, &defaultCustomMem, sizeof(ZSTD_customMem));
- ZSTD_decompressBegin(dctx);
- return dctx;
- }
+ if (!customMem.customAlloc && !customMem.customFree)
+ customMem = defaultCustomMem;
if (!customMem.customAlloc || !customMem.customFree)
return NULL;
U32 mainPause = 0;
const char* programName = argv[0];
ZSTD_customMem customMem = { ZBUFF_allocFunction, ZBUFF_freeFunction, NULL };
+ ZSTD_customMem customNULL = { NULL, NULL, NULL };
/* Check command line */
for(argNb=1; argNb<argc; argNb++) {
if (nbTests<=0) nbTests=1;
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) {
DISPLAYLEVEL(4, "Unit tests using customMem :\n")
result = basicUnitTests(0, ((double)proba) / 100, customMem); /* use custom memory allocation functions */