mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -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
							
								
									58fa5561b8
								
							
						
					
					
						commit
						fbf6acd271
					
				
					 2 changed files with 6 additions and 6 deletions
				
			
		| 
						 | 
					@ -92,9 +92,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);
 | 
				
			||||||
| 
						 | 
					@ -189,7 +189,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) {
 | 
				
			||||||
| 
						 | 
					@ -199,7 +199,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;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -144,11 +144,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)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue