Skip to content

Commit

Permalink
Explicitly convert between VALUE and st_data_t
Browse files Browse the repository at this point in the history
  • Loading branch information
nobu committed Jan 15, 2024
1 parent c5cf4d4 commit dde21a7
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions hash.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */

Expand All @@ -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:
Expand Down

0 comments on commit dde21a7

Please sign in to comment.