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

Kristian Høgsberg krh at bitplanet.net
Tue Feb 1 07:50:08 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.)
> 
> What if we did something like:
> 
>  typedef struct {
>     int dummy;
>  } cairo_key_t;
> 
>  void cairo_surface_set_data (const cairo_key_t   *key, 
>                               void                *data,
>                               cairo_destroy_func_t destroy);

That's much better.

cheers,
Kristian



More information about the cairo mailing list