[cairo] [API] Export region data type

Kristian Høgsberg krh at bitplanet.net
Fri Feb 27 13:49:43 PST 2009


On Wed, Feb 25, 2009 at 3:57 PM, Behdad Esfahbod <behdad at behdad.org> wrote:
> Kristian Høgsberg wrote:
>> On Sat, Feb 21, 2009 at 9:44 AM, Soeren Sandmann <sandmann at daimi.au.dk> wrote:
>>> Hi,
>>>
>>> I'd like to propose exporting the region data type for 1.10. There is
>>> an implementation available in the public-region branch of this
>>> repository:
>> ...
>>>    typedef struct _cairo_rectangle_int {
>>>        int x, y;
>>>        unsigned int width, height;
>>>    } cairo_rectangle_int_t;
>>
>> If we end up exporting this, I'd suggest making width and height
>> signed ints to avoid overflow pitfalls such as
>
> With signed width/height you get overflows when doing:
>
>  rect->width = x2 - x1;

How so?  Getting a negative width is not an overflow situation.  It's
potentially unexepected, but certainly not worse than having x2=100
and x1=150 and then have width be 2^32 - 50.

Kristian


More information about the cairo mailing list