[cairo-commit] cairo/src cairo-array.c, 1.9, 1.10 cairo-meta-surface.c, 1.21, 1.22 cairo-win32-font.c, 1.45, 1.46 cairoint.h, 1.237, 1.238 test-meta-surface.h, 1.1, 1.2

Carl Worth commit at pdx.freedesktop.org
Wed Dec 21 12:08:59 PST 2005


Committed by: cworth

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

Modified Files:
	cairo-array.c cairo-meta-surface.c cairo-win32-font.c 
	cairoint.h test-meta-surface.h 
Log Message:

2005-12-21  Carl Worth  <cworth at cworth.org>

        * src/test-meta-surface.h: Fix indentation.


Index: cairo-array.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo-array.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- cairo-array.c	7 Dec 2005 20:19:10 -0000	1.9
+++ cairo-array.c	21 Dec 2005 20:08:57 -0000	1.10
@@ -96,7 +96,10 @@
     if (array->is_snapshot)
 	return;
 
-    free (array->elements);
+    if (array->elements) {
+	free (* array->elements);
+	free (array->elements);
+    }
 }
 
 /**
@@ -127,8 +130,15 @@
     while (new_size < required_size)
 	new_size = new_size * 2;
 
+    if (array->elements == NULL) {
+	array->elements = malloc (sizeof (char *));
+	if (array->elements == NULL)
+	    return CAIRO_STATUS_NO_MEMORY;
+	*array->elements = NULL;
+    }
+
     array->size = new_size;
-    new_elements = realloc (array->elements,
+    new_elements = realloc (*array->elements,
 			    array->size * array->element_size);
 
     if (new_elements == NULL) {
@@ -136,7 +146,7 @@
 	return CAIRO_STATUS_NO_MEMORY;
     }
 
-    array->elements = new_elements;
+    *array->elements = new_elements;
 
     return CAIRO_STATUS_SUCCESS;
 }
@@ -181,7 +191,7 @@
 {
     assert (0 <= index && index < array->num_elements);
 
-    return (void *) &array->elements[index * array->element_size];
+    return (void *) &(*array->elements)[index * array->element_size];
 }
 
 /**
@@ -276,7 +286,7 @@
 
     assert (array->num_elements + num_elements <= array->size);
 
-    *elements = &array->elements[array->num_elements * array->element_size];
+    *elements = &(*array->elements)[array->num_elements * array->element_size];
 
     array->num_elements += num_elements;
 
@@ -331,7 +341,10 @@
     cairo_user_data_slot_t *slots;
 
     num_slots = array->num_elements;
-    slots = (cairo_user_data_slot_t *) array->elements;
+    if (num_slots == 0)
+	return;
+
+    slots = (cairo_user_data_slot_t *) (*array->elements);
     for (i = 0; i < num_slots; i++) {
 	if (slots[i].user_data != NULL && slots[i].destroy != NULL)
 	    slots[i].destroy (slots[i].user_data);
@@ -365,7 +378,10 @@
 	return NULL;
 
     num_slots = array->num_elements;
-    slots = (cairo_user_data_slot_t *) array->elements;
+    if (num_slots == 0)
+	return NULL;
+
+    slots = (cairo_user_data_slot_t *) (*array->elements);
     for (i = 0; i < num_slots; i++) {
 	if (slots[i].key == key)
 	    return slots[i].user_data;
@@ -412,16 +428,19 @@
 
     slot = NULL;
     num_slots = array->num_elements;
-    slots = (cairo_user_data_slot_t *) array->elements;
-    for (i = 0; i < num_slots; i++) {
-	if (slots[i].key == key) {
-	    slot = &slots[i];
-	    if (slot->destroy && slot->user_data)
-		slot->destroy (slot->user_data);
-	    break;
-	}
-	if (user_data && slots[i].user_data == NULL) {
-	    slot = &slots[i];	/* Have to keep searching for an exact match */
+
+    if (num_slots) {
+	slots = (cairo_user_data_slot_t *) (*array->elements);
+	for (i = 0; i < num_slots; i++) {
+	    if (slots[i].key == key) {
+		slot = &slots[i];
+		if (slot->destroy && slot->user_data)
+		    slot->destroy (slot->user_data);
+		break;
+	    }
+	    if (user_data && slots[i].user_data == NULL) {
+		slot = &slots[i];	/* Have to keep searching for an exact match */
+	    }
 	}
     }
 

