[PATCH xf86-input-synaptics 01/10] Introduce SynapticsHwStateAlloc() and SynapticsHwStateFree()

Peter Hutterer peter.hutterer at who-t.net
Thu Feb 9 06:09:51 PST 2012


On Wed, Feb 08, 2012 at 06:35:10PM -0800, Chase Douglas wrote:
> Signed-off-by: Chase Douglas <chase.douglas at canonical.com>
> ---
>  src/synaptics.c |   12 ++++++++++++
>  src/synproto.h  |    6 ++++++
>  2 files changed, 18 insertions(+), 0 deletions(-)
> 
> diff --git a/src/synaptics.c b/src/synaptics.c
> index a4c1e5a..48fa519 100644
> --- a/src/synaptics.c
> +++ b/src/synaptics.c
> @@ -2809,3 +2809,15 @@ CalculateScalingCoeffs(SynapticsPrivate *priv)
>          priv->vert_coeff = 1;
>      }
>  }
> +
> +struct SynapticsHwState *
> +SynapticsHwStateAlloc(SynapticsPrivate *priv)
> +{
> +    return calloc(1, sizeof(struct SynapticsHwState));
> +}
> +
> +void
> +SynapticsHwStateFree(struct SynapticsHwState *hw)

can we do the double-pointer thing here? I find it reduces bugs if the
FreeFoobar() function also resets the pointers to NULL.

Cheers,
  Peter

> +{
> +    free(hw);
> +}
> diff --git a/src/synproto.h b/src/synproto.h
> index 6962bbf..7ec5142 100644
> --- a/src/synproto.h
> +++ b/src/synproto.h
> @@ -32,6 +32,9 @@
>  #include <xf86Xinput.h>
>  #include <xisb.h>
>  
> +struct _SynapticsPrivateRec;
> +typedef struct _SynapticsPrivateRec SynapticsPrivate;
> +
>  /*
>   * A structure to describe the state of the touchpad hardware (buttons and pad)
>   */
> @@ -90,4 +93,7 @@ extern struct SynapticsProtocolOperations event_proto_operations;
>  extern struct SynapticsProtocolOperations psm_proto_operations;
>  #endif /* BUILD_PSMCOMM */
>  
> +extern struct SynapticsHwState *SynapticsHwStateAlloc(SynapticsPrivate *priv);
> +extern void SynapticsHwStateFree(struct SynapticsHwState *hw);
> +
>  #endif /* _SYNPROTO_H_ */
> -- 
> 1.7.8.3
> 


More information about the xorg-devel mailing list