[pulseaudio-discuss] [PATCH 20/21] object: Initialize allocated memory to zero

David Henningsson david.henningsson at canonical.com
Wed Jun 19 10:57:58 PDT 2013


On 06/19/2013 05:40 PM, Tanu Kaskinen wrote:
> This is safer and more convenient for subclasses.
> ---
>   src/pulsecore/object.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/src/pulsecore/object.c b/src/pulsecore/object.c
> index 0dc8198..b6fbe90 100644
> --- a/src/pulsecore/object.c
> +++ b/src/pulsecore/object.c
> @@ -40,7 +40,7 @@ pa_object *pa_object_new_internal(size_t size, const char *type_id, pa_bool_t (*
>       pa_assert(check_type(type_id));
>       pa_assert(check_type(pa_object_type_id));
>
> -    o = pa_xmalloc(size);
> +    o = pa_xmalloc0(size);
>       PA_REFCNT_INIT(o);
>       o->type_id = type_id;
>       o->free = pa_object_free;
>

I think this is a good change in general. It gives the opportunity for 
several cleanups in object implementations where things are explicitly 
set to zero, because with this patch only I assume a lot of things will 
be zeroed twice.

-- 
David Henningsson, Canonical Ltd.
https://launchpad.net/~diwic


More information about the pulseaudio-discuss mailing list