Explicitly convert between VALUE and st_data_t

This commit is contained in:
Nobuyoshi Nakada 2024-01-14 23:44:18 +09:00
parent c5cf4d4e12
commit dde21a7967
No known key found for this signature in database
GPG Key ID: 3582D74E1FEE4465

12
hash.c
View File

@ -844,7 +844,9 @@ ar_general_foreach(VALUE hash, st_foreach_check_callback_func *func, st_update_c
if (ar_cleared_entry(hash, i)) continue;
ar_table_pair *pair = RHASH_AR_TABLE_REF(hash, i);
enum st_retval retval = (*func)(pair->key, pair->val, arg, 0);
st_data_t key = (st_data_t)pair->key;
st_data_t val = (st_data_t)pair->val;
enum st_retval retval = (*func)(key, val, arg, 0);
ensure_ar_table(hash);
/* pair may be not valid here because of theap */
@ -856,14 +858,12 @@ ar_general_foreach(VALUE hash, st_foreach_check_callback_func *func, st_update_c
return 0;
case ST_REPLACE:
if (replace) {
VALUE key = pair->key;
VALUE val = pair->val;
retval = (*replace)(&key, &val, arg, TRUE);
// TODO: pair should be same as pair before.
ar_table_pair *pair = RHASH_AR_TABLE_REF(hash, i);
pair->key = key;
pair->val = val;
pair = RHASH_AR_TABLE_REF(hash, i);
pair->key = (VALUE)key;
pair->val = (VALUE)val;
}
break;
case ST_DELETE: