From a61e7118e6da9798862b559661075bafce44b541 Mon Sep 17 00:00:00 2001 From: Matt Valentine-House Date: Mon, 31 Mar 2025 13:50:23 +0100 Subject: [PATCH] Provide compaction support for argf_type --- io.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/io.c b/io.c index 6504f97d5b..f055746991 100644 --- a/io.c +++ b/io.c @@ -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 };