[cairo] [API] Export region data type
Behdad Esfahbod
behdad at behdad.org
Sat Feb 28 06:55:29 PST 2009
Kristian Høgsberg wrote:
> 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.
What's a negative width good for? It doesn't mean anything. It's undefined.
It's a hassle to handle (you have to check for width >= 0 all over the code).
The 2^32 - 50 on the other hand will be automatically detected and handled by
whatever check you already have in place for handling large sizes.
behdad
> Kristian
>
More information about the cairo
mailing list