From 3a9ef9d27ef47d8fa60ba83d3df75cdb2ed22b27 Mon Sep 17 00:00:00 2001 From: dearblue Date: Wed, 8 Apr 2026 21:10:45 +0900 Subject: [PATCH] Avoid using the deprecated function `mrb_data_check_and_get()` The "d" directive in `mrb_get_args()` can be used as an alternative. Furthermore, NULL checking is unnecessary for the following reasons: - Incomplete objects from `ary_combination_init()` are not passed to the caller and are garbage collected when `ObjectSpace.each_object` is called, so they are never retrieved - Even if `state.clone` is called, the `RData::type` of the cloned object is set to NULL, so it is rejected by `mrb_get_args()` --- mrbgems/mruby-array-ext/src/array.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/mrbgems/mruby-array-ext/src/array.c b/mrbgems/mruby-array-ext/src/array.c index 70473c087..ece9914df 100644 --- a/mrbgems/mruby-array-ext/src/array.c +++ b/mrbgems/mruby-array-ext/src/array.c @@ -1575,16 +1575,8 @@ ary_combination_init(mrb_state *mrb, mrb_value self) static mrb_value ary_combination_next(mrb_state *mrb, mrb_value self) { - mrb_value state_obj; - mrb_get_args(mrb, "o", &state_obj); - struct mrb_combination_state *state; - - /* Validate state object type and get data */ - state = (struct mrb_combination_state*)mrb_data_check_and_get(mrb, state_obj, &mrb_combination_state_type); - if (!state) { - mrb_raise(mrb, E_ARGUMENT_ERROR, "invalid combination state"); - } + mrb_get_args(mrb, "d", &state, &mrb_combination_state_type); /* Check if iteration is complete */ if (state->finished) return mrb_nil_value();