[cairo-commit] cairo/src cairo-gstate.c,1.185,1.186

Carl Worth commit at pdx.freedesktop.org
Mon Nov 7 10:50:42 PST 2005


Committed by: cworth

Update of /cvs/cairo/cairo/src
In directory gabe:/tmp/cvs-serv6279/src

Modified Files:
	cairo-gstate.c 
Log Message:

2005-11-07  Carl Worth  <cworth at cworth.org>

        * src/cairo-gstate.c: (_cairo_gstate_init_copy): Use
        field-by-field copying rather than whole structure copying. This
        avoids the hidden copies being overlooked in future code
        modifications.


Index: cairo-gstate.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo-gstate.c,v
retrieving revision 1.185
retrieving revision 1.186
diff -u -d -r1.185 -r1.186
--- cairo-gstate.c	7 Nov 2005 18:29:37 -0000	1.185
+++ cairo-gstate.c	7 Nov 2005 18:50:39 -0000	1.186
@@ -136,35 +136,45 @@
  * _cairo_gstate_init_copy:
  *
  * Initialize @gstate by performing a deep copy of state fields from
- * @other. Note that gstate->next is not copied but is left
- * unmodified, (yes, this behavior is bizarre.)
+ * @other. Note that gstate->next is not copied but is set to NULL by
+ * this function.
  **/
 static cairo_status_t
 _cairo_gstate_init_copy (cairo_gstate_t *gstate, cairo_gstate_t *other)
 {
     cairo_status_t status;
-    cairo_gstate_t *next;
     
-    /* Copy all members, but don't smash the next pointer */
-    next = gstate->next;
-    *gstate = *other;
-    gstate->next = next;
+    gstate->operator = other->operator;
+
+    gstate->tolerance = other->tolerance;
+    gstate->antialias = other->antialias;
 
     status = _cairo_stroke_style_init_copy (&gstate->stroke_style,
 					    &other->stroke_style);
     if (status)
 	return status;
 
-    gstate->font_face = cairo_font_face_reference (other->font_face);
+    gstate->fill_rule = other->fill_rule;
 
+    gstate->font_face = cairo_font_face_reference (other->font_face);
     gstate->scaled_font = cairo_scaled_font_reference (other->scaled_font);
 
+    gstate->font_matrix = other->font_matrix;
+
+    _cairo_font_options_init_copy (&gstate->font_options , &other->font_options);
+
     _cairo_clip_init_copy (&gstate->clip, &other->clip);
 
     gstate->target = cairo_surface_reference (other->target);
 
+    gstate->ctm = other->ctm;
+    gstate->ctm_inverse = other->ctm_inverse;
+    gstate->source_ctm_inverse = other->source_ctm_inverse;
+
     gstate->source = cairo_pattern_reference (other->source);
-    
+
+    gstate->next = NULL;
+
     return CAIRO_STATUS_SUCCESS;
 }
 



More information about the cairo-commit mailing list