[cairo-pattern] Return the nil cairo_pattern_t for CAIRO_STATUS_NO_MEMORY.

If we asked to create a pattern after encountering an allocation failure,
we can avoid another allocation by returning the nil pattern object.
This commit is contained in:
Chris Wilson 2007-05-10 19:24:54 +01:00
parent e8e5f93ffe
commit ebababc0cf

View file

@ -338,6 +338,9 @@ _cairo_pattern_create_in_error (cairo_status_t status)
{
cairo_pattern_t *pattern;
if (status == CAIRO_STATUS_NO_MEMORY)
return (cairo_pattern_t *)&_cairo_pattern_nil.base;
pattern = _cairo_pattern_create_solid (_cairo_stock_color (CAIRO_STOCK_BLACK),
CAIRO_CONTENT_COLOR);
/* no-op on a pattern already in error i.e the _cairo_pattern_nil */