zstd-ruby 1.5.7.0 → 1.5.7.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 50ffda13ae5c1470be924476eb600af7695a2e76f0764666f8f4a90b07b35428
4
- data.tar.gz: e28d50be732039fc58762c02870e3ecf227b5843d647fce6a5cebac91dbf8487
3
+ metadata.gz: 0a831f7214f9a1a344bdb30a7e969d4ed7ecbf90c3c909c463e600167168060c
4
+ data.tar.gz: 3979c655745321a2dc26bd54888e0cd5f072f666dc8b50b8fe97b7d18c2540f7
5
5
  SHA512:
6
- metadata.gz: 71433e488936220118f3b4611594f8eaac68c3544816e890c412fa76f531e450f44d62d4b03d900e95b47e25d37f35b73c41baeb8275917adc1013172763fc11
7
- data.tar.gz: 6e1f7a19a7fb75633b790d3d3a5c2c20bc520a6f2ed03f17941f186f7c9e5e2a00dfa7398fc428cfd665a935f5ed516115d81a826439bfa3d304119ae1f5cc79
6
+ metadata.gz: 9be787af166434f6d56a9bfcaad31e9832f134a0d08a08b657137b3c1983ebc1334c0bc5580e7480005bf4ae1fedd694fa1c36891fd73b39f1676f9e9226ff05
7
+ data.tar.gz: 70456cc157ce7c20a4320049281ff5e99601f5334211c5dac2e94fed162285c4392bf03bcc4dac79f995db792ee6370265de41ce2b4aee388cbcd329b48da785
@@ -4,6 +4,7 @@ struct streaming_compress_t {
4
4
  ZSTD_CCtx* ctx;
5
5
  VALUE buf;
6
6
  size_t buf_size;
7
+ VALUE pending; /* accumulate compressed bytes produced by write() */
7
8
  };
8
9
 
9
10
  static void
@@ -12,8 +13,10 @@ streaming_compress_mark(void *p)
12
13
  struct streaming_compress_t *sc = p;
13
14
  #ifdef HAVE_RB_GC_MARK_MOVABLE
14
15
  rb_gc_mark_movable(sc->buf);
16
+ rb_gc_mark_movable(sc->pending);
15
17
  #else
16
18
  rb_gc_mark(sc->buf);
19
+ rb_gc_mark(sc->pending);
17
20
  #endif
18
21
  }
19
22
 
@@ -40,6 +43,7 @@ streaming_compress_compact(void *p)
40
43
  {
41
44
  struct streaming_compress_t *sc = p;
42
45
  sc->buf = rb_gc_location(sc->buf);
46
+ sc->pending = rb_gc_location(sc->pending);
43
47
  }
44
48
  #endif
45
49
 
@@ -64,6 +68,7 @@ rb_streaming_compress_allocate(VALUE klass)
64
68
  sc->ctx = NULL;
65
69
  sc->buf = Qnil;
66
70
  sc->buf_size = 0;
71
+ sc->pending = Qnil;
67
72
  return obj;
68
73
  }
69
74
 
@@ -87,6 +92,7 @@ rb_streaming_compress_initialize(int argc, VALUE *argv, VALUE obj)
87
92
  sc->ctx = ctx;
88
93
  sc->buf = rb_str_new(NULL, buffOutSize);
89
94
  sc->buf_size = buffOutSize;
95
+ sc->pending = rb_str_new(0, 0);
90
96
 
91
97
  return obj;
92
98
  }
@@ -143,7 +149,6 @@ static VALUE
143
149
  rb_streaming_compress_write(int argc, VALUE *argv, VALUE obj)
144
150
  {
145
151
  size_t total = 0;
146
- VALUE result = rb_str_new(0, 0);
147
152
  struct streaming_compress_t* sc;
148
153
  TypedData_Get_Struct(obj, struct streaming_compress_t, &streaming_compress_type, sc);
149
154
  const char* output_data = RSTRING_PTR(sc->buf);
@@ -161,6 +166,10 @@ rb_streaming_compress_write(int argc, VALUE *argv, VALUE obj)
161
166
  if (ZSTD_isError(ret)) {
162
167
  rb_raise(rb_eRuntimeError, "compress error error code: %s", ZSTD_getErrorName(ret));
163
168
  }
169
+ /* collect produced bytes */
170
+ if (output.pos > 0) {
171
+ rb_str_cat(sc->pending, output.dst, output.pos);
172
+ }
164
173
  total += RSTRING_LEN(str);
165
174
  }
166
175
  }
@@ -193,8 +202,11 @@ rb_streaming_compress_flush(VALUE obj)
193
202
  {
194
203
  struct streaming_compress_t* sc;
195
204
  TypedData_Get_Struct(obj, struct streaming_compress_t, &streaming_compress_type, sc);
196
- VALUE result = no_compress(sc, ZSTD_e_flush);
197
- return result;
205
+ VALUE drained = no_compress(sc, ZSTD_e_flush);
206
+ rb_str_cat(sc->pending, RSTRING_PTR(drained), RSTRING_LEN(drained));
207
+ VALUE out = sc->pending;
208
+ sc->pending = rb_str_new(0, 0);
209
+ return out;
198
210
  }
199
211
 
200
212
  static VALUE
@@ -202,8 +214,11 @@ rb_streaming_compress_finish(VALUE obj)
202
214
  {
203
215
  struct streaming_compress_t* sc;
204
216
  TypedData_Get_Struct(obj, struct streaming_compress_t, &streaming_compress_type, sc);
205
- VALUE result = no_compress(sc, ZSTD_e_end);
206
- return result;
217
+ VALUE drained = no_compress(sc, ZSTD_e_end);
218
+ rb_str_cat(sc->pending, RSTRING_PTR(drained), RSTRING_LEN(drained));
219
+ VALUE out = sc->pending;
220
+ sc->pending = rb_str_new(0, 0);
221
+ return out;
207
222
  }
208
223
 
209
224
  extern VALUE rb_mZstd, cStreamingCompress;
@@ -1,3 +1,3 @@
1
1
  module Zstd
2
- VERSION = "1.5.7.0"
2
+ VERSION = "1.5.7.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zstd-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.7.0
4
+ version: 1.5.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - SpringMT
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2025-07-06 00:00:00.000000000 Z
10
+ date: 2025-09-26 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: bundler
@@ -187,7 +186,6 @@ homepage: https://github.com/SpringMT/zstd-ruby
187
186
  licenses:
188
187
  - MIT
189
188
  metadata: {}
190
- post_install_message:
191
189
  rdoc_options: []
192
190
  require_paths:
193
191
  - lib
@@ -202,8 +200,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
202
200
  - !ruby/object:Gem::Version
203
201
  version: '0'
204
202
  requirements: []
205
- rubygems_version: 3.4.19
206
- signing_key:
203
+ rubygems_version: 3.6.2
207
204
  specification_version: 4
208
205
  summary: Ruby binding for zstd(Zstandard - Fast real-time compression algorithm)
209
206
  test_files: []