API Shakeup: user data (was Re: [cairo] Patch improving fallbacks)

Kristian Høgsberg krh at bitplanet.net
Tue Feb 15 14:20:16 PST 2005


Owen Taylor wrote:
> On Mon, 2005-01-31 at 18:09 -0500, Kristian Høgsberg wrote:
> 
> 
>>>My current thought for user data for surfaces is something pretty
>>>generic:
>>>
>>> cairo_key_t cairo_key_alloc (void);
>>
>>What about just using a void pointer as key?
>>
>>	static int pdf_backend_data_key;
>>
>>	cairo_surface_set_data (&pdf_backend_data_key,
>>				some_pdf_data,
>>				destroy_some_pdf_data);
> 
> 
> Not a bad idea. It doesn't make for very readable header file or
> code to  me, however. (I guess I'm calling the kettle black here
> on mysterious void * arguments.)

Ok, here's the patch.  Fairly self-explanatory, except from the gotcha 
that cairo_surface_set_data() can fail if the memory allocation fails.

cheers,
Kristian
-------------- next part --------------
A non-text attachment was scrubbed...
Name: user-data.patch
Type: text/x-patch
Size: 10283 bytes
Desc: not available
Url : http://lists.freedesktop.org/archives/cairo/attachments/20050215/b86dc4fe/user-data.bin


More information about the cairo mailing list