[cairo] Make *_reference() functions return referenced object

Kristian Høgsberg krh at bitplanet.net
Thu Aug 4 15:45:31 PDT 2005


Hi,

Some time ago it was suggested that we make the various *_reference() 
function return the object whose reference count they increase.  It's a 
nice convenience and make the code easier to read in many cases. 
Typical uses include

	return cairo_surface_reference (surface);

and

	ctx->current_pattern = cairo_pattern_reference (pattern);

This was never actually implemented,  but the attached patch does that. 
  We are currently API stable, meaning that we don't change existing 
API, but adding these return values is a backwards compatible change. 
The part of the public API that's affected is:

	cairo_t *
	cairo_reference (cairo_t *cr);

	cairo_font_face_t *
	cairo_font_face_reference (cairo_font_face_t *font_face);

	cairo_scaled_font_t *
	cairo_scaled_font_reference (cairo_scaled_font_t *scaled_font);

	cairo_surface_t *
	cairo_surface_reference (cairo_surface_t *surface);

	cairo_pattern_t *
	cairo_pattern_reference (cairo_pattern_t *pattern);

Referencing a NULL object will return NULL and referencing an error 
object will return that error object unchanged.

cheers,
Kristian
-------------- next part --------------
A non-text attachment was scrubbed...
Name: reference-return.patch
Type: text/x-diff
Size: 14194 bytes
Desc: not available
Url : http://lists.freedesktop.org/archives/cairo/attachments/20050804/6fae1668/reference-return.bin


More information about the cairo mailing list