}
static int cbt_traverse_prefixed(void *top,
- int (*callback)(const char *, void *), void *baton)
+ int (*callback)(const char *, void *, void *), void *baton)
{
uint8_t *p = top;
cb_data_t *x = (cb_data_t *)top;
return 0;
}
- return (callback)((const char *)x->key, baton);
+ return (callback)((const char *)x->key, x->value, baton);
}
static cb_data_t *cbt_make_data(map_t *map, const uint8_t *str, size_t len, void *value)
/*! Calls callback for all strings in map with the given prefix */
int map_walk_prefixed(map_t *map, const char *prefix,
- int (*callback)(const char *, void *), void *baton)
+ int (*callback)(const char *, void *, void *), void *baton)
{
const uint8_t *ubytes = (void *)prefix;
const size_t ulen = strlen(prefix);
/*! Clears the given map */
void map_clear(map_t *map);
+/*! Calls callback for all strings in map */
+#define map_walk(map, callback, baton) \
+ map_walk_prefixed((map), "", (callback), (baton))
+
/*! Calls callback for all strings in map with the given prefix */
int map_walk_prefixed(map_t *map, const char *prefix,
- int (*callback)(const char *, void *), void *baton);
+ int (*callback)(const char *, void *, void *), void *baton);
#ifdef __cplusplus
#define set_clear(set) \
map_clear(set)
+/*! Calls callback for all strings in map */
+#define set_walk(set, callback, baton) \
+ map_walk_prefixed((set), "", (callback), (baton))
+
/*! Calls callback for all strings in set with the given prefix */
#define set_walk_prefixed(set, prefix, callback, baton) \
- map_walk_prefixed((set), (prefix), (callback), baton)
+ map_walk_prefixed((set), (prefix), (callback), (baton))
#ifdef __cplusplus
}
/* Count number of items */
-static int count_cb(const char *s, void *n) { (*(int *)n)++; return 0; }
+static int count_cb(const char *s, void *_, void *n) { (*(int *)n)++; return 0; }
static void test_complete(set_t *set, int n)
{
int i = 0;
- if (set_walk_prefixed(set, "", count_cb, &i) != 0) {
+ if (set_walk(set, count_cb, &i) != 0) {
abort();
}
if (i != n) {