zstd-ruby 2.0.3 → 2.0.4
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/README.md +0 -2
- data/ext/zstdruby/common.h +8 -2
- data/ext/zstdruby/zstdruby.c +4 -3
- 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: f9a23c701181eccbc41191787fd658f9bc2d78a449468caff3b106b2bf64173e
|
|
4
|
+
data.tar.gz: addcdf88b39e425cf4090c9b461f33058c62c8ccd77404e70dd6674403c84db9
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2c340e8a040207bd0551a634bfe899f904276bb4ddc9e20b5148e888a978b5a4d9d88fcac92914d7fb31acf4e4ffd8345d60871709540d76f0bad9a06b27a2ea
|
|
7
|
+
data.tar.gz: e240f5870f6cd187012d52c181cbe8fdfd0b2a351b896c0d25832153b708e0b241c577153bf789cdf6b6beaafce66fa0d1901e6714b37c54573dcfce67842175
|
data/README.md
CHANGED
data/ext/zstdruby/common.h
CHANGED
|
@@ -10,11 +10,17 @@
|
|
|
10
10
|
|
|
11
11
|
extern VALUE rb_cCDict, rb_cDDict;
|
|
12
12
|
|
|
13
|
-
static int convert_compression_level(VALUE compression_level_value)
|
|
13
|
+
static int convert_compression_level(ZSTD_CCtx* ctx, VALUE compression_level_value)
|
|
14
14
|
{
|
|
15
15
|
if (NIL_P(compression_level_value)) {
|
|
16
16
|
return ZSTD_CLEVEL_DEFAULT;
|
|
17
17
|
}
|
|
18
|
+
if (!RB_INTEGER_TYPE_P(compression_level_value)) {
|
|
19
|
+
if (ctx) {
|
|
20
|
+
ZSTD_freeCCtx(ctx);
|
|
21
|
+
}
|
|
22
|
+
rb_raise(rb_eTypeError, "compression level must be an Integer");
|
|
23
|
+
}
|
|
18
24
|
return NUM2INT(compression_level_value);
|
|
19
25
|
}
|
|
20
26
|
|
|
@@ -28,7 +34,7 @@ static void set_compress_params(ZSTD_CCtx* const ctx, VALUE kwargs)
|
|
|
28
34
|
|
|
29
35
|
int compression_level = ZSTD_CLEVEL_DEFAULT;
|
|
30
36
|
if (kwargs_values[0] != Qundef && kwargs_values[0] != Qnil) {
|
|
31
|
-
compression_level = convert_compression_level(kwargs_values[0]);
|
|
37
|
+
compression_level = convert_compression_level(ctx, kwargs_values[0]);
|
|
32
38
|
}
|
|
33
39
|
ZSTD_CCtx_setParameter(ctx, ZSTD_c_compressionLevel, compression_level);
|
|
34
40
|
|
data/ext/zstdruby/zstdruby.c
CHANGED
|
@@ -14,6 +14,8 @@ static VALUE rb_compress(int argc, VALUE *argv, VALUE self)
|
|
|
14
14
|
VALUE kwargs;
|
|
15
15
|
rb_scan_args(argc, argv, "10:", &input_value, &kwargs);
|
|
16
16
|
|
|
17
|
+
StringValue(input_value);
|
|
18
|
+
|
|
17
19
|
ZSTD_CCtx* const ctx = ZSTD_createCCtx();
|
|
18
20
|
if (ctx == NULL) {
|
|
19
21
|
rb_raise(rb_eRuntimeError, "%s", "ZSTD_createCCtx error");
|
|
@@ -21,7 +23,6 @@ static VALUE rb_compress(int argc, VALUE *argv, VALUE self)
|
|
|
21
23
|
|
|
22
24
|
set_compress_params(ctx, kwargs);
|
|
23
25
|
|
|
24
|
-
StringValue(input_value);
|
|
25
26
|
char* input_data = RSTRING_PTR(input_value);
|
|
26
27
|
size_t input_size = RSTRING_LEN(input_value);
|
|
27
28
|
|
|
@@ -30,12 +31,12 @@ static VALUE rb_compress(int argc, VALUE *argv, VALUE self)
|
|
|
30
31
|
char* output_data = RSTRING_PTR(output);
|
|
31
32
|
|
|
32
33
|
size_t const ret = zstd_compress(ctx, output_data, max_compressed_size, input_data, input_size, false);
|
|
34
|
+
ZSTD_freeCCtx(ctx);
|
|
33
35
|
if (ZSTD_isError(ret)) {
|
|
34
36
|
rb_raise(rb_eRuntimeError, "compress error error code: %s", ZSTD_getErrorName(ret));
|
|
35
37
|
}
|
|
36
38
|
rb_str_resize(output, ret);
|
|
37
39
|
|
|
38
|
-
ZSTD_freeCCtx(ctx);
|
|
39
40
|
return output;
|
|
40
41
|
}
|
|
41
42
|
|
|
@@ -169,7 +170,7 @@ static VALUE rb_cdict_initialize(int argc, VALUE *argv, VALUE self)
|
|
|
169
170
|
VALUE dict;
|
|
170
171
|
VALUE compression_level_value;
|
|
171
172
|
rb_scan_args(argc, argv, "11", &dict, &compression_level_value);
|
|
172
|
-
int compression_level = convert_compression_level(compression_level_value);
|
|
173
|
+
int compression_level = convert_compression_level(NULL, compression_level_value);
|
|
173
174
|
|
|
174
175
|
StringValue(dict);
|
|
175
176
|
char* dict_buffer = RSTRING_PTR(dict);
|
data/lib/zstd-ruby/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
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.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- SpringMT
|
|
8
8
|
bindir: exe
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date: 2025-
|
|
10
|
+
date: 2025-12-24 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
12
|
- !ruby/object:Gem::Dependency
|
|
13
13
|
name: bundler
|