[xf86-input-synaptics v3 10/14] Add open_slots array to SynapticsPrivate

Peter Hutterer peter.hutterer at who-t.net
Fri Feb 10 12:31:31 PST 2012


On Fri, Feb 10, 2012 at 11:56:54AM -0800, Chase Douglas wrote:
> Signed-off-by: Chase Douglas <chase.douglas at canonical.com>
> ---
>  src/synaptics.c    |   35 ++++++++++++++++++++++++++---------
>  src/synapticsstr.h |    1 +
>  2 files changed, 27 insertions(+), 9 deletions(-)
> 
> diff --git a/src/synaptics.c b/src/synaptics.c
> index a6b1b18..c86351d 100644
> --- a/src/synaptics.c
> +++ b/src/synaptics.c
> @@ -814,6 +814,10 @@ static void SynapticsUnInit(InputDriverPtr drv,
>      if (priv && priv->scroll_events_mask)
>          valuator_mask_free(&priv->scroll_events_mask);
>  #endif
> +#ifdef HAVE_MULTITOUCH
> +    if (priv && priv->open_slots)
> +        free(priv->open_slots);
> +#endif
>      free(pInfo->private);
>      pInfo->private = NULL;
>      xf86DeleteInput(pInfo, 0);
> @@ -1150,6 +1154,15 @@ DeviceInit(DeviceIntPtr dev)
>      {
>          priv->num_slots = priv->max_touches ? priv->max_touches : 10;
>  
> +        priv->open_slots = malloc(priv->num_slots * sizeof(int));
> +        if (!priv->open_slots)
> +        {
> +            xf86IDrvMsg(pInfo, X_ERROR,
> +                        "failed to allocate open touch slots array\n");
> +            priv->has_touch = 0;
> +            goto no_touch;
> +        }
> +
>          /* x/y + whatever other MT axes we found */
>          if (!InitTouchClassDeviceStruct(dev, priv->max_touches,
>                                          XIDependentTouch, 2 + priv->num_mt_axes))
> @@ -1158,6 +1171,8 @@ DeviceInit(DeviceIntPtr dev)
>                          "failed to initialize touch class device\n");
>              priv->has_touch = 0;
>              priv->num_slots = 0;
> +            free(priv->open_slots);
> +            priv->open_slots = NULL;
>              goto no_touch;

given that all the touch stuff is in an if condition, i think we'd be better
off with a helper function than a goto. That can be a follow-up patch
though, no need to rework this one.

Cheers,
  Peter

>          }
>  
> @@ -1191,24 +1206,26 @@ no_touch:
>  
>      priv->local_hw_state = SynapticsHwStateAlloc(priv);
>      if (!priv->local_hw_state)
> -    {
> -	free(priv->hwState);
> -	return !Success;
> -    }
> +	goto fail;
>  
>      priv->comm.hwState = SynapticsHwStateAlloc(priv);
>  
>      if (!alloc_shm_data(pInfo))
> -    {
> -	free(priv->local_hw_state);
> -	free(priv->hwState);
> -	return !Success;
> -    }
> +        goto fail;
>  
>      InitDeviceProperties(pInfo);
>      XIRegisterPropertyHandler(pInfo->dev, SetProperty, NULL, NULL);
>  
>      return Success;
> +
> +fail:
> +    free_shm_data(priv);
> +    free(priv->local_hw_state);
> +    free(priv->hwState);
> +#ifdef HAVE_MULTITOUCH
> +    free(priv->open_slots);
> +#endif
> +    return !Success;
>  }
>  
>  
> diff --git a/src/synapticsstr.h b/src/synapticsstr.h
> index 1c8342c..aeaf906 100644
> --- a/src/synapticsstr.h
> +++ b/src/synapticsstr.h
> @@ -282,6 +282,7 @@ typedef struct _SynapticsPrivateRec
>      int num_mt_axes;                    /* Number of multitouch axes other than X, Y */
>      SynapticsTouchAxisRec *touch_axes;  /* Touch axis information other than X, Y */
>      int num_slots;                      /* Number of touch slots allocated */
> +    int *open_slots;                    /* Array of currently open touch slots */
>  #endif
>  } SynapticsPrivate;
>  
> -- 
> 1.7.8.3
> 


More information about the xorg-devel mailing list