zstd-ruby 2.0.9 → 2.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +4 -0
- data/Rakefile +26 -0
- data/ext/zstdruby/common.h +1 -32
- data/ext/zstdruby/streaming_compress.c +4 -0
- data/ext/zstdruby/zstdruby.c +3 -6
- data/lib/zstd-ruby/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 02555a47928cf342248cbe5335c2a6b4aad14e3c7f9d78bbb65bf83fa3791c16
|
|
4
|
+
data.tar.gz: b58b8db365ce2490998468d785f77b5500023d9f4840aa49ade89413308c9672
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c2a700c515e5073d5a20b7383a8c890007aa2792db0fc27e5187bbfd2a3ff806929349d988e8809a29ac0d6616a12f3fab41583c8ab10afe4fd220a35da35e8b
|
|
7
|
+
data.tar.gz: e560ce637e53be29601f6cb610461a8c137808019902c1c2e461390400845a021e22a5749020ec3e6f842a94d02ecfae9fe155ef39485db6dcc7503b23d53967
|
data/Gemfile
CHANGED
data/Rakefile
CHANGED
|
@@ -15,6 +15,32 @@ end
|
|
|
15
15
|
|
|
16
16
|
task :default => [:clobber, :compile, :spec]
|
|
17
17
|
|
|
18
|
+
begin
|
|
19
|
+
require 'ruby_memcheck'
|
|
20
|
+
require 'ruby_memcheck/rspec/rake_task'
|
|
21
|
+
|
|
22
|
+
RubyMemcheck.config(
|
|
23
|
+
binary_name: 'zstdruby',
|
|
24
|
+
# Valgrind and YJIT interfere with each other, adding noise and slowdown,
|
|
25
|
+
# so keep YJIT disabled while running under Valgrind.
|
|
26
|
+
ruby: "#{FileUtils::RUBY} --disable-yjit"
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
namespace :spec do
|
|
30
|
+
task :check_valgrind do
|
|
31
|
+
unless system('command -v valgrind > /dev/null 2>&1')
|
|
32
|
+
abort("\nValgrind is required for `rake spec:valgrind` but was not found.\n" \
|
|
33
|
+
"Install it first (Linux only), e.g. `sudo apt-get install valgrind`.\n")
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
RubyMemcheck::RSpec::RakeTask.new(valgrind: [:check_valgrind, :compile])
|
|
38
|
+
end
|
|
39
|
+
rescue LoadError
|
|
40
|
+
# ruby_memcheck is an optional development dependency, absent on the platforms
|
|
41
|
+
# and Ruby versions the Gemfile excludes. Skip the task instead of breaking.
|
|
42
|
+
end
|
|
43
|
+
|
|
18
44
|
desc 'Sync zstd libs dirs to ext/zstdruby/libzstd'
|
|
19
45
|
task :zstd_update do
|
|
20
46
|
FileUtils.rm_r("ext/zstdruby/libzstd")
|
data/ext/zstdruby/common.h
CHANGED
|
@@ -152,7 +152,7 @@ static VALUE set_decompress_params(ZSTD_DCtx* const dctx, VALUE kwargs)
|
|
|
152
152
|
size_t load_dict_ret = ZSTD_DCtx_loadDictionary(dctx, dict_buffer, dict_size);
|
|
153
153
|
if (ZSTD_isError(load_dict_ret)) {
|
|
154
154
|
ZSTD_freeDCtx(dctx);
|
|
155
|
-
rb_raise(rb_eRuntimeError, "%s", "
|
|
155
|
+
rb_raise(rb_eRuntimeError, "%s", "ZSTD_DCtx_loadDictionary failed");
|
|
156
156
|
}
|
|
157
157
|
} else {
|
|
158
158
|
ZSTD_freeDCtx(dctx);
|
|
@@ -191,35 +191,4 @@ static size_t zstd_stream_decompress(ZSTD_DCtx* const dctx, ZSTD_outBuffer* outp
|
|
|
191
191
|
#endif
|
|
192
192
|
}
|
|
193
193
|
|
|
194
|
-
struct decompress_params {
|
|
195
|
-
ZSTD_DCtx* dctx;
|
|
196
|
-
char* output_data;
|
|
197
|
-
size_t output_size;
|
|
198
|
-
char* input_data;
|
|
199
|
-
size_t input_size;
|
|
200
|
-
size_t ret;
|
|
201
|
-
};
|
|
202
|
-
|
|
203
|
-
static void* decompress_wrapper(void* args)
|
|
204
|
-
{
|
|
205
|
-
struct decompress_params* params = args;
|
|
206
|
-
params->ret = ZSTD_decompressDCtx(params->dctx, params->output_data, params->output_size, params->input_data, params->input_size);
|
|
207
|
-
return NULL;
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
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)
|
|
211
|
-
{
|
|
212
|
-
#ifdef HAVE_RUBY_THREAD_H
|
|
213
|
-
if (gvl) {
|
|
214
|
-
return ZSTD_decompressDCtx(dctx, output_data, output_size, input_data, input_size);
|
|
215
|
-
} else {
|
|
216
|
-
struct decompress_params params = { dctx, output_data, output_size, input_data, input_size };
|
|
217
|
-
rb_thread_call_without_gvl(decompress_wrapper, ¶ms, NULL, NULL);
|
|
218
|
-
return params.ret;
|
|
219
|
-
}
|
|
220
|
-
#else
|
|
221
|
-
return ZSTD_decompressDCtx(dctx, output_data, output_size, input_data, input_size);
|
|
222
|
-
#endif
|
|
223
|
-
}
|
|
224
|
-
|
|
225
194
|
#endif /* ZSTD_RUBY_H */
|
|
@@ -211,6 +211,8 @@ rb_streaming_compress_flush(VALUE obj)
|
|
|
211
211
|
VALUE drained = no_compress(sc, ZSTD_e_flush);
|
|
212
212
|
VALUE out = rb_str_dup(sc->pending);
|
|
213
213
|
rb_str_cat(out, RSTRING_PTR(drained), RSTRING_LEN(drained));
|
|
214
|
+
/* prevent `drained` from being freed by GC inside rb_str_cat */
|
|
215
|
+
RB_GC_GUARD(drained);
|
|
214
216
|
rb_str_resize(sc->pending, 0);
|
|
215
217
|
return out;
|
|
216
218
|
}
|
|
@@ -223,6 +225,8 @@ rb_streaming_compress_finish(VALUE obj)
|
|
|
223
225
|
VALUE drained = no_compress(sc, ZSTD_e_end);
|
|
224
226
|
VALUE out = rb_str_dup(sc->pending);
|
|
225
227
|
rb_str_cat(out, RSTRING_PTR(drained), RSTRING_LEN(drained));
|
|
228
|
+
/* prevent `drained` from being freed by GC inside rb_str_cat */
|
|
229
|
+
RB_GC_GUARD(drained);
|
|
226
230
|
rb_str_resize(sc->pending, 0);
|
|
227
231
|
return out;
|
|
228
232
|
}
|
data/ext/zstdruby/zstdruby.c
CHANGED
|
@@ -52,7 +52,7 @@ static VALUE decode_one_frame(ZSTD_DCtx* dctx, const unsigned char* src, size_t
|
|
|
52
52
|
for (;;) {
|
|
53
53
|
ZSTD_outBuffer o = (ZSTD_outBuffer){ buf, cap, 0 };
|
|
54
54
|
size_t const in_pos_before = in.pos;
|
|
55
|
-
size_t ret =
|
|
55
|
+
size_t ret = zstd_stream_decompress(dctx, &o, &in, false);
|
|
56
56
|
if (ZSTD_isError(ret)) {
|
|
57
57
|
xfree(buf);
|
|
58
58
|
rb_raise(rb_eRuntimeError, "ZSTD_decompressStream failed: %s", ZSTD_getErrorName(ret));
|
|
@@ -78,10 +78,6 @@ static VALUE decode_one_frame(ZSTD_DCtx* dctx, const unsigned char* src, size_t
|
|
|
78
78
|
return out;
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
-
static VALUE decompress_buffered(ZSTD_DCtx* dctx, const char* data, size_t len) {
|
|
82
|
-
return decode_one_frame(dctx, (const unsigned char*)data, len, Qnil, NULL);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
81
|
static VALUE rb_decompress(int argc, VALUE *argv, VALUE self)
|
|
86
82
|
{
|
|
87
83
|
VALUE input_value, kwargs;
|
|
@@ -132,6 +128,7 @@ static VALUE rb_decompress(int argc, VALUE *argv, VALUE self)
|
|
|
132
128
|
result = out;
|
|
133
129
|
} else {
|
|
134
130
|
rb_str_cat(result, RSTRING_PTR(out), RSTRING_LEN(out));
|
|
131
|
+
RB_GC_GUARD(out);
|
|
135
132
|
}
|
|
136
133
|
|
|
137
134
|
if (consumed == 0) {
|
|
@@ -216,7 +213,7 @@ static VALUE rb_cdict_initialize(int argc, VALUE *argv, VALUE self)
|
|
|
216
213
|
|
|
217
214
|
static VALUE rb_ddict_alloc(VALUE self)
|
|
218
215
|
{
|
|
219
|
-
|
|
216
|
+
ZSTD_DDict* ddict = NULL;
|
|
220
217
|
return TypedData_Wrap_Struct(self, &ddict_type, ddict);
|
|
221
218
|
}
|
|
222
219
|
|
data/lib/zstd-ruby/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: zstd-ruby
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.0.
|
|
4
|
+
version: 2.0.10
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- SpringMT
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-09-
|
|
11
|
+
date: 2026-09-23 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|