Re: Code Question

Chris Wilson <[email protected]>
Newsgroups gmane.comp.lib.cairo
Message-ID <[email protected]>
On Tue, Feb 19, 2013 at 10:28:22AM +0100, Edward Zimmermann wrote:
> 
> 
> #if !PIXMAN_HAS_COMPOSITOR
>  
> 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 <[email protected]>
Date:   Tue Feb 19 09:54:24 2013 +0000

    image: Compare against the true size of the embedded buffer

Thanks,
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre
-- 
cairo mailing list
[email protected]
http://lists.cairographics.org/mailman/listinfo/cairo
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.