map: make for_each use a return value

Make it possible to stop pw_map_for_each by adding a return value
to the callback.
This commit is contained in:
Wim Taymans 2018-08-15 11:18:55 +02:00
parent 5fe230e5ff
commit f71be550c3
3 changed files with 21 additions and 10 deletions

View file

@ -259,13 +259,13 @@ static void on_sync_reply(void *_data, uint32_t seq)
}
}
static void print_global(void *obj, void *data)
static int print_global(void *obj, void *data)
{
struct global *global = obj;
struct pw_type *t;
if (global == NULL)
return;
return 0;
t = global->rd->data->t;
@ -275,6 +275,7 @@ static void print_global(void *obj, void *data)
if (global->properties)
print_properties(&global->properties->dict, ' ', false);
return 0;
}
static void registry_event_global(void *data, uint32_t id, uint32_t parent_id,
@ -303,17 +304,18 @@ static void registry_event_global(void *data, uint32_t id, uint32_t parent_id,
pw_map_insert_at(&rd->globals, id, global);
}
static void destroy_global(void *obj, void *data)
static int destroy_global(void *obj, void *data)
{
struct global *global = obj;
if (global == NULL)
return;
return 0;
pw_map_remove(&global->rd->globals, global->id);
if (global->properties)
pw_properties_free(global->properties);
free(global);
return 0;
}
static void registry_event_global_remove(void *data, uint32_t id)
@ -902,18 +904,19 @@ static bool do_global_info(struct global *global, char **error)
}
return true;
}
static void do_global_info_all(void *obj, void *data)
static int do_global_info_all(void *obj, void *data)
{
struct global *global = obj;
char *error;
if (global == NULL)
return;
return 0;
if (!do_global_info(global, &error)) {
fprintf(stderr, "info: %s\n", error);
free(error);
}
return 0;
}
static bool do_info(struct data *data, const char *cmd, char *args, char **error)