API Shakeup: user data (was Re: [cairo] Patch improving fallbacks)
Kristian Høgsberg
krh at bitplanet.net
Tue Feb 15 14:40:07 PST 2005
Kristian Høgsberg wrote:
> 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.
Argh, I guess I should have reviewed that one a bit more closely before
sending it out. Here a second try that doesn't remove the call to
backend->destroy and has a full ChangeLog entry.
Kristian
-------------- next part --------------
A non-text attachment was scrubbed...
Name: user-data.patch
Type: text/x-patch
Size: 10276 bytes
Desc: not available
Url : http://lists.freedesktop.org/archives/cairo/attachments/20050215/78970904/user-data.bin
More information about the cairo
mailing list