[PATCH:libXi] Expand comment on the memory vs. reply ordering in XIGetSelectedEvents()

Peter Hutterer peter.hutterer at who-t.net
Mon Apr 29 18:51:35 PDT 2013


On Mon, Apr 29, 2013 at 06:39:34PM -0700, Alan Coopersmith wrote:
> Unpacking from the wire involves un-interleaving the structs & masks,
> which wasn't obvious to me the first time I read it, so make notes
> before I forget again.
> 
> Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
> ---
> 
> Feel free to reword or clarify to improve this, just figured I'd save the
> next person the 15 minutes of head scratching I went through until I realized
> the comment describes the non-interleaved memory layout generated later in the 
> function, even though it appears right before the interleaved reply parsing.

fine as it is I think. Thanks, pushed

Cheers,
   Peter

> 
>  src/XISelEv.c |   10 ++++++++--
>  1 file changed, 8 insertions(+), 2 deletions(-)
> 
> diff --git a/src/XISelEv.c b/src/XISelEv.c
> index fa7eb54..f871222 100644
> --- a/src/XISelEv.c
> +++ b/src/XISelEv.c
> @@ -135,8 +135,14 @@ XIGetSelectedEvents(Display* dpy, Window win, int *num_masks_return)
>  
>      _XRead(dpy, (char*)mask_in, reply.length * 4);
>  
> -    /* Memory layout of the XIEventMask for a 3 mask reply:
> -     * [struct a][struct b][struct c][masks a][masks b][masks c]
> +    /*
> +     * This function takes interleaved xXIEventMask structs & masks off
> +     * the wire, such as this 3 mask reply:
> +     *   [struct a][masks a][struct b][masks b][struct c][masks c]
> +     * And generates a memory buffer to be returned to callers in which
> +     * they are not interleaved, so that callers can treat the returned
> +     * pointer as a simple array of XIEventMask structs, such as:
> +     *   [struct a][struct b][struct c][masks a][masks b][masks c]
>       */
>      len = reply.num_masks * sizeof(XIEventMask);
>  
> -- 
> 1.7.9.2
> 


More information about the xorg-devel mailing list