[cairo] API Shakeup: cairo_current_path -> cairo_copy_path_data

Hans Breuer hans at breuer.org
Sat Mar 12 00:53:16 PST 2005


On 12.03.2005 03:49, Carl Worth wrote:
> On Tue, 22 Feb 2005 17:47:00 -0500, mental wrote:
> 
>>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().
> 
> 
> Thinking about this a bit more, I don't think we're really closing any
> doors here. The cairo_copy_path_data call is copying data out of cairo
> and into the application, so the details of memory management should
> be on the application's terms.
> 
Not looking at the code but isn't it allocating path data and not
just copying? Anyway to me it looks like a bad API which opens the
door for mixing allocation and deallocation from different domains
(and it's one thing I often needed to put quite some effort in
while porting an application).
> Either way, I don't see a compelling need to add any abstraction here.
> 
> Or is there some other case I'm missing?
> 
What about something like debug instrumentation? With msvc it is
quite common to create a debug build of your application (using the
instrumented debug runtime version) but *not* from all DLLs your
application depends on. And the same issue applies to *NIX debug
library usage like Dmalloc, efence.

In this scenario Cairo malloc()s some memory which would not be
instrumented - and the applications call to free(pathdata) would
use the instrumented version.
This will at least cause a failure in the instrumented free()
(looks like freeing unowned data to the instrumeneted version).

To some extent the same issue applies to other C-runtime objects
like FILE*, file destricptors (as long as they are emulated by
the runtime and are not real System resources).

So I'd rather like to avoid this pattern altogether.

	Hans

-------- Hans "at" Breuer "dot" Org -----------
Tell me what you need, and I'll tell you how to
get along without it.                -- Dilbert



More information about the cairo mailing list