[cairo-commit] cairo/src cairo-gstate.c,1.181,1.182
Carl Worth
commit at pdx.freedesktop.org
Mon Nov 7 10:02:08 PST 2005
Committed by: cworth
Update of /cvs/cairo/cairo/src
In directory gabe:/tmp/cvs-serv445/src
Modified Files:
cairo-gstate.c
Log Message:
2005-11-07 Carl Worth <cworth at cworth.org>
* src/cairo-gstate.c: (_cairo_gstate_create),
(_cairo_gstate_clone): Style fix: test-and-bail rather than making
the working body conditional.
* src/cairo-gstate.c: (_cairo_gstate_destroy): Allow destroy to
work on a NULL object.
Index: cairo-gstate.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo-gstate.c,v
retrieving revision 1.181
retrieving revision 1.182
diff -u -d -r1.181 -r1.182
--- cairo-gstate.c 7 Nov 2005 17:49:52 -0000 1.181
+++ cairo-gstate.c 7 Nov 2005 18:02:06 -0000 1.182
@@ -79,15 +79,16 @@
cairo_status_t status;
cairo_gstate_t *gstate;
+ assert (target != NULL);
+
gstate = malloc (sizeof (cairo_gstate_t));
+ if (gstate == NULL)
+ return NULL;
- if (gstate)
- {
- status = _cairo_gstate_init (gstate, target);
- if (status) {
- free (gstate);
- return NULL;
- }
+ status = _cairo_gstate_init (gstate, target);
+ if (status) {
+ free (gstate);
+ return NULL;
}
return gstate;
@@ -193,6 +194,9 @@
void
_cairo_gstate_destroy (cairo_gstate_t *gstate)
{
+ if (gstate == NULL)
+ return;
+
_cairo_gstate_fini (gstate);
free (gstate);
}
@@ -210,22 +214,24 @@
* memory.
**/
cairo_gstate_t*
-_cairo_gstate_clone (cairo_gstate_t *gstate)
+_cairo_gstate_clone (cairo_gstate_t *other)
{
cairo_status_t status;
- cairo_gstate_t *clone;
+ cairo_gstate_t *gstate;
- clone = malloc (sizeof (cairo_gstate_t));
- if (clone) {
- status = _cairo_gstate_init_copy (clone, gstate);
- if (status) {
- free (clone);
- return NULL;
- }
+ assert (other != NULL);
+
+ gstate = malloc (sizeof (cairo_gstate_t));
+ if (gstate == NULL)
+ return NULL;
+
+ status = _cairo_gstate_init_copy (gstate, other);
+ if (status) {
+ free (gstate);
+ return NULL;
}
- clone->next = NULL;
- return clone;
+ return gstate;
}
/* Push rendering off to an off-screen group. */
More information about the cairo-commit
mailing list