Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 1 addition & 32 deletions ext/zstdruby/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ static VALUE set_decompress_params(ZSTD_DCtx* const dctx, VALUE kwargs)
size_t load_dict_ret = ZSTD_DCtx_loadDictionary(dctx, dict_buffer, dict_size);
if (ZSTD_isError(load_dict_ret)) {
ZSTD_freeDCtx(dctx);
rb_raise(rb_eRuntimeError, "%s", "ZSTD_CCtx_loadDictionary failed");
rb_raise(rb_eRuntimeError, "%s", "ZSTD_DCtx_loadDictionary failed");
}
} else {
ZSTD_freeDCtx(dctx);
Expand Down Expand Up @@ -191,35 +191,4 @@ static size_t zstd_stream_decompress(ZSTD_DCtx* const dctx, ZSTD_outBuffer* outp
#endif
}

struct decompress_params {
ZSTD_DCtx* dctx;
char* output_data;
size_t output_size;
char* input_data;
size_t input_size;
size_t ret;
};

static void* decompress_wrapper(void* args)
{
struct decompress_params* params = args;
params->ret = ZSTD_decompressDCtx(params->dctx, params->output_data, params->output_size, params->input_data, params->input_size);
return NULL;
}

static size_t zstd_decompress(ZSTD_DCtx* const dctx, char* output_data, size_t output_size, char* input_data, size_t input_size, bool gvl)
{
#ifdef HAVE_RUBY_THREAD_H
if (gvl) {
return ZSTD_decompressDCtx(dctx, output_data, output_size, input_data, input_size);
} else {
struct decompress_params params = { dctx, output_data, output_size, input_data, input_size };
rb_thread_call_without_gvl(decompress_wrapper, &params, NULL, NULL);
return params.ret;
}
#else
return ZSTD_decompressDCtx(dctx, output_data, output_size, input_data, input_size);
#endif
}

#endif /* ZSTD_RUBY_H */
6 changes: 1 addition & 5 deletions ext/zstdruby/zstdruby.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,6 @@ static VALUE decode_one_frame(ZSTD_DCtx* dctx, const unsigned char* src, size_t
return out;
}

static VALUE decompress_buffered(ZSTD_DCtx* dctx, const char* data, size_t len) {
return decode_one_frame(dctx, (const unsigned char*)data, len, Qnil, NULL);
}

static VALUE rb_decompress(int argc, VALUE *argv, VALUE self)
{
VALUE input_value, kwargs;
Expand Down Expand Up @@ -216,7 +212,7 @@ static VALUE rb_cdict_initialize(int argc, VALUE *argv, VALUE self)

static VALUE rb_ddict_alloc(VALUE self)
{
ZSTD_CDict* ddict = NULL;
ZSTD_DDict* ddict = NULL;
return TypedData_Wrap_Struct(self, &ddict_type, ddict);
}

Expand Down