[cairo] API completeness of reference/user_data pairs

Behdad Esfahbod behdad at behdad.org
Mon Jan 29 13:13:53 PST 2007


I wanted to propose new API for cairo_font_options_reference().
I reported this in bugzilla somewhere, but can't find it.
In short, I think the required malloc for an opaque value type is
unnecessary overhead.

But when I thought about it, I remembered that to make life
easier for language bindings, all referenced types need to have
destroy notification for the least, and user data preferably.  In
cairo, both are available using the user_data idiom.

However, it seems like from the five referenced types in cairo:

$ grep '^cairo.*_reference' cairo.h
cairo_reference (cairo_t *cr);
cairo_font_face_reference (cairo_font_face_t *font_face);
cairo_scaled_font_reference (cairo_scaled_font_t *scaled_font);
cairo_surface_reference (cairo_surface_t *surface);
cairo_pattern_reference (cairo_pattern_t *pattern);

Only two have user_data:

$ grep '^cairo.*_set_user_data' cairo.h
cairo_font_face_set_user_data (cairo_font_face_t *font_face,
cairo_surface_set_user_data (cairo_surface_t *surface,

Is there any reason that the other three don't have user_data?
How do language bindings deal with this currently?

-- 
behdad
http://behdad.org/

"Those who would give up Essential Liberty to purchase a little
 Temporary Safety, deserve neither Liberty nor Safety."
        -- Benjamin Franklin, 1759





More information about the cairo mailing list