[cairo] Code Question

Chris Wilson chris at chris-wilson.co.uk
Tue Feb 19 01:57:02 PST 2013

On Tue, Feb 19, 2013 at 10:28:22AM +0100, Edward Zimmermann wrote:
> line 2996 of cairo-image-compositor.c has
>   if (r->u.mask.extents.height * r->u.mask.stride > (int)sizeof (r->_buf))
> where in struct _cairo_image_span_renderer  we have
> line  1550:     uint8_t _buf[0];
> the above is a pointer that is not allocated.  It’s a zero length array.   The
> behavior is implementation specific and that includes throwing an error but
> this typically leads to the compiler seeing  sizeof (r->_buf)) as zero. GCC and
> Microsoft Studio accepts it. C90 hates it. C99 provides flexible array member.
> If its intended to be as written, zero length, then why the comparison? Any
> compilers accept zero length arrays and return another value.

I had forgotten that _buf was a variable length array and already had a
macro (SZ_BUF) to determine the size properly.

Pushed commit e7e1ac235ff94d184d88c8c206b81343822f6a4e
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Tue Feb 19 09:54:24 2013 +0000

    image: Compare against the true size of the embedded buffer


Chris Wilson, Intel Open Source Technology Centre

More information about the cairo mailing list