Skip to content

Commit 7bccb90

Browse files
authored
Merge pull request #132 from byroot/write-barrier
Implement Write Barriers
2 parents 24bd92d + 24809ad commit 7bccb90

3 files changed

Lines changed: 10 additions & 10 deletions

File tree

ext/zstdruby/streaming_compress.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ static const rb_data_type_t streaming_compress_type = {
5757
streaming_compress_compact,
5858
#endif
5959
},
60-
0, 0, RUBY_TYPED_FREE_IMMEDIATELY
60+
0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED
6161
};
6262

6363
static VALUE
@@ -66,9 +66,9 @@ rb_streaming_compress_allocate(VALUE klass)
6666
struct streaming_compress_t* sc;
6767
VALUE obj = TypedData_Make_Struct(klass, struct streaming_compress_t, &streaming_compress_type, sc);
6868
sc->ctx = NULL;
69-
sc->buf = Qnil;
69+
RB_OBJ_WRITE(obj, &sc->buf, Qnil);
7070
sc->buf_size = 0;
71-
sc->pending = Qnil;
71+
RB_OBJ_WRITE(obj, &sc->pending, Qnil);
7272
return obj;
7373
}
7474

@@ -89,9 +89,9 @@ rb_streaming_compress_initialize(int argc, VALUE *argv, VALUE obj)
8989
set_compress_params(ctx, kwargs);
9090

9191
sc->ctx = ctx;
92-
sc->buf = rb_str_new(NULL, buffOutSize);
92+
RB_OBJ_WRITE(obj, &sc->buf, rb_str_new(NULL, buffOutSize));
9393
sc->buf_size = buffOutSize;
94-
sc->pending = rb_str_new(0, 0);
94+
RB_OBJ_WRITE(obj, &sc->pending, rb_str_new(0, 0));
9595

9696
return obj;
9797
}

ext/zstdruby/streaming_decompress.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ static const rb_data_type_t streaming_decompress_type = {
5353
streaming_decompress_compact,
5454
#endif
5555
},
56-
0, 0, RUBY_TYPED_FREE_IMMEDIATELY
56+
0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED
5757
};
5858

5959
static VALUE
@@ -62,7 +62,7 @@ rb_streaming_decompress_allocate(VALUE klass)
6262
struct streaming_decompress_t* sd;
6363
VALUE obj = TypedData_Make_Struct(klass, struct streaming_decompress_t, &streaming_decompress_type, sd);
6464
sd->dctx = NULL;
65-
sd->buf = Qnil;
65+
RB_OBJ_WRITE(obj, &sd->buf, Qnil);
6666
sd->buf_size = 0;
6767
return obj;
6868
}
@@ -84,7 +84,7 @@ rb_streaming_decompress_initialize(int argc, VALUE *argv, VALUE obj)
8484
set_decompress_params(dctx, kwargs);
8585

8686
sd->dctx = dctx;
87-
sd->buf = rb_str_new(NULL, buffOutSize);
87+
RB_OBJ_WRITE(obj, &sd->buf, rb_str_new(NULL, buffOutSize));
8888
sd->buf_size = buffOutSize;
8989

9090
return obj;

ext/zstdruby/zstdruby.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,13 +145,13 @@ static size_t sizeof_ddict(const void *dict)
145145
static const rb_data_type_t cdict_type = {
146146
"Zstd::CDict",
147147
{0, free_cdict, sizeof_cdict,},
148-
0, 0, RUBY_TYPED_FREE_IMMEDIATELY
148+
0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED
149149
};
150150

151151
static const rb_data_type_t ddict_type = {
152152
"Zstd::DDict",
153153
{0, free_ddict, sizeof_ddict,},
154-
0, 0, RUBY_TYPED_FREE_IMMEDIATELY
154+
0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED
155155
};
156156

157157
static VALUE rb_cdict_alloc(VALUE self)

0 commit comments

Comments
 (0)