[PATCH libXi] Stop unnecessary calls to size_classes

Jeremy Huddleston jeremyhu at apple.com
Fri Nov 11 00:34:51 PST 2011


Why can't you just use malloc() ... do we really need an Xmalloc macro any more?

Either way, all 3 are:
Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com>

On Nov 10, 2011, at 8:50 PM, Peter Hutterer wrote:

> Xmalloc is a macro evaluating its argument twice.
> 
> Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
> ---
> src/XIQueryDevice.c |    4 +++-
> 1 files changed, 3 insertions(+), 1 deletions(-)
> 
> diff --git a/src/XIQueryDevice.c b/src/XIQueryDevice.c
> index af2f27a..66452c2 100644
> --- a/src/XIQueryDevice.c
> +++ b/src/XIQueryDevice.c
> @@ -71,6 +71,7 @@ XIQueryDevice(Display *dpy, int deviceid, int *ndevices_return)
>     for (i = 0; i < reply.num_devices; i++)
>     {
>         int             nclasses;
> +        size_t          sz;
>         XIDeviceInfo    *lib = &info[i];
>         xXIDeviceInfo   *wire = (xXIDeviceInfo*)ptr;
> 
> @@ -86,7 +87,8 @@ XIQueryDevice(Display *dpy, int deviceid, int *ndevices_return)
>         strncpy(lib->name, ptr, wire->name_len);
>         ptr += ((wire->name_len + 3)/4) * 4;
> 
> -        lib->classes = Xmalloc(size_classes((xXIAnyInfo*)ptr, nclasses));
> +        sz = size_classes((xXIAnyInfo*)ptr, nclasses);
> +        lib->classes = Xmalloc(sz);
>         ptr += copy_classes(lib, (xXIAnyInfo*)ptr, &nclasses);
>         /* We skip over unused classes */
>         lib->num_classes = nclasses;
> -- 
> 1.7.7.1
> _______________________________________________
> 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