pipewire: allow NULL pointers in pw_free_strv()

Just like the real free() we should just ignore a NULL pointer, makes the
caller code easier for those instances where properties are optional.
This commit is contained in:
Peter Hutterer 2021-06-02 15:19:19 +10:00 committed by Wim Taymans
parent e0471c6757
commit 71e0cfb5fa
5 changed files with 10 additions and 12 deletions

View file

@ -384,7 +384,6 @@ static int module_combine_sink_unload(struct client *client, struct module *modu
pw_manager_destroy(d->manager);
if (d->core != NULL)
pw_core_disconnect(d->core);
if (d->sink_names)
pw_free_strv(d->sink_names);
free(d->sink_name);
@ -462,7 +461,6 @@ struct module *create_module_combine_sink(struct impl *impl, const char *argumen
return module;
out:
pw_properties_free(props);
if (sink_names)
pw_free_strv(sink_names);
errno = -res;

View file

@ -117,7 +117,6 @@ error_arguments:
pw_log_error("usage: module-spa-device " MODULE_USAGE);
goto error_exit_cleanup;
error_exit_cleanup:
if (argv)
pw_free_strv(argv);
return res;
}

View file

@ -119,7 +119,6 @@ error_arguments:
pw_log_error("usage: module-spa-node " MODULE_USAGE);
goto error_exit_cleanup;
error_exit_cleanup:
if (argv)
pw_free_strv(argv);
return res;
}

View file

@ -221,7 +221,6 @@ static void configure_debug(struct support *support, const char *str)
if (n_tokens > 1)
support->categories = pw_split_strv(level[1], ",", INT_MAX, &n_tokens);
if (level)
pw_free_strv(level);
}
@ -564,7 +563,6 @@ void pw_deinit(void)
unref_handle(h);
unref_plugin(p);
}
if (support->categories)
pw_free_strv(support->categories);
free(support->i18n_domain);
spa_zero(global_support);

View file

@ -99,6 +99,10 @@ SPA_EXPORT
void pw_free_strv(char **str)
{
int i;
if (str == NULL)
return;
for (i = 0; str[i]; i++)
free(str[i]);
free(str);