From c4807f4d2f26471063ae630ba921b81b753eeb8f Mon Sep 17 00:00:00 2001 From: inikep Date: Thu, 2 Jun 2016 15:11:39 +0200 Subject: [PATCH] default custom allocation functions moved to zstd_internal.h --- lib/common/zstd_common.c | 2 +- lib/common/zstd_internal.h | 5 +++++ lib/common/zstd_static.h | 4 ---- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/common/zstd_common.c b/lib/common/zstd_common.c index c4ec46fb..262eeb23 100644 --- a/lib/common/zstd_common.c +++ b/lib/common/zstd_common.c @@ -76,8 +76,8 @@ const char* ZBUFF_getErrorName(size_t errorCode) { return ERR_getErrorName(error void* ZSTD_defaultAllocFunction(void* opaque, size_t size) { - (void)opaque; void* address = malloc(size); + (void)opaque; /* DISPLAYLEVEL(4, "alloc %p, %d opaque=%d \n", address, (int)size, (int)opaque); */ return address; } diff --git a/lib/common/zstd_internal.h b/lib/common/zstd_internal.h index 63e56aaf..8c647b51 100644 --- a/lib/common/zstd_internal.h +++ b/lib/common/zstd_internal.h @@ -255,4 +255,9 @@ const seqStore_t* ZSTD_getSeqStore(const ZSTD_CCtx* ctx); void ZSTD_seqToCodes(const seqStore_t* seqStorePtr, size_t const nbSeq); int ZSTD_isSkipFrame(ZSTD_DCtx* dctx); +/* custom memory allocation functions */ +void* ZSTD_defaultAllocFunction(void* opaque, size_t size); +void ZSTD_defaultFreeFunction(void* opaque, void* address); +MEM_STATIC ZSTD_customMem const defaultCustomMem = { ZSTD_defaultAllocFunction, ZSTD_defaultFreeFunction, NULL }; + #endif /* ZSTD_CCOMMON_H_MODULE */ diff --git a/lib/common/zstd_static.h b/lib/common/zstd_static.h index b36e92c8..f452e696 100644 --- a/lib/common/zstd_static.h +++ b/lib/common/zstd_static.h @@ -102,10 +102,6 @@ typedef void* (*ZSTD_allocFunction) (void* opaque, size_t size); typedef void (*ZSTD_freeFunction) (void* opaque, void* address); typedef struct { ZSTD_allocFunction customAlloc; ZSTD_freeFunction customFree; void* opaque; } ZSTD_customMem; -void* ZSTD_defaultAllocFunction(void* opaque, size_t size); -void ZSTD_defaultFreeFunction(void* opaque, void* address); -static ZSTD_customMem const defaultCustomMem = { ZSTD_defaultAllocFunction, ZSTD_defaultFreeFunction, NULL }; - /*-************************************* * Advanced functions