[cairo] cairo_current_xxx, reference or not?

Carl Worth cworth at cworth.org
Thu Nov 4 11:14:51 PST 2004


On Thu, 4 Nov 2004 10:55:58 -0800, Ned Konz wrote:
> On Thursday 04 November 2004 9:52 am, David Reveman wrote:
> > With the recent font changes, cairo_current_font returns a cairo_font_t
> > object that needs to be destroyed. This is different from before and
> > different from what cairo_current_pattern and
> > cairo_current_target_surface are doing. If this is the intended
> > behavior, cairo_current_pattern and cairo_current_target_surface should
> > probably be modified to return a references instead of just pointers.
> > It's a bit confusing right now.

Yes, thanks for bringing this up. I'd been sitting on the cairo_matrix_t
thread for a couple of months, intending to bring up this same point
about unifying the semantics across the board. You know helped push me
into finally replying to that thread.

> I'd be in favor of having a simple rule: whenever there's a function that 
> *returns* a pointer to a managed (reference-counted) type, you *always* have 
> to destroy it.

Either always or never--there are arguments for both sides, and I don't know which side I come down on just yet.

But, yes, I do want a single, simple rule. A C API is just too hard to
use correctly otherwise.

-Carl



More information about the cairo mailing list