Skip to content
Closed
13 changes: 7 additions & 6 deletions ext/-test-/st/numhash/numhash.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,21 +42,22 @@ numhash_aset(VALUE self, VALUE key, VALUE data)
}

static int
numhash_i(st_data_t key, st_data_t value, st_data_t arg, int error)
numhash_i(st_data_t key, st_data_t value, st_data_t arg)
{
VALUE ret;
if (key == 0 && value == 0 && error == 1) rb_raise(rb_eRuntimeError, "numhash modified");
ret = rb_yield_values(3, (VALUE)key, (VALUE)value, (VALUE)arg);
if (ret == Qtrue) return ST_CHECK;
return ST_CONTINUE;
}

static VALUE
numhash_each(VALUE self)
{
st_table *table = DATA_PTR(self);
st_data_t data = (st_data_t)self;
return st_foreach_check(table, numhash_i, data, data) ? Qtrue : Qfalse;
int res;
table->safe_mode = ST_SAFEMODE;
res = st_foreach_check(table, numhash_i, (st_data_t)self);
table->safe_mode = ST_REGULAR;
return res ? Qtrue : Qfalse;
}

static int
Expand Down Expand Up @@ -99,7 +100,7 @@ static VALUE
numhash_delete_safe(VALUE self, VALUE key)
{
st_data_t val, k = (st_data_t)key;
if (st_delete_safe((st_table *)DATA_PTR(self), &k, &val, (st_data_t)self)) {
if (st_delete((st_table *)DATA_PTR(self), &k, &val)) {
return val;
}
return Qnil;
Expand Down
16 changes: 8 additions & 8 deletions ext/tk/tkutil/tkutil.c
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ to_strkey(key, value, hash)
VALUE hash;
{
rb_hash_aset(hash, rb_funcall(key, ID_to_s, 0, 0), value);
return ST_CHECK;
return ST_CONTINUE;
}

static VALUE
Expand All @@ -279,7 +279,7 @@ tk_symbolkey2str(self, keys)

if NIL_P(keys) return new_keys;
keys = rb_convert_type(keys, T_HASH, "Hash", "to_hash");
st_foreach_check(RHASH_TBL(keys), to_strkey, new_keys, Qundef);
st_foreach_check(RHASH_TBL(keys), to_strkey, new_keys);
return new_keys;
}

Expand Down Expand Up @@ -658,11 +658,11 @@ push_kv(key, val, args)
#endif
rb_ary_push(ary, key2keyname(key));

if (val == TK_None) return ST_CHECK;
if (val == TK_None) return ST_CONTINUE;

rb_ary_push(ary, get_eval_string_core(val, Qnil, RARRAY_PTR(args)[1]));

return ST_CHECK;
return ST_CONTINUE;
}

static VALUE
Expand All @@ -674,7 +674,7 @@ hash2kv(hash, ary, self)
volatile VALUE dst = rb_ary_new2(2 * RHASH_SIZE(hash));
volatile VALUE args = rb_ary_new3(2, dst, self);

st_foreach_check(RHASH_TBL(hash), push_kv, args, Qundef);
st_foreach_check(RHASH_TBL(hash), push_kv, args);

if (NIL_P(ary)) {
return dst;
Expand Down Expand Up @@ -702,11 +702,11 @@ push_kv_enc(key, val, args)
#endif
rb_ary_push(ary, key2keyname(key));

if (val == TK_None) return ST_CHECK;
if (val == TK_None) return ST_CONTINUE;

rb_ary_push(ary, get_eval_string_core(val, Qtrue, RARRAY_PTR(args)[1]));

return ST_CHECK;
return ST_CONTINUE;
}

static VALUE
Expand All @@ -718,7 +718,7 @@ hash2kv_enc(hash, ary, self)
volatile VALUE dst = rb_ary_new2(2 * RHASH_SIZE(hash));
volatile VALUE args = rb_ary_new3(2, dst, self);

st_foreach_check(RHASH_TBL(hash), push_kv_enc, args, Qundef);
st_foreach_check(RHASH_TBL(hash), push_kv_enc, args);

if (NIL_P(ary)) {
return dst;
Expand Down
Loading