Cleanup from Move
This commit is contained in:
parent
b511a84adc
commit
881bcd80ca
@ -10,6 +10,10 @@
|
|||||||
|
|
||||||
#include "zstd_cwksp.h"
|
#include "zstd_cwksp.h"
|
||||||
|
|
||||||
|
#if defined (__cplusplus)
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Align must be a power of 2.
|
* 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.
|
* 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 */
|
/* TODO(felixh): alignment */
|
||||||
void* alloc = (BYTE *)ws->allocStart - bytes;
|
void* alloc = (BYTE *)ws->allocStart - bytes;
|
||||||
void* bottom = ws->tableEnd;
|
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) {
|
int ZSTD_cwksp_reserve_failed(const ZSTD_cwksp* ws) {
|
||||||
return ws->allocFailed;
|
return ws->allocFailed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined (__cplusplus)
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
@ -11,14 +11,32 @@
|
|||||||
#ifndef ZSTD_CWKSP_H
|
#ifndef ZSTD_CWKSP_H
|
||||||
#define ZSTD_CWKSP_H
|
#define ZSTD_CWKSP_H
|
||||||
|
|
||||||
|
/*-*************************************
|
||||||
|
* Dependencies
|
||||||
|
***************************************/
|
||||||
#include "zstd_internal.h"
|
#include "zstd_internal.h"
|
||||||
|
|
||||||
#define ZSTD_WORKSPACETOOLARGE_FACTOR 3 /* define "workspace is too large" as this number of times larger than needed */
|
#if defined (__cplusplus)
|
||||||
#define ZSTD_WORKSPACETOOLARGE_MAXDURATION 128 /* when workspace is continuously too large
|
extern "C" {
|
||||||
* during at least this number of times,
|
#endif
|
||||||
* 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 */
|
* 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 {
|
typedef enum {
|
||||||
ZSTD_cwksp_alloc_objects,
|
ZSTD_cwksp_alloc_objects,
|
||||||
ZSTD_cwksp_alloc_buffers,
|
ZSTD_cwksp_alloc_buffers,
|
||||||
@ -110,16 +128,15 @@ typedef struct {
|
|||||||
ZSTD_cwksp_alloc_phase_e phase;
|
ZSTD_cwksp_alloc_phase_e phase;
|
||||||
} ZSTD_cwksp;
|
} ZSTD_cwksp;
|
||||||
|
|
||||||
|
/*-*************************************
|
||||||
|
* Functions
|
||||||
|
***************************************/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Align must be a power of 2.
|
* Align must be a power of 2.
|
||||||
*/
|
*/
|
||||||
size_t ZSTD_cwksp_align(size_t size, size_t const align);
|
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.
|
* Unaligned.
|
||||||
*/
|
*/
|
||||||
@ -172,4 +189,8 @@ size_t ZSTD_cwksp_sizeof(const ZSTD_cwksp* ws);
|
|||||||
|
|
||||||
int ZSTD_cwksp_reserve_failed(const ZSTD_cwksp* ws);
|
int ZSTD_cwksp_reserve_failed(const ZSTD_cwksp* ws);
|
||||||
|
|
||||||
|
#if defined (__cplusplus)
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* ZSTD_CWKSP_H */
|
#endif /* ZSTD_CWKSP_H */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user