[cairo] API Shakeup:
cairo_begin_group, cairo_end_group, cairo_get_group
otaylor at redhat.com
Thu Jul 7 16:08:21 PDT 2005
On Thu, 2005-07-07 at 14:59 -0700, Carl Worth wrote:
> > + /* XXX: If we switch to never returning a NULL surface, (like we
> > + * do for cairo_t and cairo_pattern_t), then we'd have the
> > + * advantage here of actually being able to indicate to the caller
> > + * what the error is here, rather than just returning a vague
> > + * NULL. */
> > +
> > + /* Check that the content value is valid. */
> > + if (content == 0 || content & ~(CAIRO_CONTENT_COLOR |
> > CAIRO_CONTENT_ALPHA))
> > + return NULL;
> > ===
> > I don't think it's ever interesting for a program to check "if I passed
> > a junk cairo_content_t, then I should...".
> No, of course that wouldn't be useful. The point of my comment is that
> the NULL pointer is going to cause a crash down the road somewhere and
> at that point there won't be information available to the poor
> person doing the debugging as to _why_ the pointer is NULL.
But finding down the road somewhere that you have a cairo_t with
CAIRO_STATUS_INVALID_VALUE isn't going to help you track things down
very much :-)
> What is needed here (and
> > elsewhere) is simply debug spew.
> I likely do need to overcome my feeling that library code should never
My tenet in this area is:
A library should never print unless the caller violates the contract
about how the functions should behave. Once the caller has violated
their side of the contract, all bets are off... the library could
start calculating digits of pi. However, of all possible undefined
behaviors, debug spew is by far the most useful.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://lists.freedesktop.org/archives/cairo/attachments/20050707/ae657083/attachment.pgp
More information about the cairo