[cairo-commit]
cairo/src cairo_gstate.c, 1.84, 1.85 cairoint.h, 1.96, 1.97
Carl Worth
commit at pdx.freedesktop.org
Thu Feb 24 12:28:54 PST 2005
Committed by: cworth
Update of /cvs/cairo/cairo/src
In directory gabe:/tmp/cvs-serv23116/src
Modified Files:
cairo_gstate.c cairoint.h
Log Message:
Fixes from David Reveman with minor cleanups by Carl Worth:
* src/cairo_gstate.c (_cairo_gstate_create): Handle new failure
possibility of _cairo_gstate_init.
(_cairo_gstate_init): Handle possible failure of
_cairo_pattern_create_solid.
(_cairo_gstate_set_pattern): Reference new pattern before
destroying existing pattern to handle the case where they are the
same.
(_cairo_gstate_set_rgb_color): Handle possible failure of
_cairo_pattern_create_solid.
Index: cairo_gstate.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo_gstate.c,v
retrieving revision 1.84
retrieving revision 1.85
diff -u -d -r1.84 -r1.85
--- cairo_gstate.c 22 Feb 2005 19:35:03 -0000 1.84
+++ cairo_gstate.c 24 Feb 2005 20:28:51 -0000 1.85
@@ -55,17 +55,24 @@
cairo_gstate_t *
_cairo_gstate_create ()
{
+ cairo_status_t status;
cairo_gstate_t *gstate;
gstate = malloc (sizeof (cairo_gstate_t));
if (gstate)
- _cairo_gstate_init (gstate);
+ {
+ status = _cairo_gstate_init (gstate);
+ if (status) {
+ free (gstate);
+ return NULL;
+ }
+ }
return gstate;
}
-void
+cairo_status_t
_cairo_gstate_init (cairo_gstate_t *gstate)
{
gstate->operator = CAIRO_GSTATE_OPERATOR_DEFAULT;
@@ -95,6 +102,9 @@
gstate->clip.surface = NULL;
gstate->pattern = _cairo_pattern_create_solid (0.0, 0.0, 0.0);
+ if (!gstate->pattern)
+ return CAIRO_STATUS_NO_MEMORY;
+
gstate->alpha = 1.0;
gstate->pixels_per_inch = CAIRO_GSTATE_PIXELS_PER_INCH_DEFAULT;
@@ -105,6 +115,8 @@
_cairo_pen_init_empty (&gstate->pen_regular);
gstate->next = NULL;
+
+ return CAIRO_STATUS_SUCCESS;
}
cairo_status_t
@@ -392,11 +404,9 @@
if (pattern == NULL)
return CAIRO_STATUS_NULL_POINTER;
- if (gstate->pattern)
- cairo_pattern_destroy (gstate->pattern);
-
- gstate->pattern = pattern;
cairo_pattern_reference (pattern);
+ cairo_pattern_destroy (gstate->pattern);
+ gstate->pattern = pattern;
return CAIRO_STATUS_SUCCESS;
}
@@ -434,6 +444,8 @@
cairo_pattern_destroy (gstate->pattern);
gstate->pattern = _cairo_pattern_create_solid (red, green, blue);
+ if (!gstate->pattern)
+ return CAIRO_STATUS_NO_MEMORY;
return CAIRO_STATUS_SUCCESS;
}
Index: cairoint.h
===================================================================
RCS file: /cvs/cairo/cairo/src/cairoint.h,v
retrieving revision 1.96
retrieving revision 1.97
diff -u -d -r1.96 -r1.97
--- cairoint.h 24 Feb 2005 15:39:20 -0000 1.96
+++ cairoint.h 24 Feb 2005 20:28:51 -0000 1.97
@@ -926,7 +926,7 @@
cairo_private cairo_gstate_t *
_cairo_gstate_create (void);
-cairo_private void
+cairo_private cairo_status_t
_cairo_gstate_init (cairo_gstate_t *gstate);
cairo_private cairo_status_t
More information about the cairo-commit
mailing list