[pulseaudio-discuss] [PATCH 1/8] card: Use pa_xmalloc0 when creating new cards and profiles

Alexander E. Patrakov patrakov at gmail.com
Wed May 6 02:17:18 PDT 2015


This is trivially correct, but missed one more removable line.

05.05.2015 20:01, David Henningsson wrote:
> Signed-off-by: David Henningsson <david.henningsson at canonical.com>
> ---
>   src/pulsecore/card.c | 13 ++-----------
>   1 file changed, 2 insertions(+), 11 deletions(-)
>
> diff --git a/src/pulsecore/card.c b/src/pulsecore/card.c
> index 6f9391e..f9a5ddc 100644
> --- a/src/pulsecore/card.c
> +++ b/src/pulsecore/card.c
> @@ -41,14 +41,9 @@ pa_card_profile *pa_card_profile_new(const char *name, const char *description,
>
>       pa_assert(name);
>
> -    c = pa_xmalloc(PA_ALIGN(sizeof(pa_card_profile)) + extra);
> -    c->card = NULL;
> +    c = pa_xmalloc0(PA_ALIGN(sizeof(pa_card_profile)) + extra);
>       c->name = pa_xstrdup(name);
>       c->description = pa_xstrdup(description);
> -
> -    c->priority = 0;
> -    c->n_sinks = c->n_sources = 0;
> -    c->max_sink_channels = c->max_source_channels = 0;
>       c->available = PA_AVAILABLE_UNKNOWN;
>
>       return c;
> @@ -135,7 +130,7 @@ pa_card *pa_card_new(pa_core *core, pa_card_new_data *data) {
>       pa_assert(data->profiles);
>       pa_assert(!pa_hashmap_isempty(data->profiles));
>
> -    c = pa_xnew(pa_card, 1);
> +    c = pa_xnew0(pa_card, 1);
>
>       if (!(name = pa_namereg_register(core, data->name, PA_NAMEREG_CARD, c, data->namereg_fail))) {
>           pa_xfree(c);
> @@ -172,7 +167,6 @@ pa_card *pa_card_new(pa_core *core, pa_card_new_data *data) {
>       PA_HASHMAP_FOREACH(port, c->ports, state)
>           port->card = c;
>
> -    c->active_profile = NULL;
>       c->save_profile = false;

This can be removed, too.

>
>       if (data->active_profile)
> @@ -196,9 +190,6 @@ pa_card *pa_card_new(pa_core *core, pa_card_new_data *data) {
>           pa_assert(c->active_profile);
>       }
>
> -    c->userdata = NULL;
> -    c->set_profile = NULL;
> -
>       pa_device_init_description(c->proplist, c);
>       pa_device_init_icon(c->proplist, true);
>       pa_device_init_intended_roles(c->proplist);
>

-- 
Alexander E. Patrakov


More information about the pulseaudio-discuss mailing list