Provide compaction support for argf_type

This commit is contained in:
Matt Valentine-House 2025-03-31 13:50:23 +01:00
parent 6012145299
commit a61e7118e6
Notes: git 2025-03-31 16:11:08 +00:00

13
io.c
View File

@ -9996,9 +9996,20 @@ argf_memsize(const void *ptr)
return size;
}
static void
argf_compact(void *ptr)
{
struct argf *p = ptr;
p->filename = rb_gc_location(p->filename);
p->current_file = rb_gc_location(p->current_file);
p->argv = rb_gc_location(p->argv);
p->inplace = rb_gc_location(p->inplace);
p->encs.ecopts = rb_gc_location(p->encs.ecopts);
}
static const rb_data_type_t argf_type = {
"ARGF",
{argf_mark, RUBY_TYPED_DEFAULT_FREE, argf_memsize},
{argf_mark, RUBY_TYPED_DEFAULT_FREE, argf_memsize, argf_compact},
0, 0, RUBY_TYPED_FREE_IMMEDIATELY
};