Cleanup from Move
This commit is contained in:
parent
b511a84adc
commit
881bcd80ca
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
@ -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 */
|
||||
|
Loading…
Reference in New Issue
Block a user