Index: cairo-meta-surface.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo-meta-surface.c,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- cairo-meta-surface.c	20 Dec 2005 18:30:11 -0000	1.21
+++ cairo-meta-surface.c	21 Dec 2005 20:08:57 -0000	1.22
@@ -104,7 +104,10 @@
     }
 
     num_elements = meta->commands.num_elements;
-    elements = (cairo_command_t **) meta->commands.elements;
+    if (num_elements == 0)
+	return CAIRO_STATUS_SUCCESS;
+
+    elements = (cairo_command_t **) *meta->commands.elements;
     for (i = 0; i < num_elements; i++) {
 	command = elements[i];
 	switch (command->type) {
@@ -596,16 +599,18 @@
     cairo_meta_surface_t *meta;
     cairo_command_t *command, **elements;
     int i, num_elements;
-    cairo_int_status_t status;
+    cairo_int_status_t status = CAIRO_STATUS_SUCCESS;
     cairo_clip_t clip;
 
     meta = (cairo_meta_surface_t *) surface;
-    status = CAIRO_STATUS_SUCCESS;
+
+    num_elements = meta->commands.num_elements;
+    if (num_elements == 0)
+	return CAIRO_STATUS_SUCCESS;
 
     _cairo_clip_init (&clip, target);    
 
-    num_elements = meta->commands.num_elements;
-    elements = (cairo_command_t **) meta->commands.elements;
+    elements = (cairo_command_t **) *meta->commands.elements;
     for (i = 0; i < num_elements; i++) {
 	command = elements[i];
 	switch (command->type) {

Index: cairo-win32-font.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo-win32-font.c,v
retrieving revision 1.45
retrieving revision 1.46
diff -u -d -r1.45 -r1.46
--- cairo-win32-font.c	16 Dec 2005 11:02:35 -0000	1.45
+++ cairo-win32-font.c	21 Dec 2005 20:08:57 -0000	1.46
@@ -898,14 +898,16 @@
     if (status)
 	return status;
     
-    if (!ExtTextOutW (state->hdc,
-		      state->start_x, state->last_y,
-		      ETO_GLYPH_INDEX,
-		      NULL,
-		      (WCHAR *)state->glyphs.elements,
-		      state->glyphs.num_elements,
-		      (int *)state->dx.elements)) {
-	return _cairo_win32_print_gdi_error ("_flush_glyphs");
+    if (state->glyphs.elements) {
+	if (!ExtTextOutW (state->hdc,
+			  state->start_x, state->last_y,
+			  ETO_GLYPH_INDEX,
+			  NULL,
+			  (WCHAR *)*state->glyphs.elements,
+			  state->glyphs.num_elements,
+			  (int *)state->dx.elements)) {
+	    return _cairo_win32_print_gdi_error ("_flush_glyphs");
+	}
     }
     
     _cairo_array_truncate (&state->glyphs, 0);

Index: cairoint.h
===================================================================
RCS file: /cvs/cairo/cairo/src/cairoint.h,v
retrieving revision 1.237
retrieving revision 1.238
diff -u -d -r1.237 -r1.238
--- cairoint.h	21 Dec 2005 16:19:47 -0000	1.237
+++ cairoint.h	21 Dec 2005 20:08:57 -0000	1.238
@@ -334,7 +334,7 @@
     int size;
     int num_elements;
     int element_size;
-    char *elements;
+    char **elements;
 
     cairo_bool_t is_snapshot;
 };

Index: test-meta-surface.h
===================================================================
RCS file: /cvs/cairo/cairo/src/test-meta-surface.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- test-meta-surface.h	20 Dec 2005 18:30:12 -0000	1.1
+++ test-meta-surface.h	21 Dec 2005 20:08:57 -0000	1.2
@@ -42,8 +42,8 @@
 
 cairo_surface_t *
 _test_meta_surface_create (cairo_format_t	format,
-			       int		width,
-			       int		height);
+			   int			width,
+			   int			height);
 
 CAIRO_END_DECLS
 



More information about the cairo-commit mailing list