#include "zstd_cwksp.h"
+#if defined (__cplusplus)
+extern "C" {
+#endif
+
/**
* Align must be a power of 2.
*/
/**
* 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;
int ZSTD_cwksp_reserve_failed(const ZSTD_cwksp* ws) {
return ws->allocFailed;
-}
\ No newline at end of file
+}
+
+#if defined (__cplusplus)
+}
+#endif
#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,
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.
*/
int ZSTD_cwksp_reserve_failed(const ZSTD_cwksp* ws);
+#if defined (__cplusplus)
+}
+#endif
+
#endif /* ZSTD_CWKSP_H */