zstd-ruby 2.0.4 → 2.0.6

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: f9a23c701181eccbc41191787fd658f9bc2d78a449468caff3b106b2bf64173e
4
- data.tar.gz: addcdf88b39e425cf4090c9b461f33058c62c8ccd77404e70dd6674403c84db9
3
+ metadata.gz: ac26f68ad0afda2642c8dd10a92f79b5c45434a0fe978f4528f542ce276502f0
4
+ data.tar.gz: cd514652d23230593b6ec9971f5286875847da819ba31747136c2e94040d8b2f
5
5
  SHA512:
6
- metadata.gz: 2c340e8a040207bd0551a634bfe899f904276bb4ddc9e20b5148e888a978b5a4d9d88fcac92914d7fb31acf4e4ffd8345d60871709540d76f0bad9a06b27a2ea
7
- data.tar.gz: e240f5870f6cd187012d52c181cbe8fdfd0b2a351b896c0d25832153b708e0b241c577153bf789cdf6b6beaafce66fa0d1901e6714b37c54573dcfce67842175
6
+ metadata.gz: 3def0b1dabc9b717f8ff22f6f5754a219c33e3b5850fb2bf26d59b9eea819b4787f80d78819eb9166151af5ee3bb186a8ea81a707336ee5f4a83313188e5c6bc
7
+ data.tar.gz: 95c48e8b498db92b302f612295f1b47953b2f23708dcadbadf534b3710720ca21969913c675c095270839d4163fa978b8d8c0c33eb926153b18b6c90d22c04c5
@@ -57,7 +57,7 @@ static const rb_data_type_t streaming_compress_type = {
57
57
  streaming_compress_compact,
58
58
  #endif
59
59
  },
60
- 0, 0, RUBY_TYPED_FREE_IMMEDIATELY
60
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED
61
61
  };
62
62
 
63
63
  static VALUE
@@ -66,9 +66,9 @@ rb_streaming_compress_allocate(VALUE klass)
66
66
  struct streaming_compress_t* sc;
67
67
  VALUE obj = TypedData_Make_Struct(klass, struct streaming_compress_t, &streaming_compress_type, sc);
68
68
  sc->ctx = NULL;
69
- sc->buf = Qnil;
69
+ RB_OBJ_WRITE(obj, &sc->buf, Qnil);
70
70
  sc->buf_size = 0;
71
- sc->pending = Qnil;
71
+ RB_OBJ_WRITE(obj, &sc->pending, Qnil);
72
72
  return obj;
73
73
  }
74
74
 
@@ -89,9 +89,9 @@ rb_streaming_compress_initialize(int argc, VALUE *argv, VALUE obj)
89
89
  set_compress_params(ctx, kwargs);
90
90
 
91
91
  sc->ctx = ctx;
92
- sc->buf = rb_str_new(NULL, buffOutSize);
92
+ RB_OBJ_WRITE(obj, &sc->buf, rb_str_new(NULL, buffOutSize));
93
93
  sc->buf_size = buffOutSize;
94
- sc->pending = rb_str_new(0, 0);
94
+ RB_OBJ_WRITE(obj, &sc->pending, rb_str_new(0, 0));
95
95
 
96
96
  return obj;
97
97
  }
@@ -53,7 +53,7 @@ static const rb_data_type_t streaming_decompress_type = {
53
53
  streaming_decompress_compact,
54
54
  #endif
55
55
  },
56
- 0, 0, RUBY_TYPED_FREE_IMMEDIATELY
56
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED
57
57
  };
58
58
 
59
59
  static VALUE
@@ -62,7 +62,7 @@ rb_streaming_decompress_allocate(VALUE klass)
62
62
  struct streaming_decompress_t* sd;
63
63
  VALUE obj = TypedData_Make_Struct(klass, struct streaming_decompress_t, &streaming_decompress_type, sd);
64
64
  sd->dctx = NULL;
65
- sd->buf = Qnil;
65
+ RB_OBJ_WRITE(obj, &sd->buf, Qnil);
66
66
  sd->buf_size = 0;
67
67
  return obj;
68
68
  }
@@ -84,7 +84,7 @@ rb_streaming_decompress_initialize(int argc, VALUE *argv, VALUE obj)
84
84
  set_decompress_params(dctx, kwargs);
85
85
 
86
86
  sd->dctx = dctx;
87
- sd->buf = rb_str_new(NULL, buffOutSize);
87
+ RB_OBJ_WRITE(obj, &sd->buf, rb_str_new(NULL, buffOutSize));
88
88
  sd->buf_size = buffOutSize;
89
89
 
90
90
  return obj;
@@ -78,9 +78,7 @@ static VALUE rb_decompress(int argc, VALUE *argv, VALUE self)
78
78
  StringValue(input_value);
79
79
 
80
80
  size_t in_size = RSTRING_LEN(input_value);
81
- const unsigned char *in_r = (const unsigned char *)RSTRING_PTR(input_value);
82
- unsigned char *in = ALLOC_N(unsigned char, in_size);
83
- memcpy(in, in_r, in_size);
81
+ const unsigned char *in = (const unsigned char *)RSTRING_PTR(input_value);
84
82
 
85
83
  size_t off = 0;
86
84
  const uint32_t ZSTD_MAGIC = 0xFD2FB528U;
@@ -107,14 +105,12 @@ static VALUE rb_decompress(int argc, VALUE *argv, VALUE self)
107
105
  if (magic == ZSTD_MAGIC) {
108
106
  ZSTD_DCtx *dctx = ZSTD_createDCtx();
109
107
  if (!dctx) {
110
- xfree(in);
111
108
  rb_raise(rb_eRuntimeError, "ZSTD_createDCtx failed");
112
109
  }
113
110
 
114
111
  VALUE out = decode_one_frame(dctx, in + off, in_size - off, kwargs);
115
112
 
116
113
  ZSTD_freeDCtx(dctx);
117
- xfree(in);
118
114
  RB_GC_GUARD(input_value);
119
115
  return out;
120
116
  }
@@ -122,7 +118,6 @@ static VALUE rb_decompress(int argc, VALUE *argv, VALUE self)
122
118
  off += 1;
123
119
  }
124
120
 
125
- xfree(in);
126
121
  RB_GC_GUARD(input_value);
127
122
  rb_raise(rb_eRuntimeError, "not a zstd frame (magic not found)");
128
123
  }
@@ -150,13 +145,13 @@ static size_t sizeof_ddict(const void *dict)
150
145
  static const rb_data_type_t cdict_type = {
151
146
  "Zstd::CDict",
152
147
  {0, free_cdict, sizeof_cdict,},
153
- 0, 0, RUBY_TYPED_FREE_IMMEDIATELY
148
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED
154
149
  };
155
150
 
156
151
  static const rb_data_type_t ddict_type = {
157
152
  "Zstd::DDict",
158
153
  {0, free_ddict, sizeof_ddict,},
159
- 0, 0, RUBY_TYPED_FREE_IMMEDIATELY
154
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED
160
155
  };
161
156
 
162
157
  static VALUE rb_cdict_alloc(VALUE self)
@@ -1,3 +1,3 @@
1
1
  module Zstd
2
- VERSION = "2.0.4"
2
+ VERSION = "2.0.6"
3
3
  end
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
4
+ version: 2.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - SpringMT
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 2025-12-24 00:00:00.000000000 Z
10
+ date: 2026-03-01 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: bundler