diff options
author | Matt Valentine-House <[email protected]> | 2025-03-31 11:38:16 +0100 |
---|---|---|
committer | Matt Valentine-House <[email protected]> | 2025-03-31 17:10:37 +0100 |
commit | 6012145299cfa4ab561360c78710c7f2941a7e9d (patch) | |
tree | 237a6f990e4db1dbfe5ad060ff3d0c858ad50521 /io_buffer.c | |
parent | 8a475d15d6aec3618d075b66541b4bae663beac9 (diff) |
Mark rb_io_buffer_type references declaratively
allowing them to support compaction and be moved.
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/13018
Diffstat (limited to 'io_buffer.c')
-rw-r--r-- | io_buffer.c | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/io_buffer.c b/io_buffer.c index a4b7d30018..140571bdbc 100644 --- a/io_buffer.c +++ b/io_buffer.c @@ -273,13 +273,6 @@ io_buffer_free(struct rb_io_buffer *buffer) } void -rb_io_buffer_type_mark(void *_buffer) -{ - struct rb_io_buffer *buffer = _buffer; - rb_gc_mark(buffer->source); -} - -void rb_io_buffer_type_free(void *_buffer) { struct rb_io_buffer *buffer = _buffer; @@ -300,15 +293,20 @@ rb_io_buffer_type_size(const void *_buffer) return total; } +RUBY_REFERENCES(io_buffer_refs) = { + RUBY_REF_EDGE(struct rb_io_buffer, source), + RUBY_REF_END +}; + static const rb_data_type_t rb_io_buffer_type = { .wrap_struct_name = "IO::Buffer", .function = { - .dmark = rb_io_buffer_type_mark, + .dmark = RUBY_REFS_LIST_PTR(io_buffer_refs), .dfree = rb_io_buffer_type_free, .dsize = rb_io_buffer_type_size, }, .data = NULL, - .flags = RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED | RUBY_TYPED_EMBEDDABLE, + .flags = RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED | RUBY_TYPED_EMBEDDABLE | RUBY_TYPED_DECL_MARKING, }; static inline enum rb_io_buffer_flags |