[PATCH] input: add valuator_mask_free() to free a valuator mask.

Chase Douglas chase.douglas at canonical.com
Wed Jan 5 20:00:33 PST 2011


On 01/05/2011 10:12 PM, Peter Hutterer wrote:
> Expecting the caller to free the mask requires us to keep it in a single
> memory block (which may be an issue lateron), aside from leaving the API
> asymetrical. Provide valuator_mask_free() to free the memory and reset the
> mask pointer to NULL.
> 
> Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
> ---
> bit of an oversight in the first patchset...
> 
>  dix/inpututils.c |    8 ++++++++
>  include/input.h  |    1 +
>  test/input.c     |    3 ++-
>  3 files changed, 11 insertions(+), 1 deletions(-)
> 
> diff --git a/dix/inpututils.c b/dix/inpututils.c
> index 2877804..ef3142c 100644
> --- a/dix/inpututils.c
> +++ b/dix/inpututils.c
> @@ -433,6 +433,14 @@ valuator_mask_new(int num_valuators)
>      return mask;
>  }
>  
> +void
> +valuator_mask_free(ValuatorMask **mask)
> +{
> +    free(*mask);
> +    *mask = NULL;
> +}

I'm curious why not just a single pointer like traditional free(),
leaving the task of setting the pointer to NULL to the caller?

-- Chase


More information about the xorg-devel mailing list