[cairo] cairo_current_xxx, reference or not?
Ned Konz
ned at squeakland.org
Thu Nov 4 10:55:58 PST 2004
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.
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.
So cairo_current_target_surface() and cairo_current_pattern() should both
increment the reference count of their return values, as cairo_current_font()
does.
That way, there's never a question about ownership, and it's easier to do
bindings (I know, it's a selfish reason). Also it prevents memory leaks or
premature freeing in cases where the internal structure is replaced by
another.
--
Ned Konz
http://bike-nomad.com/squeak/
More information about the cairo
mailing list