mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-14 06:59:57 -05:00
list: use spa_list_consume some more
If we know the item is removed in each iteration, _consume can handle deletion of any item while being iterated.
This commit is contained in:
parent
6b269cce35
commit
b700d76ff4
6 changed files with 15 additions and 19 deletions
|
|
@ -87,9 +87,9 @@ struct pw_daemon_config *pw_daemon_config_new(void)
|
||||||
*/
|
*/
|
||||||
void pw_daemon_config_free(struct pw_daemon_config *config)
|
void pw_daemon_config_free(struct pw_daemon_config *config)
|
||||||
{
|
{
|
||||||
struct pw_command *cmd, *tmp;
|
struct pw_command *cmd;
|
||||||
|
|
||||||
spa_list_for_each_safe(cmd, tmp, &config->commands, link)
|
spa_list_consume(cmd, &config->commands, link)
|
||||||
pw_command_free(cmd);
|
pw_command_free(cmd);
|
||||||
|
|
||||||
free(config);
|
free(config);
|
||||||
|
|
@ -184,7 +184,7 @@ int pw_daemon_config_run_commands(struct pw_daemon_config *config, struct pw_cor
|
||||||
{
|
{
|
||||||
char *err = NULL;
|
char *err = NULL;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
struct pw_command *command, *tmp;
|
struct pw_command *command;
|
||||||
|
|
||||||
spa_list_for_each(command, &config->commands, link) {
|
spa_list_for_each(command, &config->commands, link) {
|
||||||
if ((ret = pw_command_run(command, core, &err)) < 0) {
|
if ((ret = pw_command_run(command, core, &err)) < 0) {
|
||||||
|
|
@ -194,7 +194,7 @@ int pw_daemon_config_run_commands(struct pw_daemon_config *config, struct pw_cor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
spa_list_for_each_safe(command, tmp, &config->commands, link)
|
spa_list_consume(command, &config->commands, link)
|
||||||
pw_command_free(command);
|
pw_command_free(command);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
|
||||||
|
|
@ -156,9 +156,9 @@ core_global_removed(void *data, struct pw_global *global)
|
||||||
static void module_destroy(void *data)
|
static void module_destroy(void *data)
|
||||||
{
|
{
|
||||||
struct impl *impl = data;
|
struct impl *impl = data;
|
||||||
struct node_info *info, *t;
|
struct node_info *info;
|
||||||
|
|
||||||
spa_list_for_each_safe(info, t, &impl->node_list, link)
|
spa_list_consume(info, &impl->node_list, link)
|
||||||
node_info_free(info);
|
node_info_free(info);
|
||||||
|
|
||||||
spa_hook_remove(&impl->core_listener);
|
spa_hook_remove(&impl->core_listener);
|
||||||
|
|
|
||||||
|
|
@ -136,11 +136,11 @@ static const struct pw_factory_implementation factory_impl = {
|
||||||
static void factory_destroy(void *_data)
|
static void factory_destroy(void *_data)
|
||||||
{
|
{
|
||||||
struct factory_data *data = _data;
|
struct factory_data *data = _data;
|
||||||
struct node_data *nd, *t;
|
struct node_data *nd;
|
||||||
|
|
||||||
spa_hook_remove(&data->module_listener);
|
spa_hook_remove(&data->module_listener);
|
||||||
|
|
||||||
spa_list_for_each_safe(nd, t, &data->node_list, link)
|
spa_list_consume(nd, &data->node_list, link)
|
||||||
pw_node_destroy(nd->node);
|
pw_node_destroy(nd->node);
|
||||||
|
|
||||||
if (data->properties)
|
if (data->properties)
|
||||||
|
|
|
||||||
|
|
@ -85,14 +85,14 @@ pw_control_new(struct pw_core *core,
|
||||||
void pw_control_destroy(struct pw_control *control)
|
void pw_control_destroy(struct pw_control *control)
|
||||||
{
|
{
|
||||||
struct impl *impl = SPA_CONTAINER_OF(control, struct impl, this);
|
struct impl *impl = SPA_CONTAINER_OF(control, struct impl, this);
|
||||||
struct pw_control *other, *tmp;
|
struct pw_control *other;
|
||||||
|
|
||||||
pw_log_debug("control %p: destroy", control);
|
pw_log_debug("control %p: destroy", control);
|
||||||
|
|
||||||
pw_control_events_destroy(control);
|
pw_control_events_destroy(control);
|
||||||
|
|
||||||
if (control->direction == SPA_DIRECTION_OUTPUT) {
|
if (control->direction == SPA_DIRECTION_OUTPUT) {
|
||||||
spa_list_for_each_safe(other, tmp, &control->inputs, inputs_link)
|
spa_list_consume(other, &control->inputs, inputs_link)
|
||||||
pw_control_unlink(control, other);
|
pw_control_unlink(control, other);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
||||||
|
|
@ -644,14 +644,10 @@ void pw_node_destroy(struct pw_node *node)
|
||||||
pw_port_unlink(port);
|
pw_port_unlink(port);
|
||||||
|
|
||||||
pw_log_debug("node %p: destroy ports", node);
|
pw_log_debug("node %p: destroy ports", node);
|
||||||
spa_list_consume(port, &node->input_ports, link) {
|
spa_list_consume(port, &node->input_ports, link)
|
||||||
pw_node_events_port_removed(node, port);
|
|
||||||
pw_port_destroy(port);
|
pw_port_destroy(port);
|
||||||
}
|
spa_list_consume(port, &node->output_ports, link)
|
||||||
spa_list_consume(port, &node->output_ports, link) {
|
|
||||||
pw_node_events_port_removed(node, port);
|
|
||||||
pw_port_destroy(port);
|
pw_port_destroy(port);
|
||||||
}
|
|
||||||
|
|
||||||
if (node->global) {
|
if (node->global) {
|
||||||
spa_hook_remove(&node->global_listener);
|
spa_hook_remove(&node->global_listener);
|
||||||
|
|
|
||||||
|
|
@ -487,14 +487,14 @@ int pw_port_add(struct pw_port *port, struct pw_node *node)
|
||||||
|
|
||||||
void pw_port_unlink(struct pw_port *port)
|
void pw_port_unlink(struct pw_port *port)
|
||||||
{
|
{
|
||||||
struct pw_link *l, *t;
|
struct pw_link *l;
|
||||||
|
|
||||||
if (port->direction == PW_DIRECTION_OUTPUT) {
|
if (port->direction == PW_DIRECTION_OUTPUT) {
|
||||||
spa_list_for_each_safe(l, t, &port->links, output_link)
|
spa_list_consume(l, &port->links, output_link)
|
||||||
pw_link_destroy(l);
|
pw_link_destroy(l);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
spa_list_for_each_safe(l, t, &port->links, input_link)
|
spa_list_consume(l, &port->links, input_link)
|
||||||
pw_link_destroy(l);
|
pw_link_destroy(l);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue