summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author卜部昌平 <[email protected]>2019-08-26 16:06:40 +0900
committer卜部昌平 <[email protected]>2019-08-27 15:52:26 +0900
commit6dd60cf114701f1ff3526381c0e742c588af2f91 ()
treed3552b145f9b5153c470ad7e3cf560c0dd5c552e
parente3fc30564e9466d6926f9d25a090dcf787bd5c33 (diff)
st_foreach now free from ANYARGS
After 5e86b005c0f2ef30df2f9906c7e2f3abefe286a2, I now think ANYARGS is dangerous and should be extinct. This commit deletes ANYARGS from st_foreach. I strongly believe that this commit should have had come with b0af0592fdd9e9d4e4b863fde006d67ccefeac21, which added extra parameter to st_foreach callbacks.
-rw-r--r--ext/-test-/st/foreach/foreach.c2
-rw-r--r--ext/-test-/st/numhash/numhash.c3
-rw-r--r--ext/objspace/object_tracing.c4
-rw-r--r--gc.c2
-rw-r--r--include/ruby/st.h8
-rw-r--r--marshal.c2
-rw-r--r--regparse.c8
-rw-r--r--st.c23
8 files changed, 33 insertions, 19 deletions
@@ -106,7 +106,7 @@ unp_fec(VALUE self, VALUE test)
}
static int
-unp_fe_i(st_data_t key, st_data_t val, st_data_t args, int error)
{
struct checker *c = (struct checker *)args;
@@ -57,7 +57,7 @@ numhash_aset(VALUE self, VALUE key, VALUE data)
}
static int
-numhash_i(st_data_t key, st_data_t value, st_data_t arg)
{
VALUE ret;
ret = rb_yield_values(3, (VALUE)key, (VALUE)value, (VALUE)arg);
@@ -135,4 +135,3 @@ Init_numhash(void)
rb_define_method(st, "size", numhash_size, 0);
rb_define_method(st, "delete_safe", numhash_delete_safe, 1);
}
-
@@ -138,14 +138,14 @@ freeobj_i(VALUE tpval, void *data)
}
static int
-free_keys_i(st_data_t key, st_data_t value, void *data)
{
ruby_xfree((void *)key);
return ST_CONTINUE;
}
static int
-free_values_i(st_data_t key, st_data_t value, void *data)
{
ruby_xfree((void *)value);
return ST_CONTINUE;
@@ -5620,7 +5620,7 @@ gc_check_after_marks_i(st_data_t k, st_data_t v, void *ptr)
}
static void
-gc_marks_check(rb_objspace_t *objspace, int (*checker_func)(ANYARGS), const char *checker_name)
{
size_t saved_malloc_increase = objspace->malloc_params.increase;
#if RGENGC_ESTIMATE_OLDMALLOC
@@ -118,9 +118,11 @@ typedef int st_update_callback_func(st_data_t *key, st_data_t *value, st_data_t
* results of hash() are same and compare() returns 0, otherwise the
* behavior is undefined */
int st_update(st_table *table, st_data_t key, st_update_callback_func *func, st_data_t arg);
-int st_foreach_with_replace(st_table *tab, int (*func)(ANYARGS), st_update_callback_func *replace, st_data_t arg);
-int st_foreach(st_table *, int (*)(ANYARGS), st_data_t);
-int st_foreach_check(st_table *, int (*)(ANYARGS), st_data_t, st_data_t);
st_index_t st_keys(st_table *table, st_data_t *keys, st_index_t size);
st_index_t st_keys_check(st_table *table, st_data_t *keys, st_index_t size, st_data_t never);
st_index_t st_values(st_table *table, st_data_t *values, st_index_t size);
@@ -112,7 +112,7 @@ static VALUE rb_marshal_dump_limited(VALUE obj, VALUE port, int limit);
static VALUE rb_marshal_load_with_proc(VALUE port, VALUE proc);
static int
-mark_marshal_compat_i(st_data_t key, st_data_t value)
{
marshal_compat_t *p = (marshal_compat_t *)value;
rb_gc_mark(p->newclass);
@@ -493,7 +493,7 @@ onig_print_names(FILE* fp, regex_t* reg)
if (IS_NOT_NULL(t)) {
fprintf(fp, "name table\n");
- onig_st_foreach(t, i_print_name_entry, (HashDataType )fp);
fputs("\n", fp);
}
return 0;
@@ -516,7 +516,7 @@ names_clear(regex_t* reg)
NameTable* t = (NameTable* )reg->name_table;
if (IS_NOT_NULL(t)) {
- onig_st_foreach(t, i_free_name_entry, 0);
}
return 0;
}
@@ -585,7 +585,7 @@ onig_foreach_name(regex_t* reg,
narg.reg = reg;
narg.arg = arg;
narg.enc = reg->enc; /* should be pattern encoding. */
- onig_st_foreach(t, i_names, (HashDataType )&narg);
}
return narg.ret;
}
@@ -613,7 +613,7 @@ onig_renumber_name_table(regex_t* reg, GroupNumRemap* map)
NameTable* t = (NameTable* )reg->name_table;
if (IS_NOT_NULL(t)) {
- onig_st_foreach(t, i_renumber_name, (HashDataType )map);
}
return 0;
}
@@ -1548,7 +1548,7 @@ st_update(st_table *tab, st_data_t key,
different for ST_CHECK and when the current element is removed
during traversing. */
static inline int
-st_general_foreach(st_table *tab, int (*func)(ANYARGS), st_update_callback_func *replace, st_data_t arg,
int check_p)
{
st_index_t bin;
@@ -1659,20 +1659,33 @@ st_general_foreach(st_table *tab, int (*func)(ANYARGS), st_update_callback_func
}
int
-st_foreach_with_replace(st_table *tab, int (*func)(ANYARGS), st_update_callback_func *replace, st_data_t arg)
{
return st_general_foreach(tab, func, replace, arg, TRUE);
}
int
-st_foreach(st_table *tab, int (*func)(ANYARGS), st_data_t arg)
{
- return st_general_foreach(tab, func, NULL, arg, FALSE);
}
/* See comments for function st_delete_safe. */
int
-st_foreach_check(st_table *tab, int (*func)(ANYARGS), st_data_t arg,
st_data_t never ATTRIBUTE_UNUSED)
{
return st_general_foreach(tab, func, NULL, arg, TRUE);