zstd-ruby 1.5.6.3 → 1.5.6.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ext/zstdruby/common.h +6 -6
- data/ext/zstdruby/streaming_compress.c +3 -3
- data/ext/zstdruby/zstdruby.c +10 -13
- 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: fe4c394ffc4bcfd9e48c1baaa1dd91f8bf19f9bd65397218017c39145db14106
|
4
|
+
data.tar.gz: 5b87fa1c74eff20d0abe4b90260ac6fdb0db8fc65afd4a571bf0f7b10aa419b2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ea1413beb577cc5c735f2a6514e99071bba67e40de2216d84b11afa77b653d36b026db573f06002797e4f258142b441331eaa4f9fb71e5426d1408ad4123bfeb
|
7
|
+
data.tar.gz: 58476bc0ce00c3d612e1aa460728a2255fbb9e289b132dc76106f539b535323d71ce5c0cda3adcded4cd8407066b332f79efff8fe41085e64e8bdee6ac14f563
|
data/ext/zstdruby/common.h
CHANGED
@@ -44,7 +44,7 @@ static void set_compress_params(ZSTD_CCtx* const ctx, VALUE level_from_args, VAL
|
|
44
44
|
}
|
45
45
|
}
|
46
46
|
|
47
|
-
struct
|
47
|
+
struct stream_compress_params {
|
48
48
|
ZSTD_CCtx* ctx;
|
49
49
|
ZSTD_outBuffer* output;
|
50
50
|
ZSTD_inBuffer* input;
|
@@ -52,21 +52,21 @@ struct compress_params {
|
|
52
52
|
size_t ret;
|
53
53
|
};
|
54
54
|
|
55
|
-
static void*
|
55
|
+
static void* stream_compress_wrapper(void* args)
|
56
56
|
{
|
57
|
-
struct
|
57
|
+
struct stream_compress_params* params = args;
|
58
58
|
params->ret = ZSTD_compressStream2(params->ctx, params->output, params->input, params->endOp);
|
59
59
|
return NULL;
|
60
60
|
}
|
61
61
|
|
62
|
-
static size_t
|
62
|
+
static size_t zstd_stream_compress(ZSTD_CCtx* const ctx, ZSTD_outBuffer* output, ZSTD_inBuffer* input, ZSTD_EndDirective endOp, bool gvl)
|
63
63
|
{
|
64
64
|
#ifdef HAVE_RUBY_THREAD_H
|
65
65
|
if (gvl) {
|
66
66
|
return ZSTD_compressStream2(ctx, output, input, endOp);
|
67
67
|
} else {
|
68
|
-
struct
|
69
|
-
rb_thread_call_without_gvl(
|
68
|
+
struct stream_compress_params params = { ctx, output, input, endOp };
|
69
|
+
rb_thread_call_without_gvl(stream_compress_wrapper, ¶ms, NULL, NULL);
|
70
70
|
return params.ret;
|
71
71
|
}
|
72
72
|
#else
|
@@ -106,7 +106,7 @@ no_compress(struct streaming_compress_t* sc, ZSTD_EndDirective endOp)
|
|
106
106
|
do {
|
107
107
|
ZSTD_outBuffer output = { (void*)output_data, sc->buf_size, 0 };
|
108
108
|
|
109
|
-
size_t const ret =
|
109
|
+
size_t const ret = zstd_stream_compress(sc->ctx, &output, &input, endOp, false);
|
110
110
|
if (ZSTD_isError(ret)) {
|
111
111
|
rb_raise(rb_eRuntimeError, "flush error error code: %s", ZSTD_getErrorName(ret));
|
112
112
|
}
|
@@ -130,7 +130,7 @@ rb_streaming_compress_compress(VALUE obj, VALUE src)
|
|
130
130
|
VALUE result = rb_str_new(0, 0);
|
131
131
|
while (input.pos < input.size) {
|
132
132
|
ZSTD_outBuffer output = { (void*)output_data, sc->buf_size, 0 };
|
133
|
-
size_t const ret =
|
133
|
+
size_t const ret = zstd_stream_compress(sc->ctx, &output, &input, ZSTD_e_continue, false);
|
134
134
|
if (ZSTD_isError(ret)) {
|
135
135
|
rb_raise(rb_eRuntimeError, "compress error error code: %s", ZSTD_getErrorName(ret));
|
136
136
|
}
|
@@ -157,7 +157,7 @@ rb_streaming_compress_write(int argc, VALUE *argv, VALUE obj)
|
|
157
157
|
|
158
158
|
while (input.pos < input.size) {
|
159
159
|
ZSTD_outBuffer output = { (void*)output_data, sc->buf_size, 0 };
|
160
|
-
size_t const ret =
|
160
|
+
size_t const ret = zstd_stream_compress(sc->ctx, &output, &input, ZSTD_e_continue, false);
|
161
161
|
if (ZSTD_isError(ret)) {
|
162
162
|
rb_raise(rb_eRuntimeError, "compress error error code: %s", ZSTD_getErrorName(ret));
|
163
163
|
}
|
data/ext/zstdruby/zstdruby.c
CHANGED
@@ -25,22 +25,19 @@ static VALUE rb_compress(int argc, VALUE *argv, VALUE self)
|
|
25
25
|
StringValue(input_value);
|
26
26
|
char* input_data = RSTRING_PTR(input_value);
|
27
27
|
size_t input_size = RSTRING_LEN(input_value);
|
28
|
-
ZSTD_inBuffer input = { input_data, input_size, 0 };
|
29
|
-
// ZSTD_compressBound causes SEGV under multi-thread
|
30
|
-
size_t max_compressed_size = ZSTD_compressBound(input_size);
|
31
|
-
VALUE buf = rb_str_new(NULL, max_compressed_size);
|
32
|
-
char* output_data = RSTRING_PTR(buf);
|
33
|
-
ZSTD_outBuffer output = { (void*)output_data, max_compressed_size, 0 };
|
34
28
|
|
35
|
-
size_t const
|
29
|
+
size_t const max_compressed_size = ZSTD_compressBound(input_size);
|
30
|
+
VALUE output = rb_str_new(NULL, max_compressed_size);
|
31
|
+
const char* output_data = RSTRING_PTR(output);
|
32
|
+
|
33
|
+
size_t const ret = ZSTD_compress2(ctx,(void*)output_data, max_compressed_size, (void*)input_data, input_size);
|
36
34
|
if (ZSTD_isError(ret)) {
|
37
|
-
|
38
|
-
rb_raise(rb_eRuntimeError, "%s: %s", "compress failed", ZSTD_getErrorName(ret));
|
35
|
+
rb_raise(rb_eRuntimeError, "compress error error code: %s", ZSTD_getErrorName(ret));
|
39
36
|
}
|
40
|
-
|
41
|
-
|
37
|
+
rb_str_resize(output, ret);
|
38
|
+
|
42
39
|
ZSTD_freeCCtx(ctx);
|
43
|
-
return
|
40
|
+
return output;
|
44
41
|
}
|
45
42
|
|
46
43
|
static VALUE rb_compress_using_dict(int argc, VALUE *argv, VALUE self)
|
@@ -141,7 +138,7 @@ static VALUE rb_decompress(int argc, VALUE *argv, VALUE self)
|
|
141
138
|
if (ZSTD_isError(decompress_size)) {
|
142
139
|
rb_raise(rb_eRuntimeError, "%s: %s", "decompress error", ZSTD_getErrorName(decompress_size));
|
143
140
|
}
|
144
|
-
|
141
|
+
ZSTD_freeDCtx(dctx);
|
145
142
|
return output;
|
146
143
|
}
|
147
144
|
|
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: 1.5.6.
|
4
|
+
version: 1.5.6.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- SpringMT
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-04-
|
11
|
+
date: 2024-04-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|