compress: move compression mode enum to function.h
This commit is contained in:
@@ -12,14 +12,14 @@ struct zstd_ctx {
|
||||
};
|
||||
|
||||
static enum b_status buffer_size(
|
||||
enum b_compressor_mode mode, size_t *inbuf_size, size_t *outbuf_size)
|
||||
enum b_compression_mode mode, size_t *inbuf_size, size_t *outbuf_size)
|
||||
{
|
||||
switch (mode) {
|
||||
case B_COMPRESSOR_MODE_COMPRESS:
|
||||
case B_COMPRESSION_MODE_COMPRESS:
|
||||
*inbuf_size = ZSTD_CStreamInSize();
|
||||
*outbuf_size = ZSTD_CStreamOutSize();
|
||||
break;
|
||||
case B_COMPRESSOR_MODE_DECOMPRESS:
|
||||
case B_COMPRESSION_MODE_DECOMPRESS:
|
||||
*inbuf_size = ZSTD_DStreamInSize();
|
||||
*outbuf_size = ZSTD_DStreamOutSize();
|
||||
break;
|
||||
@@ -34,13 +34,13 @@ static enum b_status init(struct b_compressor *compressor)
|
||||
{
|
||||
struct zstd_ctx *ctx = b_compressor_get_function_ctx(compressor);
|
||||
switch (compressor->c_mode) {
|
||||
case B_COMPRESSOR_MODE_COMPRESS:
|
||||
case B_COMPRESSION_MODE_COMPRESS:
|
||||
ctx->zstd_c = ZSTD_createCCtx();
|
||||
if (!ctx->zstd_c) {
|
||||
return B_ERR_NO_MEMORY;
|
||||
}
|
||||
break;
|
||||
case B_COMPRESSOR_MODE_DECOMPRESS:
|
||||
case B_COMPRESSION_MODE_DECOMPRESS:
|
||||
ctx->zstd_d = ZSTD_createDCtx();
|
||||
if (!ctx->zstd_d) {
|
||||
return B_ERR_NO_MEMORY;
|
||||
@@ -57,10 +57,10 @@ static enum b_status fini(struct b_compressor *compressor)
|
||||
{
|
||||
struct zstd_ctx *ctx = b_compressor_get_function_ctx(compressor);
|
||||
switch (compressor->c_mode) {
|
||||
case B_COMPRESSOR_MODE_COMPRESS:
|
||||
case B_COMPRESSION_MODE_COMPRESS:
|
||||
ZSTD_freeCCtx(ctx->zstd_c);
|
||||
break;
|
||||
case B_COMPRESSOR_MODE_DECOMPRESS:
|
||||
case B_COMPRESSION_MODE_DECOMPRESS:
|
||||
ZSTD_freeDCtx(ctx->zstd_d);
|
||||
break;
|
||||
default:
|
||||
@@ -74,10 +74,10 @@ static enum b_status reset(struct b_compressor *compressor)
|
||||
{
|
||||
struct zstd_ctx *ctx = b_compressor_get_function_ctx(compressor);
|
||||
switch (compressor->c_mode) {
|
||||
case B_COMPRESSOR_MODE_COMPRESS:
|
||||
case B_COMPRESSION_MODE_COMPRESS:
|
||||
ZSTD_CCtx_reset(ctx->zstd_c, ZSTD_reset_session_only);
|
||||
break;
|
||||
case B_COMPRESSOR_MODE_DECOMPRESS:
|
||||
case B_COMPRESSION_MODE_DECOMPRESS:
|
||||
ZSTD_DCtx_reset(ctx->zstd_d, ZSTD_reset_session_only);
|
||||
break;
|
||||
default:
|
||||
|
||||
Reference in New Issue
Block a user