From 881bcd80cacaecdc457654ba47ff13f8b27752fe Mon Sep 17 00:00:00 2001 From: "W. Felix Handte" Date: Tue, 20 Aug 2019 14:15:06 -0400 Subject: [PATCH] Cleanup from Move --- lib/compress/zstd_cwksp.c | 12 +++++++++-- lib/compress/zstd_cwksp.h | 43 +++++++++++++++++++++++++++++---------- 2 files changed, 42 insertions(+), 13 deletions(-) diff --git a/lib/compress/zstd_cwksp.c b/lib/compress/zstd_cwksp.c index 3b7341eb..a117ad09 100644 --- a/lib/compress/zstd_cwksp.c +++ b/lib/compress/zstd_cwksp.c @@ -10,6 +10,10 @@ #include "zstd_cwksp.h" +#if defined (__cplusplus) +extern "C" { +#endif + /** * Align must be a power of 2. */ @@ -22,7 +26,7 @@ size_t ZSTD_cwksp_align(size_t size, size_t const align) { /** * Internal function, use wrappers instead. */ -void* ZSTD_cwksp_reserve_internal(ZSTD_cwksp* ws, size_t bytes, ZSTD_cwksp_alloc_phase_e phase) { +static void* ZSTD_cwksp_reserve_internal(ZSTD_cwksp* ws, size_t bytes, ZSTD_cwksp_alloc_phase_e phase) { /* TODO(felixh): alignment */ void* alloc = (BYTE *)ws->allocStart - bytes; void* bottom = ws->tableEnd; @@ -200,4 +204,8 @@ size_t ZSTD_cwksp_sizeof(const ZSTD_cwksp* ws) { int ZSTD_cwksp_reserve_failed(const ZSTD_cwksp* ws) { return ws->allocFailed; -} \ No newline at end of file +} + +#if defined (__cplusplus) +} +#endif diff --git a/lib/compress/zstd_cwksp.h b/lib/compress/zstd_cwksp.h index b5b35849..965ca6b0 100644 --- a/lib/compress/zstd_cwksp.h +++ b/lib/compress/zstd_cwksp.h @@ -11,14 +11,32 @@ #ifndef ZSTD_CWKSP_H #define ZSTD_CWKSP_H +/*-************************************* +* Dependencies +***************************************/ #include "zstd_internal.h" -#define ZSTD_WORKSPACETOOLARGE_FACTOR 3 /* define "workspace is too large" as this number of times larger than needed */ -#define ZSTD_WORKSPACETOOLARGE_MAXDURATION 128 /* when workspace is continuously too large - * during at least this number of times, - * context's memory usage is considered wasteful, - * because it's sized to handle a worst case scenario which rarely happens. - * In which case, resize it down to free some memory */ +#if defined (__cplusplus) +extern "C" { +#endif + +/*-************************************* +* Constants +***************************************/ + +/* define "workspace is too large" as this number of times larger than needed */ +#define ZSTD_WORKSPACETOOLARGE_FACTOR 3 + +/* when workspace is continuously too large + * during at least this number of times, + * context's memory usage is considered wasteful, + * because it's sized to handle a worst case scenario which rarely happens. + * In which case, resize it down to free some memory */ +#define ZSTD_WORKSPACETOOLARGE_MAXDURATION 128 + +/*-************************************* +* Structures +***************************************/ typedef enum { ZSTD_cwksp_alloc_objects, ZSTD_cwksp_alloc_buffers, @@ -110,16 +128,15 @@ typedef struct { ZSTD_cwksp_alloc_phase_e phase; } ZSTD_cwksp; +/*-************************************* +* Functions +***************************************/ + /** * Align must be a power of 2. */ size_t ZSTD_cwksp_align(size_t size, size_t const align); -/** - * Internal function, use wrappers instead. - */ -void* ZSTD_cwksp_reserve_internal(ZSTD_cwksp* ws, size_t bytes, ZSTD_cwksp_alloc_phase_e phase); - /** * Unaligned. */ @@ -172,4 +189,8 @@ size_t ZSTD_cwksp_sizeof(const ZSTD_cwksp* ws); int ZSTD_cwksp_reserve_failed(const ZSTD_cwksp* ws); +#if defined (__cplusplus) +} +#endif + #endif /* ZSTD_CWKSP_H */