Skip to content

Commit 9e92a3d

Browse files
cosmo0920edsiper
authored andcommitted
st: Extract concrete function signatures
Signed-off-by: Hiroshi Hatake <hiroshi@chronosphere.io>
1 parent 306aa0b commit 9e92a3d

2 files changed

Lines changed: 9 additions & 8 deletions

File tree

st.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1600,7 +1600,7 @@ st_update(st_table *tab, st_data_t key,
16001600
different for ST_CHECK and when the current element is removed
16011601
during traversing. */
16021602
static inline int
1603-
st_general_foreach(st_table *tab, int (*func)(ANYARGS), st_update_callback_func *replace, st_data_t arg,
1603+
st_general_foreach(st_table *tab, st_foreach_callback_func *func, st_update_callback_func *replace, st_data_t arg,
16041604
int check_p)
16051605
{
16061606
st_index_t bin;
@@ -1712,22 +1712,22 @@ st_general_foreach(st_table *tab, int (*func)(ANYARGS), st_update_callback_func
17121712

17131713
#ifdef RUBY
17141714
int
1715-
st_foreach_with_replace(st_table *tab, int (*func)(ANYARGS), st_update_callback_func *replace, st_data_t arg)
1715+
st_foreach_with_replace(st_table *tab, st_foreach_callback_func *func, st_update_callback_func *replace, st_data_t arg)
17161716
{
17171717
return st_general_foreach(tab, func, replace, arg, TRUE);
17181718
}
17191719
#endif /* RUBY */
17201720

17211721
int
1722-
st_foreach(st_table *tab, int (*func)(ANYARGS), st_data_t arg)
1722+
st_foreach(st_table *tab, st_foreach_callback_func *func, st_data_t arg)
17231723
{
17241724
return st_general_foreach(tab, func, NULL, arg, FALSE);
17251725
}
17261726

17271727
#ifdef RUBY
17281728
/* See comments for function st_delete_safe. */
17291729
int
1730-
st_foreach_check(st_table *tab, int (*func)(ANYARGS), st_data_t arg,
1730+
st_foreach_check(st_table *tab, st_foreach_callback_func *func, st_data_t arg,
17311731
st_data_t never ATTRIBUTE_UNUSED)
17321732
{
17331733
return st_general_foreach(tab, func, NULL, arg, TRUE);

st.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ typedef char st_check_for_sizeof_st_index_t[SIZEOF_VOIDP == (int)sizeof(st_index
6666
#define SIZEOF_ST_INDEX_T SIZEOF_VOIDP
6767

6868
struct st_hash_type {
69-
int (*compare)(ANYARGS /*st_data_t, st_data_t*/); /* st_compare_func* */
70-
st_index_t (*hash)(ANYARGS /*st_data_t*/); /* st_hash_func* */
69+
int (*compare)(st_data_t, st_data_t); /* st_compare_func* */
70+
st_index_t (*hash)(st_data_t); /* st_hash_func* */
7171
};
7272

7373
#define ST_INDEX_BITS (SIZEOF_ST_INDEX_T * CHAR_BIT)
@@ -124,9 +124,10 @@ typedef int st_update_callback_func(st_data_t *key, st_data_t *value, st_data_t
124124
/* *key may be altered, but must equal to the old key, i.e., the
125125
* results of hash() are same and compare() returns 0, otherwise the
126126
* behavior is undefined */
127+
typedef int st_foreach_callback_func(st_data_t key, st_data_t value, st_data_t arg, int existing);
127128
int st_update(st_table *table, st_data_t key, st_update_callback_func *func, st_data_t arg);
128-
int st_foreach_with_replace(st_table *tab, int (*func)(ANYARGS), st_update_callback_func *replace, st_data_t arg);
129-
int st_foreach(st_table *, int (*)(ANYARGS), st_data_t);
129+
int st_foreach_with_replace(st_table *tab, st_foreach_callback_func *func, st_update_callback_func *replace, st_data_t arg);
130+
int st_foreach(st_table *, st_foreach_callback_func *func, st_data_t);
130131
int st_foreach_check(st_table *, int (*)(ANYARGS), st_data_t, st_data_t);
131132
st_index_t st_keys(st_table *table, st_data_t *keys, st_index_t size);
132133
st_index_t st_keys_check(st_table *table, st_data_t *keys, st_index_t size, st_data_t never);

0 commit comments

Comments
 (0)