[cairo] API Shakeup: cairo_current_path -> cairo_copy_path_data

Carl Worth cworth at cworth.org
Fri Mar 11 14:41:00 PST 2005


On Tue, 22 Feb 2005 17:47:00 -0500, wrote:
> Quoting Carl Worth <cworth at cworth.org>:
> > 	   Caller is responsible for the returned memory and should
> > 	   free() it when finished.
> 
> Hmm.  I think it might be worth abstracting the free() -- i.e. have
> a void cairo_free_path_data(cairo_t *cr, cairo_path_data_t *data)
> or similar, so the door isn't totally closed on using an allocator
> other than raw malloc().

I'm still not sure what to do here. 

I just committed a version that requires free(), and it was a bit
annoying that I had to add "#include <stdlib.h>" to my test case just
to properly use cairo_copy_path_data, (though that's probably not a
big deal).

But there are some problems if we add a new function here.

First, the convention would be to name it something like:

	cairo_path_data_destroy (cairo_path_data_t *data);

but then we'd have an unconventional "destroy" function with no
matching "create", (nor "reference").

Second, the cairo_copy_path_data function returns an array, so we open
the possibility for the user to call the "destroy" function with
something besides the address of the first element. There are no other
allocated array objecte in cairo so far, so there would be nothing to
indicate to the user that this destroy function must only be called on
the first element. Meanwhile, the semantics of free are well-enough
understood to not suffer from this problem.

-Carl

 LocalWords:  objecte
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.freedesktop.org/archives/cairo/attachments/20050311/6ef9a39f/attachment.pgp


More information about the cairo mailing list