[PATCH joystick 2/2] Deal with opaque input option types.
Jeremy Huddleston
jeremyhu at apple.com
Sun Oct 30 23:18:18 PDT 2011
You need to declare InputOption tmp; in input_option_free_list.
With that, both are Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com>
On Oct 30, 2011, at 21:41, Peter Hutterer wrote:
> ABI 14 made the InputOption type opaque, move the existing code to ifdefs
> and use the new function calls otherwise.
>
> Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
> ---
> src/jstk_key.c | 50 +++++++++++++++++++++++++++++++++++---------------
> 1 files changed, 35 insertions(+), 15 deletions(-)
>
> diff --git a/src/jstk_key.c b/src/jstk_key.c
> index e842941..896bffc 100644
> --- a/src/jstk_key.c
> +++ b/src/jstk_key.c
> @@ -247,13 +247,43 @@ int jstkKeyboardPreInit(InputDriverPtr drv, InputInfoPtr pInfo, int flags)
> return Success;
> }
>
> +#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) < 14
> +static InputOption*
> +input-option_new(InputOption* list, const char *key, const char *value)
> +{
> + InputOption tmp;
> + tmp = calloc(1, sizeof(InputOption));
> + tmp->key = xf86OptionName(opts);
> + tmp->value = xf86OptionValue(opts);
> + tmp->next = list;
> + return tmp;
> +}
> +
> +static void
> +input_option_free_list(InputOption **list)
> +{
> + InputOption *iopts = *list;
> + while(iopts)
> + {
> + tmp = iopts->next;
> + free(iopts->key);
> + free(iopts->value);
> + free(iopts);
> + iopts = tmp;
> + }
> +
> + *list = NULL;
> +}
> +
> +#endif
> +
> InputInfoPtr
> jstkKeyboardHotplug(InputInfoPtr pInfo, int flags)
> {
> int rc;
> char name[512] = {0};
> InputAttributes *attrs = NULL;
> - InputOption *iopts = NULL, *tmp;
> + InputOption *iopts = NULL;
> DeviceIntPtr dev;
> XF86OptionPtr opts;
>
> @@ -266,12 +296,9 @@ jstkKeyboardHotplug(InputInfoPtr pInfo, int flags)
>
> while(opts)
> {
> - tmp = calloc(1, sizeof(InputOption));
> -
> - tmp->key = xf86OptionName(opts);
> - tmp->value = xf86OptionValue(opts);
> - tmp->next = iopts;
> - iopts = tmp;
> + iopts = input_option_new(iopts,
> + xf86OptionName(opts),
> + xf86OptionValue(opts));
> opts = xf86NextOption(opts);
> }
>
> @@ -280,14 +307,7 @@ jstkKeyboardHotplug(InputInfoPtr pInfo, int flags)
>
> rc = NewInputDeviceRequest(iopts, attrs, &dev);
>
> - while(iopts)
> - {
> - tmp = iopts->next;
> - free(iopts->key);
> - free(iopts->value);
> - free(iopts);
> - iopts = tmp;
> - }
> + input_option_free_list(&iopts);
>
> FreeInputAttributes(attrs);
>
> --
> 1.7.7
> _______________________________________________
> xorg-devel at lists.x.org: X.Org development
> Archives: http://lists.x.org/archives/xorg-devel
> Info: http://lists.x.org/mailman/listinfo/xorg-devel
>
More information about the xorg-devel
mailing list