[PATCH] mi: streamline CopyGetMasterEvent(), remove code duplication.

Daniel Stone daniel at fooishbar.org
Mon Dec 8 06:57:47 PST 2008


On Mon, Dec 08, 2008 at 06:13:36PM +1000, Peter Hutterer wrote:
> +    int len = count * sizeof(xEvent);
> +    xEvent *ev;
> +
> +    /* Assumption: GenericEvents always have count 1 */
> +
> +    if (GEV(original)->type == GenericEvent)
> +        len += GEV(original)->length * 4;
> +
> +    ev = xalloc(len);
> +    if (!ev)
> +        FatalError("[mi] No memory left for master event.\n");
> +    memcpy(ev, original, len);
> +    *master = ev;
> +
> +    while(count--)

Hi,
Would it be possible to do something like we do with GPE and friends
where you pessimistically allocate based on the maximum possible number
of events and only reallocate upwards when necessary? Having malloc() in
the event delivery path is a bit of a loss.

Cheers,
Daniel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 197 bytes
Desc: Digital signature
URL: <http://lists.x.org/archives/xorg/attachments/20081209/13d6f6d7/attachment.pgp>


More information about the xorg mailing list