summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2007-10-04 13:15:46 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2007-10-04 13:31:44 +0100
commitbed8239f03773ad1584c8ba48ceb0b34bbe69453 (patch)
treefb97a0cd4874f4fd4a2b22d6ec882a77f04202da
parentd90d4bb6b99e0a912650234e28d097ea76c1cecc (diff)
[cairo-error] Clean up all the warnings and missing _cairo_error() calls.
Every time we assign or return a hard-coded error status wrap that value with a call to _cairo_error(). So the idiom becomes: status = _cairo_error (CAIRO_STATUS_NO_MEMORY); or return _cairo_error (CAIRO_STATUS_INVALID_DASH); This ensures that a breakpoint placed on _cairo_error() will trigger immediately cairo detects the error.
-rw-r--r--src/cairo-analysis-surface.c4
-rw-r--r--src/cairo-array.c9
-rw-r--r--src/cairo-atsui-font.c18
-rw-r--r--src/cairo-base85-stream.c2
-rw-r--r--src/cairo-bentley-ottmann.c22
-rw-r--r--src/cairo-cache.c4
-rw-r--r--src/cairo-cff-subset.c122
-rw-r--r--src/cairo-clip.c18
-rw-r--r--src/cairo-deflate-stream.c2
-rw-r--r--src/cairo-directfb-surface.c49
-rw-r--r--src/cairo-font-face.c6
-rw-r--r--src/cairo-font-options.c4
-rw-r--r--src/cairo-ft-font.c111
-rw-r--r--src/cairo-glitz-surface.c89
-rw-r--r--src/cairo-gstate.c37
-rw-r--r--src/cairo-hash.c10
-rw-r--r--src/cairo-hull.c2
-rw-r--r--src/cairo-image-surface.c47
-rw-r--r--src/cairo-lzw.c6
-rw-r--r--src/cairo-matrix.c4
-rw-r--r--src/cairo-meta-surface.c48
-rw-r--r--src/cairo-os2-surface.c24
-rw-r--r--src/cairo-output-stream.c18
-rw-r--r--src/cairo-paginated-surface.c8
-rw-r--r--src/cairo-path-fixed.c14
-rw-r--r--src/cairo-path-stroke.c6
-rw-r--r--src/cairo-path.c16
-rw-r--r--src/cairo-pattern.c65
-rw-r--r--src/cairo-pdf-surface.c62
-rw-r--r--src/cairo-pen.c19
-rw-r--r--src/cairo-png.c24
-rw-r--r--src/cairo-polygon.c6
-rw-r--r--src/cairo-ps-surface.c63
-rw-r--r--src/cairo-quartz-surface.c15
-rw-r--r--src/cairo-region.c22
-rw-r--r--src/cairo-scaled-font-subsets.c20
-rw-r--r--src/cairo-scaled-font.c16
-rw-r--r--src/cairo-skiplist.c2
-rw-r--r--src/cairo-spline.c6
-rw-r--r--src/cairo-stroke-style.c6
-rw-r--r--src/cairo-surface-fallback.c10
-rw-r--r--src/cairo-surface.c82
-rw-r--r--src/cairo-svg-surface.c24
-rw-r--r--src/cairo-traps.c9
-rw-r--r--src/cairo-truetype-subset.c43
-rw-r--r--src/cairo-type1-fallback.c27
-rw-r--r--src/cairo-type1-subset.c30
-rw-r--r--src/cairo-unicode.c20
-rw-r--r--src/cairo-win32-font.c40
-rw-r--r--src/cairo-win32-surface.c23
-rw-r--r--src/cairo-xcb-surface.c50
-rw-r--r--src/cairo-xlib-display.c2
-rw-r--r--src/cairo-xlib-surface.c88
-rw-r--r--src/cairo.c8
-rw-r--r--src/cairoint.h8
-rw-r--r--src/test-fallback-surface.c2
-rw-r--r--src/test-meta-surface.c6
-rw-r--r--src/test-paginated-surface.c6
58 files changed, 648 insertions, 856 deletions
diff --git a/src/cairo-analysis-surface.c b/src/cairo-analysis-surface.c
index 067543f3..97b245e4 100644
--- a/src/cairo-analysis-surface.c
+++ b/src/cairo-analysis-surface.c
@@ -76,7 +76,7 @@ _cairo_analysis_surface_analyze_meta_surface_pattern (cairo_analysis_surface_t *
analysis = _cairo_analysis_surface_create (surface->target,
surface->width, surface->height);
if (analysis == NULL)
- return CAIRO_STATUS_NO_MEMORY;
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
status = _cairo_meta_surface_replay_analyze_meta_pattern (meta_surface, analysis);
if (status == CAIRO_STATUS_SUCCESS)
@@ -592,7 +592,7 @@ _cairo_analysis_surface_create (cairo_surface_t *target,
return &surface->base;
FAIL:
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
+ _cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
return NULL;
}
diff --git a/src/cairo-array.c b/src/cairo-array.c
index 58c699e0..0313caa9 100644
--- a/src/cairo-array.c
+++ b/src/cairo-array.c
@@ -132,10 +132,8 @@ _cairo_array_grow_by (cairo_array_t *array, int additional)
if (array->elements == NULL) {
array->elements = malloc (sizeof (char *));
- if (array->elements == NULL) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
- return CAIRO_STATUS_NO_MEMORY;
- }
+ if (array->elements == NULL)
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
*array->elements = NULL;
}
@@ -146,8 +144,7 @@ _cairo_array_grow_by (cairo_array_t *array, int additional)
if (new_elements == NULL) {
array->size = old_size;
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
- return CAIRO_STATUS_NO_MEMORY;
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
}
*array->elements = new_elements;
diff --git a/src/cairo-atsui-font.c b/src/cairo-atsui-font.c
index ab567c6b..b6771853 100644
--- a/src/cairo-atsui-font.c
+++ b/src/cairo-atsui-font.c
@@ -213,7 +213,7 @@ _cairo_atsui_font_set_metrics (cairo_atsui_font_t *font)
}
}
- return CAIRO_STATUS_NULL_POINTER;
+ return _cairo_error (CAIRO_STATUS_NULL_POINTER);
}
static cairo_status_t
@@ -233,7 +233,7 @@ _cairo_atsui_font_create_scaled (cairo_font_face_t *font_face,
font = malloc(sizeof(cairo_atsui_font_t));
if (font == NULL)
- return CAIRO_STATUS_NO_MEMORY;
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
status = _cairo_scaled_font_init (&font->base,
font_face, font_matrix, ctm, options,
@@ -263,7 +263,7 @@ _cairo_atsui_font_create_scaled (cairo_font_face_t *font_face,
sizeof(ATSUAttributeTag), theFontStyleTags,
theFontStyleSizes, theFontStyleValues);
if (err != noErr) {
- status = CAIRO_STATUS_NO_MEMORY;
+ status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto FAIL;
}
}
@@ -436,7 +436,7 @@ _cairo_atsui_font_init_glyph_metrics (cairo_atsui_font_t *scaled_font,
1, &theGlyph, 0, false,
false, &metricsH);
if (err != noErr)
- return CAIRO_STATUS_NO_MEMORY;
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
/* Scale down to font units.*/
_cairo_matrix_compute_scale_factors (&scaled_font->base.scale,
@@ -550,7 +550,7 @@ _cairo_atsui_scaled_font_init_glyph_path (cairo_atsui_font_t *scaled_font,
scaled_path.path = _cairo_path_fixed_create ();
if (!scaled_path.path)
- return CAIRO_STATUS_NO_MEMORY;
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
if (theGlyph == kATSDeletedGlyphcode) {
_cairo_scaled_glyph_set_path (scaled_glyph, &scaled_font->base,
@@ -703,7 +703,7 @@ _cairo_atsui_scaled_font_init_glyph_surface (cairo_atsui_font_t *scaled_font,
if (!drawingContext) {
cairo_surface_destroy ((cairo_surface_t *)surface);
- return CAIRO_STATUS_NO_MEMORY;
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
}
atsFont = FMGetATSFontRefFromFont (scaled_font->fontID);
@@ -810,10 +810,8 @@ _cairo_atsui_font_text_to_glyphs (void *abstract_font,
*num_glyphs = glyphCount - 1;
*glyphs =
(cairo_glyph_t *) _cairo_malloc_ab(*num_glyphs, sizeof (cairo_glyph_t));
- if (*glyphs == NULL) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
- return CAIRO_STATUS_NO_MEMORY;
- }
+ if (*glyphs == NULL)
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
_cairo_matrix_compute_scale_factors (&font->base.ctm, &xscale, &yscale, 1);
device_to_user_scale =
diff --git a/src/cairo-base85-stream.c b/src/cairo-base85-stream.c
index bfde0cfe..97ef2635 100644
--- a/src/cairo-base85-stream.c
+++ b/src/cairo-base85-stream.c
@@ -115,7 +115,7 @@ _cairo_base85_stream_create (cairo_output_stream_t *output)
stream = malloc (sizeof (cairo_base85_stream_t));
if (stream == NULL) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
+ _cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
return (cairo_output_stream_t *) &_cairo_output_stream_nil;
}
diff --git a/src/cairo-bentley-ottmann.c b/src/cairo-bentley-ottmann.c
index 679b532b..b8a5f813 100644
--- a/src/cairo-bentley-ottmann.c
+++ b/src/cairo-bentley-ottmann.c
@@ -701,7 +701,7 @@ _cairo_bo_event_queue_insert (cairo_bo_event_queue_t *queue,
/* Don't insert if there's already an equivalent intersection event in the queue. */
if (_cairo_skip_list_insert (&queue->intersection_queue, event,
event->type == CAIRO_BO_EVENT_TYPE_INTERSECTION) == NULL)
- status = CAIRO_STATUS_NO_MEMORY;
+ status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
return status;
}
@@ -755,10 +755,8 @@ _cairo_bo_event_queue_init (cairo_bo_event_queue_t *event_queue,
* event type a union so it doesn't always contain the skip
* elt? */
events = _cairo_malloc_ab (num_events, sizeof (cairo_bo_event_t) + sizeof(cairo_bo_event_t*));
- if (events == NULL) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
- return CAIRO_STATUS_NO_MEMORY;
- }
+ if (events == NULL)
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
sorted_event_ptrs = (cairo_bo_event_t **) (events + num_events);
event_queue->startstop_events = events;
@@ -861,7 +859,7 @@ _cairo_bo_sweep_line_insert (cairo_bo_sweep_line_t *sweep_line,
sweep_line_elt = _cairo_skip_list_insert (&sweep_line->active_edges, &edge,
1 /* unique inserts*/);
if (sweep_line_elt == NULL)
- return CAIRO_STATUS_NO_MEMORY;
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
next_elt = sweep_line_elt->elt.next[0];
if (next_elt)
@@ -1148,10 +1146,8 @@ _cairo_bo_edge_start_or_continue_trap (cairo_bo_edge_t *edge,
if (edge->next) {
trap = edge->deferred_trap = _cairo_freelist_alloc (&bo_traps->freelist);
- if (!edge->deferred_trap) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
- return CAIRO_STATUS_NO_MEMORY;
- }
+ if (!edge->deferred_trap)
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
trap->right = edge->next;
trap->top = top;
@@ -1441,10 +1437,8 @@ _cairo_bentley_ottmann_tessellate_polygon (cairo_traps_t *traps,
edges = stack_edges;
} else {
edges = _cairo_malloc_ab (polygon->num_edges, sizeof (cairo_bo_edge_t));
- if (edges == NULL) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
- return CAIRO_STATUS_NO_MEMORY;
- }
+ if (edges == NULL)
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
}
/* Figure out the bounding box of the input coordinates and
diff --git a/src/cairo-cache.c b/src/cairo-cache.c
index a7c27c12..9bb4de59 100644
--- a/src/cairo-cache.c
+++ b/src/cairo-cache.c
@@ -54,7 +54,7 @@ _cairo_cache_init (cairo_cache_t *cache,
{
cache->hash_table = _cairo_hash_table_create (keys_equal);
if (cache->hash_table == NULL)
- return CAIRO_STATUS_NO_MEMORY;
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
cache->entry_destroy = entry_destroy;
@@ -132,7 +132,7 @@ _cairo_cache_create (cairo_cache_keys_equal_func_t keys_equal,
cache = malloc (sizeof (cairo_cache_t));
if (cache == NULL) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
+ status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
return NULL;
}
diff --git a/src/cairo-cff-subset.c b/src/cairo-cff-subset.c
index aac13780..7bc7cb9c 100644
--- a/src/cairo-cff-subset.c
+++ b/src/cairo-cff-subset.c
@@ -389,10 +389,8 @@ cff_index_append_copy (cairo_array_t *index,
element.length = length;
element.is_copy = TRUE;
element.data = malloc (element.length);
- if (element.data == NULL) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
- return CAIRO_STATUS_NO_MEMORY;
- }
+ if (element.data == NULL)
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
memcpy (element.data, object, element.length);
@@ -444,7 +442,7 @@ cff_dict_create_operator (int operator,
op = malloc (sizeof (cff_dict_operator_t));
if (op == NULL) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
+ _cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
return NULL;
}
@@ -452,7 +450,7 @@ cff_dict_create_operator (int operator,
op->operand = malloc (operand_length);
if (op->operand == NULL) {
free (op);
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
+ _cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
return NULL;
}
memcpy (op->operand, operand, operand_length);
@@ -487,7 +485,7 @@ cff_dict_read (cairo_hash_table_t *dict, unsigned char *p, int dict_size)
_cairo_array_index (&operands, 0),
_cairo_array_num_elements (&operands));
if (op == NULL) {
- status = CAIRO_STATUS_NO_MEMORY;
+ status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto fail;
}
status = _cairo_hash_table_insert (dict, &op->base);
@@ -551,10 +549,8 @@ cff_dict_set_operands (cairo_hash_table_t *dict,
{
free (op->operand);
op->operand = malloc (size);
- if (op->operand == NULL) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
- return CAIRO_STATUS_NO_MEMORY;
- }
+ if (op->operand == NULL)
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
memcpy (op->operand, operand, size);
op->operand_length = size;
@@ -562,10 +558,8 @@ cff_dict_set_operands (cairo_hash_table_t *dict,
else
{
op = cff_dict_create_operator (operator, operand, size);
- if (op == NULL) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
- return CAIRO_STATUS_NO_MEMORY;
- }
+ if (op == NULL)
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
status = _cairo_hash_table_insert (dict, &op->base);
if (status)
@@ -731,10 +725,8 @@ cairo_cff_font_read_fdselect (cairo_cff_font_t *font, unsigned char *p)
int type, num_ranges, first, last, fd, i, j;
font->fdselect = calloc (font->num_glyphs, sizeof (int));
- if (font->fdselect == NULL) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
- return CAIRO_STATUS_NO_MEMORY;
- }
+ if (font->fdselect == NULL)
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
type = *p++;
if (type == 0)
@@ -782,26 +774,26 @@ cairo_cff_font_read_cid_fontdict (cairo_cff_font_t *font, unsigned char *ptr)
font->fd_dict = calloc (sizeof (cairo_hash_table_t *), font->num_fontdicts);
if (font->fd_dict == NULL) {
- status = CAIRO_STATUS_NO_MEMORY;
+ status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto fail;
}
font->fd_private_dict = calloc (sizeof (cairo_hash_table_t *), font->num_fontdicts);
if (font->fd_private_dict == NULL) {
- status = CAIRO_STATUS_NO_MEMORY;
+ status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto fail;
}
font->fd_local_sub_index = calloc (sizeof (cairo_array_t), font->num_fontdicts);
if (font->fd_local_sub_index == NULL) {
- status = CAIRO_STATUS_NO_MEMORY;
+ status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto fail;
}
for (i = 0; i < font->num_fontdicts; i++) {
cff_dict_init (&font->fd_dict[i]);
if (font->fd_dict[i] == NULL) {
- status = CAIRO_STATUS_NO_MEMORY;
+ status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto fail;
}
element = _cairo_array_index (&index, i);
@@ -818,7 +810,7 @@ cairo_cff_font_read_cid_fontdict (cairo_cff_font_t *font, unsigned char *ptr)
decode_integer (operand, &offset);
cff_dict_init (&font->fd_private_dict[i]);
if (font->fd_private_dict[i] == NULL) {
- status = CAIRO_STATUS_NO_MEMORY;
+ status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto fail;
}
cff_index_init (&font->fd_local_sub_index[i]);
@@ -843,8 +835,7 @@ cairo_cff_font_read_cid_fontdict (cairo_cff_font_t *font, unsigned char *ptr)
fail:
cff_index_fini (&index);
- _cairo_error (status);
- return status;
+ return _cairo_error (status);
}
static cairo_int_status_t
@@ -1078,28 +1069,20 @@ cairo_cff_font_subset_fontdict (cairo_cff_font_t *font)
font->fdselect_subset = calloc (font->scaled_font_subset->num_glyphs,
sizeof (int));
- if (font->fdselect_subset == NULL) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
- return CAIRO_STATUS_NO_MEMORY;
- }
+ if (font->fdselect_subset == NULL)
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
font->fd_subset_map = calloc (font->num_fontdicts, sizeof (int));
- if (font->fd_subset_map == NULL) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
- return CAIRO_STATUS_NO_MEMORY;
- }
+ if (font->fd_subset_map == NULL)
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
font->private_dict_offset = calloc (font->num_fontdicts, sizeof (int));
- if (font->private_dict_offset == NULL) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
- return CAIRO_STATUS_NO_MEMORY;
- }
+ if (font->private_dict_offset == NULL)
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
reverse_map = calloc (font->num_fontdicts, sizeof (int));
- if (reverse_map == NULL) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
- return CAIRO_STATUS_NO_MEMORY;
- }
+ if (reverse_map == NULL)
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
for (i = 0; i < font->num_fontdicts; i++)
reverse_map[i] = -1;
@@ -1127,24 +1110,18 @@ cairo_cff_font_create_cid_fontdict (cairo_cff_font_t *font)
font->num_fontdicts = 1;
font->fd_dict = malloc (sizeof (cairo_hash_table_t *));
- if (font->fd_dict == NULL) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
- return CAIRO_STATUS_NO_MEMORY;
- }
+ if (font->fd_dict == NULL)
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
cff_dict_init (&font->fd_dict[0]);
font->fd_subset_map = malloc (sizeof (int));
- if (font->fd_subset_map == NULL) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
- return CAIRO_STATUS_NO_MEMORY;
- }
+ if (font->fd_subset_map == NULL)
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
font->private_dict_offset = malloc (sizeof (int));
- if (font->private_dict_offset == NULL) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
- return CAIRO_STATUS_NO_MEMORY;
- }
+ if (font->private_dict_offset == NULL)
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
font->fd_subset_map[0] = 0;
font->num_subset_fontdicts = 1;
@@ -1698,10 +1675,8 @@ _cairo_cff_font_create (cairo_scaled_font_subset_t *scaled_font_subset,
return status;
name = malloc (size);
- if (name == NULL) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
- return CAIRO_STATUS_NO_MEMORY;
- }
+ if (name == NULL)
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
status = backend->load_truetype_table (scaled_font_subset->scaled_font,
TT_TAG_name, 0,
@@ -1711,7 +1686,7 @@ _cairo_cff_font_create (cairo_scaled_font_subset_t *scaled_font_subset,
font = malloc (sizeof (cairo_cff_font_t));
if (font == NULL) {
- status = CAIRO_STATUS_NO_MEMORY;
+ status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto fail1;
}
@@ -1725,7 +1700,7 @@ _cairo_cff_font_create (cairo_scaled_font_subset_t *scaled_font_subset,
font->subset_font_name = strdup (subset_name);
if (font->subset_font_name == NULL) {
- status = CAIRO_STATUS_NO_MEMORY;
+ status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto fail3;
}
font->x_min = (int16_t) be16_to_cpu (head.x_min);
@@ -1761,7 +1736,7 @@ _cairo_cff_font_create (cairo_scaled_font_subset_t *scaled_font_subset,
if (font->font_name == NULL) {
font->font_name = malloc (30);
if (font->font_name == NULL) {
- status = CAIRO_STATUS_NO_MEMORY;
+ status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto fail4;
}
snprintf(font->font_name, 30, "CairoFont-%u-%u",
@@ -1778,7 +1753,7 @@ _cairo_cff_font_create (cairo_scaled_font_subset_t *scaled_font_subset,
font->widths = calloc (font->scaled_font_subset->num_glyphs, sizeof (int));
if (font->widths == NULL) {
- status = CAIRO_STATUS_NO_MEMORY;
+ status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto fail5;
}
cairo_cff_font_create_set_widths (font);
@@ -1786,7 +1761,7 @@ _cairo_cff_font_create (cairo_scaled_font_subset_t *scaled_font_subset,
font->data_length = data_length;
font->data = malloc (data_length);
if (font->data == NULL) {
- status = CAIRO_STATUS_NO_MEMORY;
+ status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto fail6;
}
status = font->backend->load_truetype_table ( font->scaled_font_subset->scaled_font,
@@ -1831,8 +1806,7 @@ fail2:
free (font);
fail1:
free (name);
- _cairo_error (status);
- return status;
+ return _cairo_error (status);
}
static void
@@ -1946,8 +1920,7 @@ _cairo_cff_subset_init (cairo_cff_subset_t *cff_subset,
fail1:
cairo_cff_font_destroy (font);
- _cairo_error (status);
- return status;
+ return _cairo_error (status);
}
void
@@ -1967,10 +1940,8 @@ _cairo_cff_font_fallback_create (cairo_scaled_font_subset_t *scaled_font_subset
cairo_cff_font_t *font;
font = malloc (sizeof (cairo_cff_font_t));
- if (font == NULL) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
- return CAIRO_STATUS_NO_MEMORY;
- }
+ if (font == NULL)
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
font->backend = NULL;
font->scaled_font_subset = scaled_font_subset;
@@ -1982,13 +1953,13 @@ _cairo_cff_font_fallback_create (cairo_scaled_font_subset_t *scaled_font_subset
font->subset_font_name = strdup (subset_name);
if (font->subset_font_name == NULL) {
- status = CAIRO_STATUS_NO_MEMORY;
+ status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto fail2;
}
font->font_name = strdup (subset_name);
if (font->subset_font_name == NULL) {
- status = CAIRO_STATUS_NO_MEMORY;
+ status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto fail3;
}
@@ -2001,7 +1972,7 @@ _cairo_cff_font_fallback_create (cairo_scaled_font_subset_t *scaled_font_subset
font->widths = calloc (font->scaled_font_subset->num_glyphs, sizeof (int));
if (font->widths == NULL) {
- status = CAIRO_STATUS_NO_MEMORY;
+ status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto fail4;
}
@@ -2037,8 +2008,7 @@ fail2:
_cairo_array_fini (&font->output);
fail1:
free (font);
- _cairo_error (status);
- return status;
+ return _cairo_error (status);
}
static cairo_int_status_t
diff --git a/src/cairo-clip.c b/src/cairo-clip.c
index 4f42414b..43b25ca2 100644
--- a/src/cairo-clip.c
+++ b/src/cairo-clip.c
@@ -86,7 +86,7 @@ _cairo_clip_init_copy (cairo_clip_t *clip, cairo_clip_t *other)
{
_cairo_region_fini (&clip->region);
cairo_surface_destroy (clip->surface);
- return CAIRO_STATUS_NO_MEMORY;
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
}
clip->has_region = TRUE;
} else {
@@ -276,10 +276,8 @@ _cairo_clip_intersect_path (cairo_clip_t *clip,
return CAIRO_INT_STATUS_UNSUPPORTED;
clip_path = malloc (sizeof (cairo_clip_path_t));
- if (clip_path == NULL) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
- return CAIRO_STATUS_NO_MEMORY;
- }
+ if (clip_path == NULL)
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
status = _cairo_path_fixed_init_copy (&clip_path->path, path);
if (status) {
@@ -404,7 +402,7 @@ _cairo_clip_intersect_mask (cairo_clip_t *clip,
CAIRO_COLOR_WHITE,
NULL);
if (surface->status)
- return CAIRO_STATUS_NO_MEMORY;
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
/* Render the new clipping path into the new mask surface. */
@@ -593,7 +591,7 @@ BAIL:
if (clip->surface)
cairo_surface_destroy (clip->surface);
- return CAIRO_STATUS_NO_MEMORY;
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
}
const cairo_rectangle_list_t _cairo_rectangles_nil =
@@ -644,7 +642,7 @@ _cairo_clip_copy_rectangle_list (cairo_clip_t *clip, cairo_gstate_t *gstate)
rectangles = _cairo_malloc_ab (n_boxes, sizeof (cairo_rectangle_t));
if (rectangles == NULL) {
_cairo_region_boxes_fini (&clip->region, boxes);
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
+ _cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
return (cairo_rectangle_list_t*) &_cairo_rectangles_nil;
}
@@ -669,7 +667,7 @@ _cairo_clip_copy_rectangle_list (cairo_clip_t *clip, cairo_gstate_t *gstate)
rectangles = malloc(sizeof (cairo_rectangle_t));
if (rectangles == NULL) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
+ _cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
return (cairo_rectangle_list_t*) &_cairo_rectangles_nil;
}
@@ -684,7 +682,7 @@ _cairo_clip_copy_rectangle_list (cairo_clip_t *clip, cairo_gstate_t *gstate)
list = malloc (sizeof (cairo_rectangle_list_t));
if (list == NULL) {
free (rectangles);
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
+ _cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
return (cairo_rectangle_list_t*) &_cairo_rectangles_nil;
}
diff --git a/src/cairo-deflate-stream.c b/src/cairo-deflate-stream.c
index 618c6bec..73746fe1 100644
--- a/src/cairo-deflate-stream.c
+++ b/src/cairo-deflate-stream.c
@@ -119,7 +119,7 @@ _cairo_deflate_stream_create (cairo_output_stream_t *output)
stream = malloc (sizeof (cairo_deflate_stream_t));
if (stream == NULL) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
+ _cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
return (cairo_output_stream_t *) &_cairo_output_stream_nil;
}
diff --git a/src/cairo-directfb-surface.c b/src/cairo-directfb-surface.c
index 50f926cc..b79f8e2f 100644
--- a/src/cairo-directfb-surface.c
+++ b/src/cairo-directfb-surface.c
@@ -390,7 +390,7 @@ _directfb_acquire_surface (cairo_directfb_surface_t *surface,
if( buffer != surface->dfbsurface)
buffer->Release(buffer);
}
- return CAIRO_STATUS_NO_MEMORY;
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
}
@@ -415,7 +415,7 @@ _cairo_directfb_surface_create_similar (void *abstract_src,
format = _cairo_format_from_content (content);
surface = calloc (1, sizeof(cairo_directfb_surface_t));
if (!surface) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
+ _cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
return NULL;
}
@@ -576,14 +576,14 @@ _cairo_directfb_surface_clone_similar (void *abstract_surface,
_cairo_content_from_format (image_src->format),
image_src->width, image_src->height);
if (!clone)
- return CAIRO_STATUS_NO_MEMORY;
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
ret = clone->dfbsurface->Lock (clone->dfbsurface,
DSLF_WRITE, (void *)&dst, &pitch);
if (ret) {
DirectFBError ("IDirectFBSurface::Lock()", ret);
cairo_surface_destroy ((cairo_surface_t *)clone);
- return CAIRO_STATUS_NO_MEMORY;
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
}
dst += pitch * src_y;
@@ -687,7 +687,7 @@ _directfb_prepare_composite (cairo_directfb_surface_t *dst,
dst->color = _cairo_directfb_surface_create_similar (dst,
CAIRO_CONTENT_COLOR_ALPHA, 1, 1);
if (!dst->color)
- return CAIRO_STATUS_NO_MEMORY;
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
}
src = (cairo_directfb_surface_t *)dst->color;
@@ -758,7 +758,7 @@ _cairo_directfb_surface_composite (cairo_operator_t op,
unsigned int height)
{
cairo_directfb_surface_t *dst = abstract_dst;
- cairo_directfb_surface_t *src;
+ cairo_directfb_surface_t *src = NULL; /* hide compiler warning */
cairo_surface_attributes_t src_attr;
cairo_matrix_t *m;
cairo_status_t ret;
@@ -1109,9 +1109,11 @@ _cairo_directfb_surface_set_clip_region (void *abstract_surface,
if (region) {
cairo_box_int_t *boxes;
int n_boxes, i;
+ cairo_status_t status;
- if (_cairo_region_get_boxes (region, &n_boxes, &boxes) != CAIRO_STATUS_SUCCESS)
- return CAIRO_STATUS_NO_MEMORY;
+ status = _cairo_region_get_boxes (region, &n_boxes, &boxes);
+ if (status)
+ return status;
if (surface->n_clips != n_boxes) {
if( surface->clips )
@@ -1121,8 +1123,7 @@ _cairo_directfb_surface_set_clip_region (void *abstract_surface,
if (!surface->clips) {
_cairo_region_boxes_fini (region, boxes);
surface->n_clips = 0;
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
- return CAIRO_STATUS_NO_MEMORY;
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
}
surface->n_clips = n_boxes;
@@ -1184,7 +1185,7 @@ _cairo_directfb_surface_mark_dirty_rectangle (void *abstract_surface,
if( !surface->dirty_region )
surface->dirty_region = malloc(sizeof(DFBRegion));
if (!dirty_region)
- return CAIRO_STATUS_NO_MEMORY;
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
#endif
return CAIRO_STATUS_SUCCESS;
}
@@ -1215,14 +1216,14 @@ _directfb_allocate_font_cache (IDirectFB *dfb, int width, int height)
cache = calloc (1, sizeof(cairo_directfb_font_cache_t));
if (!cache) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
+ _cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
return NULL;
}
cache->dfbsurface = _directfb_buffer_surface_create( dfb, DSPF_A8, width, height);
if (!cache->dfbsurface) {
free (cache);
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
+ _cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
return NULL;
}
@@ -1319,10 +1320,8 @@ _directfb_acquire_font_cache (cairo_directfb_surface_t *surface,
/* Remember glyph location */
rect = malloc (sizeof(DFBRectangle));
- if (!rect) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
- return CAIRO_STATUS_NO_MEMORY;
- }
+ if (!rect)
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
*rect = rects[n];
scaled_glyph->surface_private = rect;
@@ -1359,10 +1358,8 @@ _directfb_acquire_font_cache (cairo_directfb_surface_t *surface,
"Reallocating font cache (%dx%d).\n", w, h);
new_cache = _directfb_allocate_font_cache (surface->dfb, w, h);
- if (!new_cache) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
- return CAIRO_STATUS_NO_MEMORY;
- }
+ if (!new_cache)
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
new_cache->dfbsurface->Blit (new_cache->dfbsurface,
cache->dfbsurface, NULL, 0, 0);
@@ -1376,10 +1373,8 @@ _directfb_acquire_font_cache (cairo_directfb_surface_t *surface,
"Allocating font cache (%dx%d).\n", w, h);
cache = _directfb_allocate_font_cache (surface->dfb, w, h);
- if (!cache) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
- return CAIRO_STATUS_NO_MEMORY;
- }
+ if (!cache)
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
scaled_font->surface_backend = &cairo_directfb_surface_backend;
scaled_font->surface_private = cache;
@@ -1391,7 +1386,7 @@ _directfb_acquire_font_cache (cairo_directfb_surface_t *surface,
if (cache->dfbsurface->Lock (cache->dfbsurface,
DSLF_WRITE, (void *)&data, &pitch))
- return CAIRO_STATUS_NO_MEMORY;
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
for (i = 0; i < num_chars; i++) {
cairo_image_surface_t *img = chars[i]->surface;
@@ -1642,7 +1637,7 @@ cairo_directfb_surface_create (IDirectFB *dfb, IDirectFBSurface *dfbsurface)
surface = calloc (1, sizeof(cairo_directfb_surface_t));
if (!surface) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
+ _cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
return NULL;
}
diff --git a/src/cairo-font-face.c b/src/cairo-font-face.c
index b3bcc843..0285b52e 100644
--- a/src/cairo-font-face.c
+++ b/src/cairo-font-face.c
@@ -231,7 +231,7 @@ cairo_font_face_set_user_data (cairo_font_face_t *font_face,
cairo_destroy_func_t destroy)
{
if (CAIRO_REFERENCE_COUNT_IS_INVALID (&font_face->ref_count))
- return CAIRO_STATUS_NO_MEMORY;
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
return _cairo_user_data_array_set_data (&font_face->user_data,
key, user_data, destroy);
@@ -321,7 +321,7 @@ _cairo_toy_font_face_init (cairo_toy_font_face_t *font_face,
family_copy = strdup (family);
if (family_copy == NULL)
- return CAIRO_STATUS_NO_MEMORY;
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
_cairo_toy_font_face_init_key (font_face, family_copy,
slant, weight);
@@ -396,7 +396,7 @@ _cairo_toy_font_face_create (const char *family,
/* Otherwise create it and insert into hash table. */
font_face = malloc (sizeof (cairo_toy_font_face_t));
if (font_face == NULL) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
+ status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto UNWIND_HASH_TABLE_LOCK;
}
diff --git a/src/cairo-font-options.c b/src/cairo-font-options.c
index b3a5660c..c5d5c12b 100644
--- a/src/cairo-font-options.c
+++ b/src/cairo-font-options.c
@@ -90,7 +90,7 @@ cairo_font_options_create (void)
options = malloc (sizeof (cairo_font_options_t));
if (!options) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
+ _cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
return (cairo_font_options_t *)&_cairo_font_options_nil;
}
@@ -123,7 +123,7 @@ cairo_font_options_copy (const cairo_font_options_t *original)
options = malloc (sizeof (cairo_font_options_t));
if (!options) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
+ _cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
return (cairo_font_options_t *)&_cairo_font_options_nil;
}
diff --git a/src/cairo-ft-font.c b/src/cairo-ft-font.c
index 753810a8..7768a77c 100644
--- a/src/cairo-ft-font.c
+++ b/src/cairo-ft-font.c
@@ -177,7 +177,7 @@ _cairo_ft_unscaled_font_map_create (void)
font_map = malloc (sizeof (cairo_ft_unscaled_font_map_t));
if (font_map == NULL) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
+ _cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
goto FAIL;
}
@@ -257,7 +257,7 @@ _cairo_ft_unscaled_font_map_lock (void)
if (cairo_ft_unscaled_font_map == NULL) {
CAIRO_MUTEX_UNLOCK (_cairo_ft_unscaled_font_map_mutex);
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
+ _cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
return NULL;
}
}
@@ -330,10 +330,8 @@ _cairo_ft_unscaled_font_init (cairo_ft_unscaled_font_t *unscaled,
unscaled->face = NULL;
filename_copy = strdup (filename);
- if (filename_copy == NULL) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
- return CAIRO_STATUS_NO_MEMORY;
- }
+ if (filename_copy == NULL)
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
_cairo_ft_unscaled_font_init_key (unscaled, filename_copy, id);
}
@@ -426,7 +424,7 @@ _cairo_ft_unscaled_font_create_for_pattern (FcPattern *pattern)
/* Otherwise create it and insert into hash table. */
unscaled = malloc (sizeof (cairo_ft_unscaled_font_t));
if (unscaled == NULL) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
+ _cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
goto UNWIND_FONT_MAP_LOCK;
}
@@ -461,7 +459,7 @@ _cairo_ft_unscaled_font_create_from_face (FT_Face face)
unscaled = malloc (sizeof (cairo_ft_unscaled_font_t));
if (unscaled == NULL) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
+ _cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
return NULL;
}
@@ -560,7 +558,7 @@ _cairo_ft_unscaled_font_lock_face (cairo_ft_unscaled_font_t *unscaled)
{
unscaled->lock_count--;
CAIRO_MUTEX_UNLOCK (unscaled->mutex);
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
+ _cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
return NULL;
}
@@ -666,10 +664,8 @@ _cairo_ft_unscaled_font_set_scale (cairo_ft_unscaled_font_t *unscaled,
sf.x_scale * 64.0,
sf.y_scale * 64.0,
0, 0);
- if (error) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
- return CAIRO_STATUS_NO_MEMORY;
- }
+ if (error)
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
} else {
double min_distance = DBL_MAX;
int i;
@@ -698,10 +694,8 @@ _cairo_ft_unscaled_font_set_scale (cairo_ft_unscaled_font_t *unscaled,
error = FT_Set_Pixel_Sizes (unscaled->face,
unscaled->face->available_sizes[best_i].width,
unscaled->face->available_sizes[best_i].height);
- if (error) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
- return CAIRO_STATUS_NO_MEMORY;
- }
+ if (error)
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
}
return CAIRO_STATUS_SUCCESS;
@@ -755,10 +749,8 @@ _get_bitmap_surface (FT_Bitmap *bitmap,
assert (stride == bitmap->pitch);
} else {
data = _cairo_malloc_ab (height, stride);
- if (!data) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
- return CAIRO_STATUS_NO_MEMORY;
- }
+ if (!data)
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
if (stride == bitmap->pitch) {
memcpy (data, bitmap->buffer, stride * height);
@@ -805,10 +797,9 @@ _get_bitmap_surface (FT_Bitmap *bitmap,
data = bitmap->buffer;
} else {
data = _cairo_malloc_ab (height, stride);
- if (!data) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
- return CAIRO_STATUS_NO_MEMORY;
- }
+ if (!data)
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
+
memcpy (data, bitmap->buffer, stride * height);
}
format = CAIRO_FORMAT_A8;
@@ -850,8 +841,7 @@ _get_bitmap_surface (FT_Bitmap *bitmap,
if (data_rgba == NULL) {
if (own_buffer)
free (bitmap->buffer);
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
- return CAIRO_STATUS_NO_MEMORY;
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
}
os = 1;
@@ -919,8 +909,7 @@ _get_bitmap_surface (FT_Bitmap *bitmap,
default:
if (own_buffer)
free (bitmap->buffer);
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
- return CAIRO_STATUS_NO_MEMORY;
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
}
*surface = (cairo_image_surface_t *)
@@ -929,7 +918,7 @@ _get_bitmap_surface (FT_Bitmap *bitmap,
width, height, stride);
if ((*surface)->base.status) {
free (data);
- return CAIRO_STATUS_NO_MEMORY;
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
}
if (subpixel)
@@ -1002,7 +991,7 @@ _render_glyph_outline (FT_Face face,
(*surface) = (cairo_image_surface_t *)
cairo_image_surface_create_for_data (NULL, format, 0, 0, 0);
if ((*surface)->base.status)
- return CAIRO_STATUS_NO_MEMORY;
+ return (*surface)->base.status;
} else {
matrix.xx = matrix.yy = 0x10000L;
@@ -1049,16 +1038,14 @@ _render_glyph_outline (FT_Face face,
bitmap.rows = height * vmul;
bitmap.buffer = calloc (stride, bitmap.rows);
if (bitmap.buffer == NULL) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
- return CAIRO_STATUS_NO_MEMORY;
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
}
FT_Outline_Translate (outline, -cbox.xMin*hmul, -cbox.yMin*vmul);
if (FT_Outline_Get_Bitmap (glyphslot->library, outline, &bitmap) != 0) {
free (bitmap.buffer);
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
- return CAIRO_STATUS_NO_MEMORY;
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
}
status = _get_bitmap_surface (&bitmap, TRUE, font_options, surface);
@@ -1099,10 +1086,8 @@ _render_glyph_bitmap (FT_Face face,
error = FT_Render_Glyph (glyphslot, FT_RENDER_MODE_NORMAL);
/* XXX ignoring all other errors for now. They are not fatal, typically
* just a glyph-not-found. */
- if (error == FT_Err_Out_Of_Memory) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
- return CAIRO_STATUS_NO_MEMORY;
- }
+ if (error == FT_Err_Out_Of_Memory)
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
status = _get_bitmap_surface (&glyphslot->bitmap, FALSE, font_options, surface);
if (status)
@@ -1199,7 +1184,7 @@ _transform_glyph_bitmap (cairo_matrix_t * shape,
width = (width + 3) & ~3;
image = cairo_image_surface_create (CAIRO_FORMAT_A8, width, height);
if (image->status)
- return CAIRO_STATUS_NO_MEMORY;
+ return image->status;
/* Initialize it to empty
*/
@@ -1486,7 +1471,7 @@ _cairo_ft_scaled_font_create (cairo_ft_unscaled_font_t *unscaled,
scaled_font = malloc (sizeof(cairo_ft_scaled_font_t));
if (scaled_font == NULL) {
_cairo_ft_unscaled_font_unlock_face (unscaled);
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
+ _cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
return NULL;
}
@@ -1596,10 +1581,8 @@ _cairo_ft_scaled_font_create_toy (cairo_toy_font_face_t *toy_face,
unsigned char *family = (unsigned char*) toy_face->family;
pattern = FcPatternCreate ();
- if (!pattern) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
- return CAIRO_STATUS_NO_MEMORY;
- }
+ if (!pattern)
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
switch (toy_face->weight)
{
@@ -1668,10 +1651,8 @@ _cairo_ft_scaled_font_create_toy (cairo_toy_font_face_t *toy_face,
if (new_font) {
*font = new_font;
return CAIRO_STATUS_SUCCESS;
- } else {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
- return CAIRO_STATUS_NO_MEMORY;
- }
+ } else
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
}
static void
@@ -1804,7 +1785,7 @@ _decompose_glyph_outline (FT_Face face,
path = _cairo_path_fixed_create ();
if (!path)
- return CAIRO_STATUS_NO_MEMORY;
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
glyph = face->glyph;
@@ -1812,8 +1793,7 @@ _decompose_glyph_outline (FT_Face face,
FT_Outline_Transform (&glyph->outline, &invert_y);
if (FT_Outline_Decompose (&glyph->outline, &outline_funcs, path)) {
_cairo_path_fixed_destroy (path);
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
- return CAIRO_STATUS_NO_MEMORY;
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
}
status = _cairo_path_fixed_close_path (path);
@@ -1868,7 +1848,7 @@ _cairo_ft_scaled_glyph_init (void *abstract_font,
face = _cairo_ft_unscaled_font_lock_face (unscaled);
if (!face)
- return CAIRO_STATUS_NO_MEMORY;
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
status = _cairo_ft_unscaled_font_set_scale (scaled_font->unscaled,
&scaled_font->base.scale);
@@ -1897,7 +1877,7 @@ _cairo_ft_scaled_glyph_init (void *abstract_font,
/* XXX ignoring all other errors for now. They are not fatal, typically
* just a glyph-not-found. */
if (error == FT_Err_Out_Of_Memory) {
- status = CAIRO_STATUS_NO_MEMORY;
+ status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto FAIL;
}
@@ -2036,7 +2016,7 @@ _cairo_ft_scaled_glyph_init (void *abstract_font,
}
if (info & CAIRO_SCALED_GLYPH_INFO_PATH) {
- cairo_path_fixed_t *path;
+ cairo_path_fixed_t *path = NULL; /* hide compiler warning */
/*
* A kludge -- the above code will trash the outline,
@@ -2049,9 +2029,8 @@ _cairo_ft_scaled_glyph_init (void *abstract_font,
/* XXX ignoring all other errors for now. They are not fatal, typically
* just a glyph-not-found. */
if (error == FT_Err_Out_Of_Memory) {
- _cairo_ft_unscaled_font_unlock_face (unscaled);
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
- return CAIRO_STATUS_NO_MEMORY;
+ status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
+ goto FAIL;
}
#if HAVE_FT_GLYPHSLOT_EMBOLDEN
/*
@@ -2118,7 +2097,7 @@ _cairo_ft_load_truetype_table (void *abstract_font,
#if HAVE_FT_LOAD_SFNT_TABLE
face = _cairo_ft_unscaled_font_lock_face (unscaled);
if (!face)
- return CAIRO_STATUS_NO_MEMORY;
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
if (FT_IS_SFNT (face) &&
FT_Load_Sfnt_Table (face, tag, offset, buffer, length) == 0)
@@ -2260,12 +2239,10 @@ _cairo_ft_font_face_scaled_font_create (void *abstract_face,
&font_face->base,
font_matrix, ctm,
options, ft_options);
- if (*scaled_font) {
+ if (*scaled_font)
return CAIRO_STATUS_SUCCESS;
- } else {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
- return CAIRO_STATUS_NO_MEMORY;
- }
+ else
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
}
static const cairo_font_face_backend_t _cairo_ft_font_face_backend = {
@@ -2301,7 +2278,7 @@ _cairo_ft_font_face_create (cairo_ft_unscaled_font_t *unscaled,
/* No match found, create a new one */
font_face = malloc (sizeof (cairo_ft_font_face_t));
if (!font_face) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
+ _cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
return NULL;
}
@@ -2451,7 +2428,7 @@ cairo_ft_font_face_create_for_pattern (FcPattern *pattern)
unscaled = _cairo_ft_unscaled_font_create_for_pattern (pattern);
if (unscaled == NULL) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
+ _cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
return (cairo_font_face_t *)&_cairo_font_face_nil;
}
@@ -2501,7 +2478,7 @@ cairo_ft_font_face_create_for_ft_face (FT_Face face,
unscaled = _cairo_ft_unscaled_font_create_from_face (face);
if (unscaled == NULL) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
+ _cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
return (cairo_font_face_t *)&_cairo_font_face_nil;
}
diff --git a/src/cairo-glitz-surface.c b/src/cairo-glitz-surface.c
index 4d781cfc..83a51097 100644
--- a/src/cairo-glitz-surface.c
+++ b/src/cairo-glitz-surface.c
@@ -89,7 +89,7 @@ _cairo_glitz_surface_create_similar (void *abstract_src,
glitz_find_standard_format (drawable,
_glitz_format_from_content (content));
if (!gformat) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
+ _cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
return (cairo_surface_t*) &_cairo_surface_nil;
}
@@ -99,7 +99,7 @@ _cairo_glitz_surface_create_similar (void *abstract_src,
0, NULL);
if (surface == NULL) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
+ _cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
return (cairo_surface_t*) &_cairo_surface_nil;
}
@@ -166,7 +166,7 @@ _cairo_glitz_get_boxes_from_region (cairo_region_t *region, int *nboxes)
gboxes = _cairo_malloc_ab (n, sizeof(glitz_box_t));
if (gboxes == NULL) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
+ _cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
goto done;
}
@@ -271,16 +271,13 @@ _cairo_glitz_surface_get_image (cairo_glitz_surface_t *surface,
pf.scanline_order = GLITZ_PIXEL_SCANLINE_ORDER_TOP_DOWN;
pixels = _cairo_malloc_ab (height, pf.bytes_per_line);
- if (!pixels) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
- return CAIRO_STATUS_NO_MEMORY;
- }
+ if (!pixels)
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
buffer = glitz_buffer_create_for_data (pixels);
if (!buffer) {
free (pixels);
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
- return CAIRO_STATUS_NO_MEMORY;
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
}
/* clear out the glitz clip; the clip affects glitz_get_pixels */
@@ -304,7 +301,7 @@ _cairo_glitz_surface_get_image (cairo_glitz_surface_t *surface,
box = _cairo_glitz_get_boxes_from_region (&surface->clip, &n);
if (box == NULL && n != 0) {
free (pixels);
- return CAIRO_STATUS_NO_MEMORY;
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
}
glitz_surface_set_clip_region (surface->surface, 0, 0, box, n);
@@ -350,7 +347,7 @@ _cairo_glitz_surface_get_image (cairo_glitz_surface_t *surface,
FAIL:
free (pixels);
- return CAIRO_STATUS_NO_MEMORY;
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
}
static void
@@ -433,7 +430,7 @@ _cairo_glitz_surface_set_image (void *abstract_surface,
buffer = glitz_buffer_create_for_data (data);
if (!buffer)
- return CAIRO_STATUS_NO_MEMORY;
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
glitz_set_pixels (surface->surface,
x_dst, y_dst,
@@ -539,7 +536,7 @@ _cairo_glitz_surface_clone_similar (void *abstract_surface,
image_src->width,
image_src->height);
if (clone->base.status)
- return CAIRO_STATUS_NO_MEMORY;
+ return clone->base.status;
image_extent.x = 0;
image_extent.y = 0;
@@ -769,32 +766,28 @@ _cairo_glitz_pattern_acquire_surface (cairo_pattern_t *pattern,
int size1, size2;
if (n_params >= INT32_MAX / sizeof (glitz_fixed16_16_t) ||
gradient->n_stops >= INT32_MAX / sizeof (unsigned int))
- return CAIRO_STATUS_NO_MEMORY;
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
size1 = n_params * sizeof (glitz_fixed16_16_t);
size2 = gradient->n_stops * sizeof (unsigned int);
if (size1 >= INT32_MAX - size2)
- return CAIRO_STATUS_NO_MEMORY;
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
data = malloc (size1 + size2);
}
- if (!data) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
- return CAIRO_STATUS_NO_MEMORY;
- }
+ if (!data)
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
params = (glitz_fixed16_16_t *) data;
pixels = (unsigned int *)
(data + sizeof (glitz_fixed16_16_t) * n_params);
buffer = glitz_buffer_create_for_data (pixels);
- if (!buffer)
- {
+ if (!buffer) {
free (data);
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
- return CAIRO_STATUS_NO_MEMORY;
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
}
src = (cairo_glitz_surface_t *)
@@ -805,7 +798,7 @@ _cairo_glitz_pattern_acquire_surface (cairo_pattern_t *pattern,
{
glitz_buffer_destroy (buffer);
free (data);
- return CAIRO_STATUS_NO_MEMORY;
+ return src->base.status;
}
for (i = 0; i < gradient->n_stops; i++)
@@ -1166,7 +1159,7 @@ _cairo_glitz_surface_fill_rectangles (void *abstract_dst,
(cairo_color_t *) color,
NULL);
if (src->base.status)
- return CAIRO_STATUS_NO_MEMORY;
+ return src->base.status;
glitz_surface_set_fill (src->surface, GLITZ_FILL_REPEAT);
@@ -1285,7 +1278,7 @@ _cairo_glitz_surface_composite_trapezoids (cairo_operator_t op,
if (src_pattern == &tmp_src_pattern.base)
_cairo_pattern_fini (&tmp_src_pattern.base);
- return CAIRO_STATUS_NO_MEMORY;
+ return mask->base.status;
}
color.red = color.green = color.blue = color.alpha = 0xffff;
@@ -1312,8 +1305,7 @@ _cairo_glitz_surface_composite_trapezoids (cairo_operator_t op,
&attributes);
if (src_pattern == &tmp_src_pattern.base)
_cairo_pattern_fini (&tmp_src_pattern.base);
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
- return CAIRO_STATUS_NO_MEMORY;
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
}
if (buffer)
@@ -1326,8 +1318,7 @@ _cairo_glitz_surface_composite_trapezoids (cairo_operator_t op,
&attributes);
if (src_pattern == &tmp_src_pattern.base)
_cairo_pattern_fini (&tmp_src_pattern.base);
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
- return CAIRO_STATUS_NO_MEMORY;
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
}
}
@@ -1363,8 +1354,7 @@ _cairo_glitz_surface_composite_trapezoids (cairo_operator_t op,
_cairo_glitz_pattern_release_surface (src_pattern, src, &attributes);
if (src_pattern == &tmp_src_pattern.base)
_cairo_pattern_fini (&tmp_src_pattern.base);
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
- return CAIRO_STATUS_NO_MEMORY;
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
}
/* using negative stride */
@@ -1379,7 +1369,7 @@ _cairo_glitz_surface_composite_trapezoids (cairo_operator_t op,
{
cairo_surface_destroy (&src->base);
free (data);
- return CAIRO_STATUS_NO_MEMORY;
+ return image->base.status;
}
pixman_add_trapezoids (image->pixman_image, -dst_x, -dst_y,
@@ -1394,7 +1384,7 @@ _cairo_glitz_surface_composite_trapezoids (cairo_operator_t op,
_cairo_glitz_pattern_release_surface (src_pattern, src, &attributes);
free (data);
cairo_surface_destroy (&image->base);
- return CAIRO_STATUS_NO_MEMORY;
+ return mask->base.status;
}
_cairo_glitz_surface_set_image (mask, image, 0, 0, width, height, 0, 0);
@@ -1449,24 +1439,25 @@ _cairo_glitz_surface_set_clip_region (void *abstract_surface,
{
glitz_box_t *box;
int n;
+ cairo_status_t status;
if (!surface->has_clip) {
_cairo_region_init (&surface->clip);
surface->has_clip = TRUE;
}
- if (_cairo_region_copy (&surface->clip, region) != CAIRO_STATUS_SUCCESS)
- {
+ status = _cairo_region_copy (&surface->clip, region);
+ if (status) {
_cairo_region_fini (&surface->clip);
surface->has_clip = FALSE;
- return CAIRO_STATUS_NO_MEMORY;
+ return status;
}
box = _cairo_glitz_get_boxes_from_region (&surface->clip, &n);
if (box == NULL && n != 0) {
_cairo_region_fini (&surface->clip);
surface->has_clip = FALSE;
- return CAIRO_STATUS_NO_MEMORY;
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
}
glitz_surface_set_clip_region (surface->surface, 0, 0, box, n);
@@ -1577,7 +1568,7 @@ _cairo_glitz_area_create (cairo_glitz_root_area_t *root,
area = malloc (sizeof (cairo_glitz_area_t));
if (!area) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
+ _cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
return NULL;
}
@@ -1801,7 +1792,7 @@ _cairo_glitz_root_area_init (cairo_glitz_root_area_t *root,
root->area = _cairo_glitz_area_create (root, 0, 0, 0, width, height);
if (!root->area)
- return CAIRO_STATUS_NO_MEMORY;
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
return CAIRO_STATUS_SUCCESS;
}
@@ -1913,10 +1904,8 @@ _cairo_glitz_surface_font_init (cairo_glitz_surface_t *surface,
return CAIRO_INT_STATUS_UNSUPPORTED;
font_private = malloc (sizeof (cairo_glitz_surface_font_private_t));
- if (!font_private) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
- return CAIRO_STATUS_NO_MEMORY;
- }
+ if (!font_private)
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
font_private->surface = glitz_surface_create (drawable, surface_format,
GLYPH_CACHE_TEXTURE_SIZE,
@@ -2001,10 +1990,8 @@ _cairo_glitz_surface_add_glyph (cairo_glitz_surface_t *surface,
if (glyph_private == NULL)
{
glyph_private = malloc (sizeof (cairo_glitz_surface_glyph_private_t));
- if (!glyph_private) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
- return CAIRO_STATUS_NO_MEMORY;
- }
+ if (!glyph_private)
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
glyph_private->area = NULL;
glyph_private->locked = FALSE;
@@ -2048,7 +2035,7 @@ _cairo_glitz_surface_add_glyph (cairo_glitz_surface_t *surface,
if (!buffer)
{
_cairo_glitz_area_move_out (glyph_private->area);
- return CAIRO_STATUS_NO_MEMORY;
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
}
cairo_format_get_masks (glyph_surface->format, &bpp, &am, &rm, &gm, &bm);
@@ -2169,7 +2156,7 @@ _cairo_glitz_surface_old_show_glyphs (cairo_scaled_font_t *scaled_font,
data = malloc (size1 + size2);
if (!data) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
+ _cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
goto FAIL1;
}
@@ -2459,7 +2446,7 @@ cairo_glitz_surface_create (glitz_surface_t *surface)
crsurface = malloc (sizeof (cairo_glitz_surface_t));
if (crsurface == NULL) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
+ _cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
return (cairo_surface_t*) &_cairo_surface_nil;
}
diff --git a/src/cairo-gstate.c b/src/cairo-gstate.c
index 4097a650..b1fc6b34 100644
--- a/src/cairo-gstate.c
+++ b/src/cairo-gstate.c
@@ -94,7 +94,7 @@ _cairo_gstate_init (cairo_gstate_t *gstate,
gstate->source = _cairo_pattern_create_solid (CAIRO_COLOR_BLACK,
CAIRO_CONTENT_COLOR);
if (gstate->source->status)
- return CAIRO_STATUS_NO_MEMORY;
+ return gstate->source->status;
return target ? target->status : CAIRO_STATUS_NULL_POINTER;
}
@@ -208,7 +208,7 @@ _cairo_gstate_clone (cairo_gstate_t *other)
gstate = malloc (sizeof (cairo_gstate_t));
if (gstate == NULL) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
+ _cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
return NULL;
}
@@ -235,10 +235,8 @@ _cairo_gstate_save (cairo_gstate_t **gstate)
cairo_gstate_t *top;
top = _cairo_gstate_clone (*gstate);
-
- if (top == NULL) {
- return CAIRO_STATUS_NO_MEMORY;
- }
+ if (top == NULL)
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
top->next = *gstate;
*gstate = top;
@@ -258,10 +256,8 @@ _cairo_gstate_restore (cairo_gstate_t **gstate)
cairo_gstate_t *top;
top = *gstate;
-
- if (top->next == NULL) {
- return CAIRO_STATUS_INVALID_RESTORE;
- }
+ if (top->next == NULL)
+ return _cairo_error (CAIRO_STATUS_INVALID_RESTORE);
*gstate = top->next;
@@ -535,8 +531,7 @@ _cairo_gstate_set_dash (cairo_gstate_t *gstate, const double *dash, int num_dash
gstate->stroke_style.dash = _cairo_malloc_ab (gstate->stroke_style.num_dashes, sizeof (double));
if (gstate->stroke_style.dash == NULL) {
gstate->stroke_style.num_dashes = 0;
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
- return CAIRO_STATUS_NO_MEMORY;
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
}
memcpy (gstate->stroke_style.dash, dash, gstate->stroke_style.num_dashes * sizeof (double));
@@ -544,12 +539,12 @@ _cairo_gstate_set_dash (cairo_gstate_t *gstate, const double *dash, int num_dash
dash_total = 0.0;
for (i = 0; i < gstate->stroke_style.num_dashes; i++) {
if (gstate->stroke_style.dash[i] < 0)
- return CAIRO_STATUS_INVALID_DASH;
+ return _cairo_error (CAIRO_STATUS_INVALID_DASH);
dash_total += gstate->stroke_style.dash[i];
}
if (dash_total == 0.0)
- return CAIRO_STATUS_INVALID_DASH;
+ return _cairo_error (CAIRO_STATUS_INVALID_DASH);
/* A single dash value indicate symmetric repeating, so the total
* is twice as long. */
@@ -626,7 +621,7 @@ _cairo_gstate_scale (cairo_gstate_t *gstate, double sx, double sy)
cairo_matrix_t tmp;
if (sx == 0 || sy == 0)
- return CAIRO_STATUS_INVALID_MATRIX;
+ return _cairo_error (CAIRO_STATUS_INVALID_MATRIX);
_cairo_gstate_unset_scaled_font (gstate);
@@ -1576,10 +1571,8 @@ _cairo_gstate_show_glyphs (cairo_gstate_t *gstate,
transformed_glyphs = stack_transformed_glyphs;
} else {
transformed_glyphs = _cairo_malloc_ab (num_glyphs, sizeof(cairo_glyph_t));
- if (transformed_glyphs == NULL) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
- return CAIRO_STATUS_NO_MEMORY;
- }
+ if (transformed_glyphs == NULL)
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
}
_cairo_gstate_transform_glyphs_to_backend (gstate, glyphs, num_glyphs,
@@ -1623,10 +1616,8 @@ _cairo_gstate_glyph_path (cairo_gstate_t *gstate,
transformed_glyphs = stack_transformed_glyphs;
else
transformed_glyphs = _cairo_malloc_ab (num_glyphs, sizeof(cairo_glyph_t));
- if (transformed_glyphs == NULL) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
- return CAIRO_STATUS_NO_MEMORY;
- }
+ if (transformed_glyphs == NULL)
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
_cairo_gstate_transform_glyphs_to_backend (gstate, glyphs, num_glyphs,
transformed_glyphs);
diff --git a/src/cairo-hash.c b/src/cairo-hash.c
index 70518600..c419e9e0 100644
--- a/src/cairo-hash.c
+++ b/src/cairo-hash.c
@@ -150,7 +150,7 @@ _cairo_hash_table_create (cairo_hash_keys_equal_func_t keys_equal)
hash_table = malloc (sizeof (cairo_hash_table_t));
if (hash_table == NULL) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
+ _cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
return NULL;
}
@@ -161,8 +161,8 @@ _cairo_hash_table_create (cairo_hash_keys_equal_func_t keys_equal)
hash_table->entries = calloc (hash_table->arrangement->size,
sizeof(cairo_hash_entry_t *));
if (hash_table->entries == NULL) {
+ _cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
free (hash_table);
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
return NULL;
}
@@ -331,10 +331,8 @@ _cairo_hash_table_resize (cairo_hash_table_t *hash_table)
new_size = tmp.arrangement->size;
tmp.entries = calloc (new_size, sizeof (cairo_hash_entry_t*));
- if (tmp.entries == NULL) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
- return CAIRO_STATUS_NO_MEMORY;
- }
+ if (tmp.entries == NULL)
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
for (i = 0; i < hash_table->arrangement->size; ++i) {
if (ENTRY_IS_LIVE (hash_table->entries[i])) {
diff --git a/src/cairo-hull.c b/src/cairo-hull.c
index f5d05e47..9eed671f 100644
--- a/src/cairo-hull.c
+++ b/src/cairo-hull.c
@@ -64,7 +64,7 @@ _cairo_hull_create (cairo_pen_vertex_t *vertices, int num_vertices)
hull = _cairo_malloc_ab (num_vertices, sizeof (cairo_hull_t));
if (hull == NULL) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
+ _cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
return NULL;
}
diff --git a/src/cairo-image-surface.c b/src/cairo-image-surface.c
index 091a9572..3331e557 100644
--- a/src/cairo-image-surface.c
+++ b/src/cairo-image-surface.c
@@ -214,7 +214,7 @@ _cairo_image_surface_create_for_pixman_image (pixman_image_t *pixman_image,
surface = malloc (sizeof (cairo_image_surface_t));
if (surface == NULL) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
+ _cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
return (cairo_surface_t*) &_cairo_surface_nil;
}
@@ -433,7 +433,7 @@ _cairo_image_surface_create_with_pixman_format (unsigned char *data,
(uint32_t *) data, stride);
if (pixman_image == NULL) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
+ _cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
return (cairo_surface_t*) &_cairo_surface_nil;
}
@@ -475,7 +475,7 @@ cairo_image_surface_create (cairo_format_t format,
pixman_format_code_t pixman_format;
if (! CAIRO_FORMAT_VALID (format)) {
- _cairo_error (CAIRO_STATUS_INVALID_FORMAT);
+ _cairo_error_throw (CAIRO_STATUS_INVALID_FORMAT);
return (cairo_surface_t*) &_cairo_image_surface_nil_invalid_format;
}
@@ -494,7 +494,7 @@ _cairo_image_surface_create_with_content (cairo_content_t content,
int height)
{
if (! CAIRO_CONTENT_VALID (content)) {
- _cairo_error (CAIRO_STATUS_INVALID_CONTENT);
+ _cairo_error_throw (CAIRO_STATUS_INVALID_CONTENT);
return (cairo_surface_t*) &_cairo_image_surface_nil_invalid_content;
}
@@ -545,7 +545,7 @@ cairo_image_surface_create_for_data (unsigned char *data,
* attempting to create such surfaces will failure but we will interpret
* such failure as CAIRO_STATUS_NO_MEMORY. */
if (! CAIRO_FORMAT_VALID (format) || stride % sizeof (uint32_t) != 0) {
- _cairo_error (CAIRO_STATUS_INVALID_FORMAT);
+ _cairo_error_throw (CAIRO_STATUS_INVALID_FORMAT);
return (cairo_surface_t*) &_cairo_image_surface_nil_invalid_format;
}
@@ -564,7 +564,7 @@ _cairo_image_surface_create_for_data_with_content (unsigned char *data,
int stride)
{
if (! CAIRO_CONTENT_VALID (content)) {
- _cairo_error (CAIRO_STATUS_INVALID_CONTENT);
+ _cairo_error_throw (CAIRO_STATUS_INVALID_CONTENT);
return (cairo_surface_t*) &_cairo_image_surface_nil_invalid_content;
}
@@ -591,7 +591,7 @@ cairo_image_surface_get_data (cairo_surface_t *surface)
cairo_image_surface_t *image_surface = (cairo_image_surface_t *) surface;
if (!_cairo_surface_is_image (surface)) {
- _cairo_error (CAIRO_STATUS_SURFACE_TYPE_MISMATCH);
+ _cairo_error_throw (CAIRO_STATUS_SURFACE_TYPE_MISMATCH);
return NULL;
}
@@ -614,7 +614,7 @@ cairo_image_surface_get_format (cairo_surface_t *surface)
cairo_image_surface_t *image_surface = (cairo_image_surface_t *) surface;
if (!_cairo_surface_is_image (surface)) {
- _cairo_error (CAIRO_STATUS_SURFACE_TYPE_MISMATCH);
+ _cairo_error_throw (CAIRO_STATUS_SURFACE_TYPE_MISMATCH);
return 0;
}
@@ -637,7 +637,7 @@ cairo_image_surface_get_width (cairo_surface_t *surface)
cairo_image_surface_t *image_surface = (cairo_image_surface_t *) surface;
if (!_cairo_surface_is_image (surface)) {
- _cairo_error (CAIRO_STATUS_SURFACE_TYPE_MISMATCH);
+ _cairo_error_throw (CAIRO_STATUS_SURFACE_TYPE_MISMATCH);
return 0;
}
@@ -659,7 +659,7 @@ cairo_image_surface_get_height (cairo_surface_t *surface)
cairo_image_surface_t *image_surface = (cairo_image_surface_t *) surface;
if (!_cairo_surface_is_image (surface)) {
- _cairo_error (CAIRO_STATUS_SURFACE_TYPE_MISMATCH);
+ _cairo_error_throw (CAIRO_STATUS_SURFACE_TYPE_MISMATCH);
return 0;
}
@@ -687,7 +687,7 @@ cairo_image_surface_get_stride (cairo_surface_t *surface)
cairo_image_surface_t *image_surface = (cairo_image_surface_t *) surface;
if (!_cairo_surface_is_image (surface)) {
- _cairo_error (CAIRO_STATUS_SURFACE_TYPE_MISMATCH);
+ _cairo_error_throw (CAIRO_STATUS_SURFACE_TYPE_MISMATCH);
return 0;
}
@@ -839,7 +839,7 @@ _cairo_image_surface_set_matrix (cairo_image_surface_t *surface,
_cairo_matrix_to_pixman_matrix (matrix, &pixman_transform);
if (!pixman_image_set_transform (surface->pixman_image, &pixman_transform))
- return CAIRO_STATUS_NO_MEMORY;
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
return CAIRO_STATUS_SUCCESS;
}
@@ -1062,10 +1062,8 @@ _cairo_image_surface_fill_rectangles (void *abstract_surface,
if (num_rects > ARRAY_LENGTH(stack_rects)) {
pixman_rects = _cairo_malloc_ab (num_rects, sizeof(pixman_rectangle16_t));
- if (pixman_rects == NULL) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
- return CAIRO_STATUS_NO_MEMORY;
- }
+ if (pixman_rects == NULL)
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
}
for (i = 0; i < num_rects; i++) {
@@ -1081,8 +1079,7 @@ _cairo_image_surface_fill_rectangles (void *abstract_surface,
&pixman_color,
num_rects,
pixman_rects)) {
- status = CAIRO_STATUS_NO_MEMORY;
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
+ status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
}
if (pixman_rects != stack_rects)
@@ -1128,10 +1125,8 @@ _cairo_image_surface_composite_trapezoids (cairo_operator_t op,
/* Convert traps to pixman traps */
if (num_traps > ARRAY_LENGTH(stack_traps)) {
pixman_traps = _cairo_malloc_ab (num_traps, sizeof(pixman_trapezoid_t));
- if (pixman_traps == NULL) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
- return CAIRO_STATUS_NO_MEMORY;
- }
+ if (pixman_traps == NULL)
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
}
for (i = 0; i < num_traps; i++) {
@@ -1206,16 +1201,14 @@ _cairo_image_surface_composite_trapezoids (cairo_operator_t op,
/* The image must be initially transparent */
mask_data = calloc (mask_stride, height);
if (mask_data == NULL) {
- status = CAIRO_STATUS_NO_MEMORY;
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
+ status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto CLEANUP_SOURCE;
}
mask = pixman_image_create_bits (format, width, height,
mask_data, mask_stride);
if (mask == NULL) {
- status = CAIRO_STATUS_NO_MEMORY;
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
+ status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto CLEANUP_IMAGE_DATA;
}
@@ -1263,7 +1256,7 @@ _cairo_image_surface_set_clip_region (void *abstract_surface,
cairo_image_surface_t *surface = (cairo_image_surface_t *) abstract_surface;
if (!pixman_image_set_clip_region (surface->pixman_image, &region->rgn))
- return CAIRO_STATUS_NO_MEMORY;
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
surface->has_clip = region != NULL;
diff --git a/src/cairo-lzw.c b/src/cairo-lzw.c
index 73d82a3e..6158eaf4 100644
--- a/src/cairo-lzw.c
+++ b/src/cairo-lzw.c
@@ -75,8 +75,7 @@ _lzw_buf_init (lzw_buf_t *buf, int size)
buf->data = malloc (size);
if (buf->data == NULL) {
buf->data_size = 0;
- buf->status = CAIRO_STATUS_NO_MEMORY;
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
+ buf->status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
return;
}
}
@@ -102,8 +101,7 @@ _lzw_buf_grow (lzw_buf_t *buf)
if (new_data == NULL) {
free (buf->data);
buf->data_size = 0;
- buf->status = CAIRO_STATUS_NO_MEMORY;
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
+ buf->status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
return buf->status;
}
diff --git a/src/cairo-matrix.c b/src/cairo-matrix.c
index 17b11ef3..cf31c5d4 100644
--- a/src/cairo-matrix.c
+++ b/src/cairo-matrix.c
@@ -473,11 +473,11 @@ cairo_matrix_invert (cairo_matrix_t *matrix)
_cairo_matrix_compute_determinant (matrix, &det);
if (det == 0)
- return CAIRO_STATUS_INVALID_MATRIX;
+ return _cairo_error (CAIRO_STATUS_INVALID_MATRIX);
/* this weird construct is for detecting NaNs */
if (! (det * det > 0.))
- return CAIRO_STATUS_INVALID_MATRIX;
+ return _cairo_error (CAIRO_STATUS_INVALID_MATRIX);
_cairo_matrix_compute_adjoint (matrix);
_cairo_matrix_scalar_multiply (matrix, 1 / det);
diff --git a/src/cairo-meta-surface.c b/src/cairo-meta-surface.c
index ac43be99..d353d2eb 100644
--- a/src/cairo-meta-surface.c
+++ b/src/cairo-meta-surface.c
@@ -85,7 +85,7 @@ _cairo_meta_surface_create (cairo_content_t content,
meta = malloc (sizeof (cairo_meta_surface_t));
if (meta == NULL) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
+ _cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
return (cairo_surface_t*) &_cairo_surface_nil;
}
@@ -252,10 +252,8 @@ _cairo_meta_surface_paint (void *abstract_surface,
cairo_command_paint_t *command;
command = malloc (sizeof (cairo_command_paint_t));
- if (command == NULL) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
- return CAIRO_STATUS_NO_MEMORY;
- }
+ if (command == NULL)
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
command->header.type = CAIRO_COMMAND_PAINT;
command->header.region = CAIRO_META_REGION_ALL;
@@ -295,10 +293,8 @@ _cairo_meta_surface_mask (void *abstract_surface,
cairo_command_mask_t *command;
command = malloc (sizeof (cairo_command_mask_t));
- if (command == NULL) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
- return CAIRO_STATUS_NO_MEMORY;
- }
+ if (command == NULL)
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
command->header.type = CAIRO_COMMAND_MASK;
command->header.region = CAIRO_META_REGION_ALL;
@@ -343,10 +339,8 @@ _cairo_meta_surface_stroke (void *abstract_surface,
cairo_command_stroke_t *command;
command = malloc (sizeof (cairo_command_stroke_t));
- if (command == NULL) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
- return CAIRO_STATUS_NO_MEMORY;
- }
+ if (command == NULL)
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
command->header.type = CAIRO_COMMAND_STROKE;
command->header.region = CAIRO_META_REGION_ALL;
@@ -400,10 +394,8 @@ _cairo_meta_surface_fill (void *abstract_surface,
cairo_command_fill_t *command;
command = malloc (sizeof (cairo_command_fill_t));
- if (command == NULL) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
- return CAIRO_STATUS_NO_MEMORY;
- }
+ if (command == NULL)
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
command->header.type = CAIRO_COMMAND_FILL;
command->header.region = CAIRO_META_REGION_ALL;
@@ -449,10 +441,8 @@ _cairo_meta_surface_show_glyphs (void *abstract_surface,
cairo_command_show_glyphs_t *command;
command = malloc (sizeof (cairo_command_show_glyphs_t));
- if (command == NULL) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
- return CAIRO_STATUS_NO_MEMORY;
- }
+ if (command == NULL)
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
command->header.type = CAIRO_COMMAND_SHOW_GLYPHS;
command->header.region = CAIRO_META_REGION_ALL;
@@ -464,7 +454,7 @@ _cairo_meta_surface_show_glyphs (void *abstract_surface,
command->glyphs = _cairo_malloc_ab (num_glyphs, sizeof (cairo_glyph_t));
if (command->glyphs == NULL) {
- status = CAIRO_STATUS_NO_MEMORY;
+ status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto CLEANUP_SOURCE;
}
memcpy (command->glyphs, glyphs, sizeof (cairo_glyph_t) * num_glyphs);
@@ -486,8 +476,7 @@ _cairo_meta_surface_show_glyphs (void *abstract_surface,
_cairo_pattern_fini (&command->source.base);
CLEANUP_COMMAND:
free (command);
- _cairo_error (status);
- return status;
+ return _cairo_error (status);
}
/**
@@ -511,7 +500,7 @@ _cairo_meta_surface_snapshot (void *abstract_other)
meta = malloc (sizeof (cairo_meta_surface_t));
if (meta == NULL) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
+ _cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
return (cairo_surface_t*) &_cairo_surface_nil;
}
@@ -542,10 +531,8 @@ _cairo_meta_surface_intersect_clip_path (void *dst,
cairo_status_t status;
command = malloc (sizeof (cairo_command_intersect_clip_path_t));
- if (command == NULL) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
- return CAIRO_STATUS_NO_MEMORY;
- }
+ if (command == NULL)
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
command->header.type = CAIRO_COMMAND_INTERSECT_CLIP_PATH;
command->header.region = CAIRO_META_REGION_ALL;
@@ -811,8 +798,7 @@ _cairo_meta_surface_replay_internal (cairo_surface_t *surface,
if (has_device_transform) {
dev_glyphs = _cairo_malloc_ab (num_glyphs, sizeof (cairo_glyph_t));
if (dev_glyphs == NULL) {
- status = CAIRO_STATUS_NO_MEMORY;
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
+ status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
break;
}
for (i = 0; i < num_glyphs; i++) {
diff --git a/src/cairo-os2-surface.c b/src/cairo-os2-surface.c
index b4488874..0d888ed3 100644
--- a/src/cairo-os2-surface.c
+++ b/src/cairo-os2-surface.c
@@ -473,7 +473,7 @@ _cairo_os2_surface_acquire_source_image (void *abstract_surfac
(local_os2_surface->base.backend != &cairo_os2_surface_backend))
{
/* Invalid parameter (wrong surface)! */
- return CAIRO_STATUS_SURFACE_TYPE_MISMATCH;
+ return _cairo_error (CAIRO_STATUS_SURFACE_TYPE_MISMATCH);
}
DosRequestMutexSem (local_os2_surface->hmtx_use_private_fields, SEM_INDEFINITE_WAIT);
@@ -529,7 +529,7 @@ _cairo_os2_surface_acquire_dest_image (void *abstract_surfac
(local_os2_surface->base.backend != &cairo_os2_surface_backend))
{
/* Invalid parameter (wrong surface)! */
- return CAIRO_STATUS_SURFACE_TYPE_MISMATCH;
+ return _cairo_error (CAIRO_STATUS_SURFACE_TYPE_MISMATCH);
}
DosRequestMutexSem (local_os2_surface->hmtx_use_private_fields, SEM_INDEFINITE_WAIT);
@@ -637,7 +637,7 @@ _cairo_os2_surface_get_extents (void *abstract_surface,
(local_os2_surface->base.backend != &cairo_os2_surface_backend))
{
/* Invalid parameter (wrong surface)! */
- return CAIRO_STATUS_SURFACE_TYPE_MISMATCH;
+ return _cairo_error (CAIRO_STATUS_SURFACE_TYPE_MISMATCH);
}
rectangle->x = 0;
@@ -773,14 +773,14 @@ cairo_os2_surface_set_size (cairo_surface_t *surface,
(local_os2_surface->base.backend != &cairo_os2_surface_backend))
{
/* Invalid parameter (wrong surface)! */
- return CAIRO_STATUS_SURFACE_TYPE_MISMATCH;
+ return _cairo_error (CAIRO_STATUS_SURFACE_TYPE_MISMATCH);
}
if ((new_width <= 0) ||
(new_height <= 0))
{
/* Invalid size! */
- return CAIRO_STATUS_NO_MEMORY;
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
}
/* Allocate memory for new stuffs */
@@ -789,7 +789,7 @@ cairo_os2_surface_set_size (cairo_surface_t *surface,
/* Not enough memory for the pixels!
* Everything remains the same!
*/
- return CAIRO_STATUS_NO_MEMORY;
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
}
/* This is possibly not needed, malloc'd space is usually
@@ -812,7 +812,7 @@ cairo_os2_surface_set_size (cairo_surface_t *surface,
* Everything remains the same!
*/
free (pchNewPixels);
- return CAIRO_STATUS_NO_MEMORY;
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
}
/* Okay, new memory allocated, so it's time to swap old buffers
@@ -824,7 +824,7 @@ cairo_os2_surface_set_size (cairo_surface_t *surface,
*/
cairo_surface_destroy ((cairo_surface_t *) pNewImageSurface);
free (pchNewPixels);
- return CAIRO_STATUS_NO_MEMORY;
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
}
/* We have to make sure that we won't destroy a surface which
@@ -840,7 +840,7 @@ cairo_os2_surface_set_size (cairo_surface_t *surface,
/* Either timeout or something wrong... Exit. */
cairo_surface_destroy ((cairo_surface_t *) pNewImageSurface);
free (pchNewPixels);
- return CAIRO_STATUS_NO_MEMORY;
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
}
/* Okay, grab mutex and check counter again! */
if (DosRequestMutexSem (local_os2_surface->hmtx_use_private_fields, SEM_INDEFINITE_WAIT)
@@ -851,7 +851,7 @@ cairo_os2_surface_set_size (cairo_surface_t *surface,
*/
cairo_surface_destroy ((cairo_surface_t *) pNewImageSurface);
free (pchNewPixels);
- return CAIRO_STATUS_NO_MEMORY;
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
}
}
@@ -949,7 +949,7 @@ _cairo_os2_surface_finish (void *abstract_surface)
(local_os2_surface->base.backend != &cairo_os2_surface_backend))
{
/* Invalid parameter (wrong surface)! */
- return CAIRO_STATUS_SURFACE_TYPE_MISMATCH;
+ return _cairo_error (CAIRO_STATUS_SURFACE_TYPE_MISMATCH);
}
DosRequestMutexSem (local_os2_surface->hmtx_use_private_fields, SEM_INDEFINITE_WAIT);
@@ -1042,7 +1042,7 @@ _cairo_os2_surface_mark_dirty_rectangle (void *surface,
(local_os2_surface->base.backend != &cairo_os2_surface_backend))
{
/* Invalid parameter (wrong surface)! */
- return CAIRO_STATUS_SURFACE_TYPE_MISMATCH;
+ return _cairo_error (CAIRO_STATUS_SURFACE_TYPE_MISMATCH);
}
/* Get mutex, we'll work with the pixel array! */
diff --git a/src/cairo-output-stream.c b/src/cairo-output-stream.c
index a0add6d7..791c0f22 100644
--- a/src/cairo-output-stream.c
+++ b/src/cairo-output-stream.c
@@ -120,7 +120,7 @@ _cairo_output_stream_create (cairo_write_func_t write_func,
stream = malloc (sizeof (cairo_output_stream_with_closure_t));
if (stream == NULL) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
+ _cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
return (cairo_output_stream_t *) &_cairo_output_stream_nil;
}
@@ -164,7 +164,7 @@ _cairo_output_stream_destroy (cairo_output_stream_t *stream)
cairo_status_t status;
if (stream == NULL)
- return CAIRO_STATUS_NULL_POINTER;
+ return _cairo_error (CAIRO_STATUS_NULL_POINTER);
status = _cairo_output_stream_fini (stream);
free (stream);
@@ -434,7 +434,7 @@ stdio_write (cairo_output_stream_t *base,
stdio_stream_t *stream = (stdio_stream_t *) base;
if (fwrite (data, 1, length, stream->file) != length)
- return CAIRO_STATUS_WRITE_ERROR;
+ return _cairo_error (CAIRO_STATUS_WRITE_ERROR);
return CAIRO_STATUS_SUCCESS;
}
@@ -447,7 +447,7 @@ stdio_flush (cairo_output_stream_t *base)
fflush (stream->file);
if (ferror (stream->file))
- return CAIRO_STATUS_WRITE_ERROR;
+ return _cairo_error (CAIRO_STATUS_WRITE_ERROR);
else
return CAIRO_STATUS_SUCCESS;
}
@@ -471,13 +471,13 @@ _cairo_output_stream_create_for_file (FILE *file)
stdio_stream_t *stream;
if (file == NULL) {
- _cairo_error (CAIRO_STATUS_WRITE_ERROR);
+ _cairo_error_throw (CAIRO_STATUS_WRITE_ERROR);
return (cairo_output_stream_t *) &_cairo_output_stream_nil_write_error;
}
stream = malloc (sizeof *stream);
if (stream == NULL) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
+ _cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
return (cairo_output_stream_t *) &_cairo_output_stream_nil;
}
@@ -495,14 +495,14 @@ _cairo_output_stream_create_for_filename (const char *filename)
file = fopen (filename, "wb");
if (file == NULL) {
- _cairo_error (CAIRO_STATUS_WRITE_ERROR);
+ _cairo_error_throw (CAIRO_STATUS_WRITE_ERROR);
return (cairo_output_stream_t *) &_cairo_output_stream_nil_write_error;
}
stream = malloc (sizeof *stream);
if (stream == NULL) {
fclose (file);
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
+ _cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
return (cairo_output_stream_t *) &_cairo_output_stream_nil;
}
@@ -544,7 +544,7 @@ _cairo_memory_stream_create (void)
stream = malloc (sizeof *stream);
if (stream == NULL) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
+ _cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
return (cairo_output_stream_t *) &_cairo_output_stream_nil;
}
diff --git a/src/cairo-paginated-surface.c b/src/cairo-paginated-surface.c
index 76eb6616..d7f02f3d 100644
--- a/src/cairo-paginated-surface.c
+++ b/src/cairo-paginated-surface.c
@@ -76,10 +76,8 @@ _cairo_paginated_surface_create (cairo_surface_t *target,
cairo_paginated_surface_t *surface;
surface = malloc (sizeof (cairo_paginated_surface_t));
- if (surface == NULL) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
+ if (surface == NULL)
goto FAIL;
- }
_cairo_surface_init (&surface->base, &cairo_paginated_surface_backend,
content);
@@ -108,7 +106,7 @@ _cairo_paginated_surface_create (cairo_surface_t *target,
FAIL_CLEANUP_SURFACE:
free (surface);
FAIL:
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
+ _cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
return (cairo_surface_t*) &_cairo_surface_nil;
}
@@ -289,7 +287,7 @@ _paint_page (cairo_paginated_surface_t *surface)
analysis = _cairo_analysis_surface_create (surface->target,
surface->width, surface->height);
if (analysis == NULL)
- return CAIRO_STATUS_NO_MEMORY;
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
surface->backend->set_paginated_mode (surface->target, CAIRO_PAGINATED_MODE_ANALYZE);
status = _cairo_meta_surface_replay_and_create_regions (surface->meta, analysis);
diff --git a/src/cairo-path-fixed.c b/src/cairo-path-fixed.c
index 56b1df2d..1ed674ea 100644
--- a/src/cairo-path-fixed.c
+++ b/src/cairo-path-fixed.c
@@ -108,7 +108,7 @@ _cairo_path_fixed_init_copy (cairo_path_fixed_t *path,
buf = _cairo_path_buf_create ();
if (buf == NULL) {
_cairo_path_fixed_fini (path);
- return CAIRO_STATUS_NO_MEMORY;
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
}
memcpy (buf, other_buf, sizeof (cairo_path_buf_t));
_cairo_path_fixed_add_buf (path, buf);
@@ -124,7 +124,7 @@ _cairo_path_fixed_create (void)
path = malloc (sizeof (cairo_path_fixed_t));
if (!path) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
+ _cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
return NULL;
}
@@ -206,7 +206,7 @@ _cairo_path_fixed_rel_move_to (cairo_path_fixed_t *path,
cairo_fixed_t x, y;
if (! path->has_current_point)
- return CAIRO_STATUS_NO_CURRENT_POINT;
+ return _cairo_error (CAIRO_STATUS_NO_CURRENT_POINT);
x = path->current_point.x + dx;
y = path->current_point.y + dy;
@@ -252,7 +252,7 @@ _cairo_path_fixed_rel_line_to (cairo_path_fixed_t *path,
cairo_fixed_t x, y;
if (! path->has_current_point)
- return CAIRO_STATUS_NO_CURRENT_POINT;
+ return _cairo_error (CAIRO_STATUS_NO_CURRENT_POINT);
x = path->current_point.x + dx;
y = path->current_point.y + dy;
@@ -302,7 +302,7 @@ _cairo_path_fixed_rel_curve_to (cairo_path_fixed_t *path,
cairo_fixed_t x2, y2;
if (! path->has_current_point)
- return CAIRO_STATUS_NO_CURRENT_POINT;
+ return _cairo_error (CAIRO_STATUS_NO_CURRENT_POINT);
x0 = path->current_point.x + dx0;
y0 = path->current_point.y + dy0;
@@ -346,7 +346,7 @@ _cairo_path_fixed_get_current_point (cairo_path_fixed_t *path,
cairo_fixed_t *y)
{
if (! path->has_current_point)
- return CAIRO_STATUS_NO_CURRENT_POINT;
+ return _cairo_error (CAIRO_STATUS_NO_CURRENT_POINT);
*x = path->current_point.x;
*y = path->current_point.y;
@@ -367,7 +367,7 @@ _cairo_path_fixed_add (cairo_path_fixed_t *path,
buf = _cairo_path_buf_create ();
if (buf == NULL)
- return CAIRO_STATUS_NO_MEMORY;
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
_cairo_path_fixed_add_buf (path, buf);
}
diff --git a/src/cairo-path-stroke.c b/src/cairo-path-stroke.c
index 0a295baf..ce523b06 100644
--- a/src/cairo-path-stroke.c
+++ b/src/cairo-path-stroke.c
@@ -1066,10 +1066,8 @@ _cairo_rectilinear_stroker_add_segment (cairo_rectilinear_stroker_t *stroker,
new_size = 4;
new_segments = _cairo_realloc_ab (stroker->segments,
new_size, sizeof (cairo_line_t));
- if (new_segments == NULL) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
- return CAIRO_STATUS_NO_MEMORY;
- }
+ if (new_segments == NULL)
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
stroker->segments_size = new_size;
stroker->segments = new_segments;
diff --git a/src/cairo-path.c b/src/cairo-path.c
index b1ef44e2..90b726dc 100644
--- a/src/cairo-path.c
+++ b/src/cairo-path.c
@@ -353,7 +353,7 @@ _cairo_path_create_in_error (cairo_status_t status)
path = malloc (sizeof (cairo_path_t));
if (path == NULL) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
+ _cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
return (cairo_path_t*) &_cairo_path_nil;
}
@@ -373,7 +373,7 @@ _cairo_path_create_internal (cairo_path_fixed_t *path_fixed,
path = malloc (sizeof (cairo_path_t));
if (path == NULL) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
+ _cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
return (cairo_path_t*) &_cairo_path_nil;
}
@@ -390,7 +390,7 @@ _cairo_path_create_internal (cairo_path_fixed_t *path_fixed,
sizeof (cairo_path_data_t));
if (path->data == NULL) {
free (path);
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
+ _cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
return (cairo_path_t*) &_cairo_path_nil;
}
@@ -496,19 +496,19 @@ _cairo_path_append_to_context (const cairo_path_t *path,
switch (p->header.type) {
case CAIRO_PATH_MOVE_TO:
if (p->header.length < 2)
- return CAIRO_STATUS_INVALID_PATH_DATA;
+ return _cairo_error (CAIRO_STATUS_INVALID_PATH_DATA);
cairo_move_to (cr,
p[1].point.x, p[1].point.y);
break;
case CAIRO_PATH_LINE_TO:
if (p->header.length < 2)
- return CAIRO_STATUS_INVALID_PATH_DATA;
+ return _cairo_error (CAIRO_STATUS_INVALID_PATH_DATA);
cairo_line_to (cr,
p[1].point.x, p[1].point.y);
break;
case CAIRO_PATH_CURVE_TO:
if (p->header.length < 4)
- return CAIRO_STATUS_INVALID_PATH_DATA;
+ return _cairo_error (CAIRO_STATUS_INVALID_PATH_DATA);
cairo_curve_to (cr,
p[1].point.x, p[1].point.y,
p[2].point.x, p[2].point.y,
@@ -516,11 +516,11 @@ _cairo_path_append_to_context (const cairo_path_t *path,
break;
case CAIRO_PATH_CLOSE_PATH:
if (p->header.length < 1)
- return CAIRO_STATUS_INVALID_PATH_DATA;
+ return _cairo_error (CAIRO_STATUS_INVALID_PATH_DATA);
cairo_close_path (cr);
break;
default:
- return CAIRO_STATUS_INVALID_PATH_DATA;
+ return _cairo_error (CAIRO_STATUS_INVALID_PATH_DATA);
}
status = cairo_status (cr);
diff --git a/src/cairo-pattern.c b/src/cairo-pattern.c
index a7e804e6..6eea9a61 100644
--- a/src/cairo-pattern.c
+++ b/src/cairo-pattern.c
@@ -77,7 +77,7 @@ const cairo_solid_pattern_t cairo_pattern_none = {
* breakpoint in _cairo_error() to generate a stack trace for when the
* user causes cairo to detect an error.
**/
-static void
+static cairo_status_t
_cairo_pattern_set_error (cairo_pattern_t *pattern,
cairo_status_t status)
{
@@ -85,7 +85,7 @@ _cairo_pattern_set_error (cairo_pattern_t *pattern,
* error, which is the most significant. */
_cairo_status_set_error (&pattern->status, status);
- _cairo_error (status);
+ return _cairo_error (status);
}
static void
@@ -137,8 +137,7 @@ _cairo_gradient_pattern_init_copy (cairo_gradient_pattern_t *pattern,
if (pattern->stops == NULL) {
pattern->stops_size = 0;
pattern->n_stops = 0;
- _cairo_pattern_set_error (&pattern->base, CAIRO_STATUS_NO_MEMORY);
- return CAIRO_STATUS_NO_MEMORY;
+ return _cairo_pattern_set_error (&pattern->base, CAIRO_STATUS_NO_MEMORY);
}
memcpy (pattern->stops, other->stops,
@@ -152,10 +151,8 @@ cairo_status_t
_cairo_pattern_init_copy (cairo_pattern_t *pattern,
const cairo_pattern_t *other)
{
- if (other->status) {
- _cairo_pattern_set_error (pattern, other->status);
- return other->status;
- }
+ if (other->status)
+ return _cairo_pattern_set_error (pattern, other->status);
switch (other->type) {
case CAIRO_PATTERN_TYPE_SOLID: {
@@ -345,7 +342,7 @@ _cairo_pattern_create_in_error (cairo_status_t status)
pattern = _cairo_pattern_create_solid (_cairo_stock_color (CAIRO_STOCK_BLACK),
CAIRO_CONTENT_COLOR);
if (pattern->status == CAIRO_STATUS_SUCCESS)
- _cairo_pattern_set_error (pattern, status);
+ status = _cairo_pattern_set_error (pattern, status);
return pattern;
}
@@ -385,7 +382,7 @@ cairo_pattern_create_rgb (double red, double green, double blue)
pattern = _cairo_pattern_create_solid (&color,
CAIRO_CONTENT_COLOR);
if (pattern->status)
- _cairo_error (pattern->status);
+ _cairo_error_throw (pattern->status);
return pattern;
}
@@ -429,7 +426,7 @@ cairo_pattern_create_rgba (double red, double green, double blue,
pattern = _cairo_pattern_create_solid (&color,
CAIRO_CONTENT_COLOR_ALPHA);
if (pattern->status)
- _cairo_error (pattern->status);
+ _cairo_error_throw (pattern->status);
return pattern;
}
@@ -463,7 +460,7 @@ cairo_pattern_create_for_surface (cairo_surface_t *surface)
pattern = malloc (sizeof (cairo_surface_pattern_t));
if (pattern == NULL) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
+ _cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
return (cairo_pattern_t *)&_cairo_pattern_nil.base;
}
@@ -506,7 +503,7 @@ cairo_pattern_create_linear (double x0, double y0, double x1, double y1)
pattern = malloc (sizeof (cairo_linear_pattern_t));
if (pattern == NULL) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
+ _cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
return (cairo_pattern_t *) &_cairo_pattern_nil.base;
}
@@ -551,7 +548,7 @@ cairo_pattern_create_radial (double cx0, double cy0, double radius0,
pattern = malloc (sizeof (cairo_radial_pattern_t));
if (pattern == NULL) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
+ _cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
return (cairo_pattern_t *) &_cairo_pattern_nil.base;
}
@@ -734,7 +731,7 @@ cairo_pattern_set_user_data (cairo_pattern_t *pattern,
cairo_destroy_func_t destroy)
{
if (CAIRO_REFERENCE_COUNT_IS_INVALID (&pattern->ref_count))
- return CAIRO_STATUS_NO_MEMORY;
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
return _cairo_user_data_array_set_data (&pattern->user_data,
key, user_data, destroy);
@@ -769,10 +766,8 @@ _cairo_pattern_gradient_grow (cairo_gradient_pattern_t *pattern)
sizeof (cairo_gradient_stop_t));
}
- if (new_stops == NULL) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
- return CAIRO_STATUS_NO_MEMORY;
- }
+ if (new_stops == NULL)
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
pattern->stops = new_stops;
pattern->stops_size = new_size;
@@ -795,7 +790,7 @@ _cairo_pattern_add_color_stop (cairo_gradient_pattern_t *pattern,
if (pattern->n_stops >= pattern->stops_size) {
cairo_status_t status = _cairo_pattern_gradient_grow (pattern);
if (status) {
- _cairo_pattern_set_error (&pattern->base, CAIRO_STATUS_NO_MEMORY);
+ status = _cairo_pattern_set_error (&pattern->base, status);
return;
}
}
@@ -984,7 +979,7 @@ cairo_pattern_set_matrix (cairo_pattern_t *pattern,
inverse = *matrix;
status = cairo_matrix_invert (&inverse);
if (status)
- _cairo_pattern_set_error (pattern, status);
+ status = _cairo_pattern_set_error (pattern, status);
}
slim_hidden_def (cairo_pattern_set_matrix);
@@ -1160,10 +1155,8 @@ _cairo_pattern_acquire_surface_for_gradient (cairo_gradient_pattern_t *pattern,
if (pattern->n_stops > ARRAY_LENGTH(pixman_stops_static)) {
pixman_stops = _cairo_malloc_ab (pattern->n_stops, sizeof(pixman_gradient_stop_t));
- if (pixman_stops == NULL) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
- return CAIRO_STATUS_NO_MEMORY;
- }
+ if (pixman_stops == NULL)
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
}
for (i = 0; i < pattern->n_stops; i++) {
@@ -1212,7 +1205,7 @@ _cairo_pattern_acquire_surface_for_gradient (cairo_gradient_pattern_t *pattern,
free (pixman_stops);
if (pixman_image == NULL)
- return CAIRO_STATUS_NO_MEMORY;
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
if (_cairo_surface_is_image (dst))
{
@@ -1222,7 +1215,7 @@ _cairo_pattern_acquire_surface_for_gradient (cairo_gradient_pattern_t *pattern,
if (image->base.status)
{
pixman_image_unref (pixman_image);
- return CAIRO_STATUS_NO_MEMORY;
+ return image->base.status;
}
attr->x_offset = attr->y_offset = 0;
@@ -1264,7 +1257,7 @@ _cairo_pattern_acquire_surface_for_gradient (cairo_gradient_pattern_t *pattern,
cairo_image_surface_create (CAIRO_FORMAT_ARGB32, width, height);
if (image->base.status) {
pixman_image_unref (pixman_image);
- return CAIRO_STATUS_NO_MEMORY;
+ return image->base.status;
}
pixman_image_set_filter (pixman_image, PIXMAN_FILTER_BILINEAR, NULL, 0);
@@ -1273,7 +1266,7 @@ _cairo_pattern_acquire_surface_for_gradient (cairo_gradient_pattern_t *pattern,
if (!pixman_image_set_transform (pixman_image, &pixman_transform)) {
cairo_surface_destroy (&image->base);
pixman_image_unref (pixman_image);
- return CAIRO_STATUS_NO_MEMORY;
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
}
switch (pattern->base.extend) {
@@ -2030,7 +2023,7 @@ cairo_pattern_get_rgba (cairo_pattern_t *pattern,
double r0, g0, b0, a0;
if (pattern->type != CAIRO_PATTERN_TYPE_SOLID)
- return CAIRO_STATUS_PATTERN_TYPE_MISMATCH;
+ return _cairo_error (CAIRO_STATUS_PATTERN_TYPE_MISMATCH);
_cairo_color_get_rgba (&solid->color, &r0, &g0, &b0, &a0);
@@ -2068,7 +2061,7 @@ cairo_pattern_get_surface (cairo_pattern_t *pattern,
cairo_surface_pattern_t *spat = (cairo_surface_pattern_t*) pattern;
if (pattern->type != CAIRO_PATTERN_TYPE_SURFACE)
- return CAIRO_STATUS_PATTERN_TYPE_MISMATCH;
+ return _cairo_error (CAIRO_STATUS_PATTERN_TYPE_MISMATCH);
if (surface)
*surface = spat->surface;
@@ -2107,10 +2100,10 @@ cairo_pattern_get_color_stop_rgba (cairo_pattern_t *pattern,
if (pattern->type != CAIRO_PATTERN_TYPE_LINEAR &&
pattern->type != CAIRO_PATTERN_TYPE_RADIAL)
- return CAIRO_STATUS_PATTERN_TYPE_MISMATCH;
+ return _cairo_error (CAIRO_STATUS_PATTERN_TYPE_MISMATCH);
if (index < 0 || (unsigned int) index >= gradient->n_stops)
- return CAIRO_STATUS_INVALID_INDEX;
+ return _cairo_error (CAIRO_STATUS_INVALID_INDEX);
if (offset)
*offset = _cairo_fixed_to_double(gradient->stops[index].x);
@@ -2148,7 +2141,7 @@ cairo_pattern_get_color_stop_count (cairo_pattern_t *pattern,
if (pattern->type != CAIRO_PATTERN_TYPE_LINEAR &&
pattern->type != CAIRO_PATTERN_TYPE_RADIAL)
- return CAIRO_STATUS_PATTERN_TYPE_MISMATCH;
+ return _cairo_error (CAIRO_STATUS_PATTERN_TYPE_MISMATCH);
if (count)
*count = gradient->n_stops;
@@ -2180,7 +2173,7 @@ cairo_pattern_get_linear_points (cairo_pattern_t *pattern,
cairo_linear_pattern_t *linear = (cairo_linear_pattern_t*) pattern;
if (pattern->type != CAIRO_PATTERN_TYPE_LINEAR)
- return CAIRO_STATUS_PATTERN_TYPE_MISMATCH;
+ return _cairo_error (CAIRO_STATUS_PATTERN_TYPE_MISMATCH);
if (x0)
*x0 = _cairo_fixed_to_double (linear->p1.x);
@@ -2221,7 +2214,7 @@ cairo_pattern_get_radial_circles (cairo_pattern_t *pattern,
cairo_radial_pattern_t *radial = (cairo_radial_pattern_t*) pattern;
if (pattern->type != CAIRO_PATTERN_TYPE_RADIAL)
- return CAIRO_STATUS_PATTERN_TYPE_MISMATCH;
+ return _cairo_error (CAIRO_STATUS_PATTERN_TYPE_MISMATCH);
if (x0)
*x0 = _cairo_fixed_to_double (radial->c1.x);
diff --git a/src/cairo-pdf-surface.c b/src/cairo-pdf-surface.c
index 043d8f4c..3a5b637d 100644
--- a/src/cairo-pdf-surface.c
+++ b/src/cairo-pdf-surface.c
@@ -305,7 +305,7 @@ _cairo_pdf_surface_create_for_stream_internal (cairo_output_stream_t *output,
surface = malloc (sizeof (cairo_pdf_surface_t));
if (surface == NULL) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
+ _cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
return (cairo_surface_t*) &_cairo_surface_nil;
}
@@ -331,7 +331,7 @@ _cairo_pdf_surface_create_for_stream_internal (cairo_output_stream_t *output,
surface->font_subsets = _cairo_scaled_font_subsets_create_composite ();
if (! surface->font_subsets) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
+ _cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
goto fail;
}
@@ -403,10 +403,8 @@ cairo_pdf_surface_create_for_stream (cairo_write_func_t write_func,
output = _cairo_output_stream_create (write_func, NULL, closure);
status = _cairo_output_stream_get_status (output);
- if (status) {
- _cairo_error (status);
+ if (status)
return (cairo_surface_t*) &_cairo_surface_nil;
- }
return _cairo_pdf_surface_create_for_stream_internal (output,
width_in_points,
@@ -442,12 +440,10 @@ cairo_pdf_surface_create (const char *filename,
output = _cairo_output_stream_create_for_filename (filename);
status = _cairo_output_stream_get_status (output);
- if (status) {
- _cairo_error (status);
+ if (status)
return (status == CAIRO_STATUS_WRITE_ERROR) ?
(cairo_surface_t*) &_cairo_surface_nil_write_error :
(cairo_surface_t*) &_cairo_surface_nil;
- }
return _cairo_pdf_surface_create_for_stream_internal (output,
width_in_points,
@@ -471,12 +467,12 @@ _extract_pdf_surface (cairo_surface_t *surface,
cairo_surface_t *target;
if (! _cairo_surface_is_paginated (surface))
- return CAIRO_STATUS_SURFACE_TYPE_MISMATCH;
+ return _cairo_error (CAIRO_STATUS_SURFACE_TYPE_MISMATCH);
target = _cairo_paginated_surface_get_target (surface);
if (! _cairo_surface_is_pdf (target))
- return CAIRO_STATUS_SURFACE_TYPE_MISMATCH;
+ return _cairo_error (CAIRO_STATUS_SURFACE_TYPE_MISMATCH);
*pdf_surface = (cairo_pdf_surface_t *) target;
@@ -505,12 +501,12 @@ cairo_pdf_surface_set_size (cairo_surface_t *surface,
double width_in_points,
double height_in_points)
{
- cairo_pdf_surface_t *pdf_surface;
+ cairo_pdf_surface_t *pdf_surface = NULL; /* hide compiler warning */
cairo_status_t status;
status = _extract_pdf_surface (surface, &pdf_surface);
if (status) {
- _cairo_surface_set_error (surface, CAIRO_STATUS_SURFACE_TYPE_MISMATCH);
+ status = _cairo_surface_set_error (surface, status);
return;
}
@@ -521,7 +517,7 @@ cairo_pdf_surface_set_size (cairo_surface_t *surface,
width_in_points,
height_in_points);
if (status)
- _cairo_surface_set_error (surface, status);
+ status = _cairo_surface_set_error (surface, status);
}
static void
@@ -1182,7 +1178,7 @@ compress_dup (const void *data, unsigned long data_size,
*compressed_size = data_size + (data_size >> 12) + (data_size >> 14) + 11;
compressed = malloc (*compressed_size);
if (compressed == NULL) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
+ _cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
return NULL;
}
@@ -1221,8 +1217,7 @@ _cairo_pdf_surface_emit_smask (cairo_pdf_surface_t *surface,
alpha_size = image->height * image->width;
alpha = malloc (alpha_size);
if (alpha == NULL) {
- status = CAIRO_STATUS_NO_MEMORY;
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
+ status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto CLEANUP;
}
@@ -1258,7 +1253,7 @@ _cairo_pdf_surface_emit_smask (cairo_pdf_surface_t *surface,
alpha_compressed = compress_dup (alpha, alpha_size, &alpha_compressed_size);
if (alpha_compressed == NULL) {
- status = CAIRO_STATUS_NO_MEMORY;
+ status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto CLEANUP_ALPHA;
}
@@ -1315,8 +1310,7 @@ _cairo_pdf_surface_emit_image (cairo_pdf_surface_t *surface,
rgb_size = image->height * image->width * 3;
rgb = malloc (rgb_size);
if (rgb == NULL) {
- status = CAIRO_STATUS_NO_MEMORY;
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
+ status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto CLEANUP;
}
@@ -1356,7 +1350,7 @@ _cairo_pdf_surface_emit_image (cairo_pdf_surface_t *surface,
compressed = compress_dup (rgb, rgb_size, &compressed_size);
if (compressed == NULL) {
- status = CAIRO_STATUS_NO_MEMORY;
+ status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto CLEANUP_RGB;
}
@@ -1888,10 +1882,8 @@ _cairo_pdf_surface_emit_pattern_stops (cairo_pdf_surface_t *surface,
alpha_function->id = 0;
allstops = _cairo_malloc_ab ((pattern->n_stops + 2), sizeof (cairo_pdf_color_stop_t));
- if (allstops == NULL) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
- return CAIRO_STATUS_NO_MEMORY;
- }
+ if (allstops == NULL)
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
stops = &allstops[1];
n_stops = pattern->n_stops;
@@ -2303,7 +2295,7 @@ _cairo_pdf_surface_emit_pattern (cairo_pdf_surface_t *surface, cairo_pattern_t *
}
ASSERT_NOT_REACHED;
- return CAIRO_STATUS_PATTERN_TYPE_MISMATCH;
+ return _cairo_error (CAIRO_STATUS_PATTERN_TYPE_MISMATCH);
}
static cairo_status_t
@@ -2498,7 +2490,8 @@ _cairo_pdf_surface_add_clip (cairo_pdf_surface_t *surface,
} else {
elem.clip_path = _cairo_path_fixed_create ();
if (elem.clip_path == NULL)
- return CAIRO_STATUS_NO_MEMORY;
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
+
status = _cairo_path_fixed_init_copy (elem.clip_path, path);
if (status)
return status;
@@ -2694,7 +2687,7 @@ _cairo_pdf_surface_emit_cff_font (cairo_pdf_surface_t *surface,
compressed = compress_dup (subset->data, subset->data_length, &compressed_length);
if (compressed == NULL)
- return CAIRO_STATUS_NO_MEMORY;
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
stream = _cairo_pdf_surface_new_object (surface);
_cairo_output_stream_printf (surface->output,
@@ -2858,7 +2851,7 @@ _cairo_pdf_surface_emit_type1_font (cairo_pdf_surface_t *surface,
length = subset->header_length + subset->data_length;
compressed = compress_dup (subset->data, length, &compressed_length);
if (compressed == NULL)
- return CAIRO_STATUS_NO_MEMORY;
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
stream = _cairo_pdf_surface_new_object (surface);
_cairo_output_stream_printf (surface->output,
@@ -3015,7 +3008,7 @@ _cairo_pdf_surface_emit_truetype_font_subset (cairo_pdf_surface_t *surface,
&compressed_length);
if (compressed == NULL) {
_cairo_truetype_subset_fini (&subset);
- return CAIRO_STATUS_NO_MEMORY;
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
}
stream = _cairo_pdf_surface_new_object (surface);
@@ -3280,7 +3273,7 @@ _cairo_pdf_surface_emit_glyph (cairo_pdf_surface_t *surface,
width);
if (status)
- _cairo_surface_set_error (&surface->base, status);
+ status = _cairo_surface_set_error (&surface->base, status);
}
static cairo_status_t
@@ -3297,16 +3290,13 @@ _cairo_pdf_surface_emit_type3_font_subset (cairo_pdf_surface_t *surface,
cairo_box_t bbox = {{0,0},{0,0}};
glyphs = _cairo_malloc_ab (font_subset->num_glyphs, sizeof (cairo_pdf_resource_t));
- if (glyphs == NULL) {
- _cairo_surface_set_error (&surface->base, CAIRO_STATUS_NO_MEMORY);
- return CAIRO_STATUS_NO_MEMORY;
- }
+ if (glyphs == NULL)
+ return _cairo_surface_set_error (&surface->base, CAIRO_STATUS_NO_MEMORY);
widths = _cairo_malloc_ab (font_subset->num_glyphs, sizeof (double));
if (widths == NULL) {
free (glyphs);
- _cairo_surface_set_error (&surface->base, CAIRO_STATUS_NO_MEMORY);
- return CAIRO_STATUS_NO_MEMORY;
+ return _cairo_surface_set_error (&surface->base, CAIRO_STATUS_NO_MEMORY);
}
for (i = 0; i < font_subset->num_glyphs; i++) {
diff --git a/src/cairo-pen.c b/src/cairo-pen.c
index 471849b0..0f0dee84 100644
--- a/src/cairo-pen.c
+++ b/src/cairo-pen.c
@@ -80,10 +80,8 @@ _cairo_pen_init (cairo_pen_t *pen,
pen->vertices = _cairo_malloc_ab (pen->num_vertices,
sizeof (cairo_pen_vertex_t));
- if (pen->vertices == NULL) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
- return CAIRO_STATUS_NO_MEMORY;
- }
+ if (pen->vertices == NULL)
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
/*
* Compute pen coordinates. To generate the right ellipse, compute points around
@@ -123,10 +121,9 @@ _cairo_pen_init_copy (cairo_pen_t *pen, cairo_pen_t *other)
if (pen->num_vertices) {
pen->vertices = _cairo_malloc_ab (pen->num_vertices,
sizeof (cairo_pen_vertex_t));
- if (pen->vertices == NULL) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
- return CAIRO_STATUS_NO_MEMORY;
- }
+ if (pen->vertices == NULL)
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
+
memcpy (pen->vertices, other->vertices, pen->num_vertices * sizeof (cairo_pen_vertex_t));
}
@@ -144,10 +141,8 @@ _cairo_pen_add_points (cairo_pen_t *pen, cairo_point_t *point, int num_points)
num_vertices = pen->num_vertices + num_points;
vertices = _cairo_realloc_ab (pen->vertices,
num_vertices, sizeof (cairo_pen_vertex_t));
- if (vertices == NULL) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
- return CAIRO_STATUS_NO_MEMORY;
- }
+ if (vertices == NULL)
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
pen->vertices = vertices;
pen->num_vertices = num_vertices;
diff --git a/src/cairo-png.c b/src/cairo-png.c
index 8ad4c9a0..27150675 100644
--- a/src/cairo-png.c
+++ b/src/cairo-png.c
@@ -129,14 +129,14 @@ write_png (cairo_surface_t *surface,
&image_extra);
if (status == CAIRO_STATUS_NO_MEMORY)
- return CAIRO_STATUS_NO_MEMORY;
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
else if (status != CAIRO_STATUS_SUCCESS)
- return CAIRO_STATUS_SURFACE_TYPE_MISMATCH;
+ return _cairo_error (CAIRO_STATUS_SURFACE_TYPE_MISMATCH);
if (image->height && image->width) {
rows = _cairo_malloc_ab (image->height, sizeof (png_byte*));
if (rows == NULL) {
- status = CAIRO_STATUS_NO_MEMORY;
+ status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto BAIL1;
}
@@ -148,13 +148,13 @@ write_png (cairo_surface_t *surface,
png_simple_error_callback,
png_simple_warning_callback);
if (png == NULL) {
- status = CAIRO_STATUS_NO_MEMORY;
+ status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto BAIL2;
}
info = png_create_info_struct (png);
if (info == NULL) {
- status = CAIRO_STATUS_NO_MEMORY;
+ status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto BAIL3;
}
@@ -181,7 +181,7 @@ write_png (cairo_surface_t *surface,
png_color_type = PNG_COLOR_TYPE_GRAY;
break;
default:
- status = CAIRO_STATUS_INVALID_FORMAT;
+ status = _cairo_error (CAIRO_STATUS_INVALID_FORMAT);
goto BAIL3;
}
@@ -270,12 +270,12 @@ cairo_surface_write_to_png (cairo_surface_t *surface,
fp = fopen (filename, "wb");
if (fp == NULL)
- return CAIRO_STATUS_WRITE_ERROR;
+ return _cairo_error (CAIRO_STATUS_WRITE_ERROR);
status = write_png (surface, stdio_write_func, fp);
if (fclose (fp) && status == CAIRO_STATUS_SUCCESS)
- status = CAIRO_STATUS_WRITE_ERROR;
+ status = _cairo_error (CAIRO_STATUS_WRITE_ERROR);
return status;
}
@@ -477,7 +477,7 @@ read_png (png_rw_ptr read_func,
png_destroy_read_struct (&png, &info, NULL);
if (surface->status)
- _cairo_error (surface->status);
+ _cairo_error_throw (surface->status);
return surface;
}
@@ -526,13 +526,13 @@ cairo_image_surface_create_from_png (const char *filename)
if (fp == NULL) {
switch (errno) {
case ENOMEM:
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
+ _cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
return (cairo_surface_t*) &_cairo_surface_nil;
case ENOENT:
- _cairo_error (CAIRO_STATUS_FILE_NOT_FOUND);
+ _cairo_error_throw (CAIRO_STATUS_FILE_NOT_FOUND);
return (cairo_surface_t*) &_cairo_surface_nil_file_not_found;
default:
- _cairo_error (CAIRO_STATUS_READ_ERROR);
+ _cairo_error_throw (CAIRO_STATUS_READ_ERROR);
return (cairo_surface_t*) &_cairo_surface_nil_read_error;
}
}
diff --git a/src/cairo-polygon.c b/src/cairo-polygon.c
index 3aa0c4cd..125d54d3 100644
--- a/src/cairo-polygon.c
+++ b/src/cairo-polygon.c
@@ -101,10 +101,8 @@ _cairo_polygon_grow (cairo_polygon_t *polygon)
new_size, sizeof (cairo_edge_t));
}
- if (new_edges == NULL) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
- return CAIRO_STATUS_NO_MEMORY;
- }
+ if (new_edges == NULL)
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
polygon->edges = new_edges;
polygon->edges_size = new_size;
diff --git a/src/cairo-ps-surface.c b/src/cairo-ps-surface.c
index 77d3820b..23a478c5 100644
--- a/src/cairo-ps-surface.c
+++ b/src/cairo-ps-surface.c
@@ -150,7 +150,7 @@ _word_wrap_stream_create (cairo_output_stream_t *output, int max_column)
stream = malloc (sizeof (word_wrap_stream_t));
if (stream == NULL) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
+ _cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
return (cairo_output_stream_t *) &_cairo_output_stream_nil;
}
@@ -653,7 +653,7 @@ _cairo_ps_surface_emit_glyph (cairo_ps_surface_t *surface,
"\t\t}\n");
if (status)
- _cairo_surface_set_error (&surface->base, status);
+ status = _cairo_surface_set_error (&surface->base, status);
return status;
}
@@ -807,7 +807,7 @@ _cairo_ps_surface_create_for_stream_internal (cairo_output_stream_t *stream,
surface = malloc (sizeof (cairo_ps_surface_t));
if (surface == NULL) {
- status = CAIRO_STATUS_NO_MEMORY;
+ status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto CLEANUP;
}
@@ -857,7 +857,7 @@ _cairo_ps_surface_create_for_stream_internal (cairo_output_stream_t *stream,
CLEANUP_SURFACE:
free (surface);
CLEANUP:
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
+ _cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
return (cairo_surface_t*) &_cairo_surface_nil;
}
@@ -895,12 +895,10 @@ cairo_ps_surface_create (const char *filename,
stream = _cairo_output_stream_create_for_filename (filename);
status = _cairo_output_stream_get_status (stream);
- if (status) {
- _cairo_error (status);
+ if (status)
return (status == CAIRO_STATUS_WRITE_ERROR) ?
(cairo_surface_t*) &_cairo_surface_nil_write_error :
(cairo_surface_t*) &_cairo_surface_nil;
- }
return _cairo_ps_surface_create_for_stream_internal (stream,
width_in_points,
@@ -943,10 +941,8 @@ cairo_ps_surface_create_for_stream (cairo_write_func_t write_func,
stream = _cairo_output_stream_create (write_func, NULL, closure);
status = _cairo_output_stream_get_status (stream);
- if (status) {
- _cairo_error (status);
+ if (status)
return (cairo_surface_t*) &_cairo_surface_nil;
- }
return _cairo_ps_surface_create_for_stream_internal (stream,
width_in_points,
@@ -970,12 +966,12 @@ _extract_ps_surface (cairo_surface_t *surface,
cairo_surface_t *target;
if (! _cairo_surface_is_paginated (surface))
- return CAIRO_STATUS_SURFACE_TYPE_MISMATCH;
+ return _cairo_error (CAIRO_STATUS_SURFACE_TYPE_MISMATCH);
target = _cairo_paginated_surface_get_target (surface);
if (! _cairo_surface_is_ps (target))
- return CAIRO_STATUS_SURFACE_TYPE_MISMATCH;
+ return _cairo_error (CAIRO_STATUS_SURFACE_TYPE_MISMATCH);
*ps_surface = (cairo_ps_surface_t *) target;
@@ -1007,7 +1003,7 @@ cairo_ps_surface_set_eps (cairo_surface_t *surface,
status = _extract_ps_surface (surface, &ps_surface);
if (status) {
- _cairo_surface_set_error (surface, CAIRO_STATUS_SURFACE_TYPE_MISMATCH);
+ status = _cairo_surface_set_error (surface, status);
return;
}
@@ -1032,7 +1028,7 @@ cairo_ps_surface_get_eps (cairo_surface_t *surface)
status = _extract_ps_surface (surface, &ps_surface);
if (status) {
- _cairo_surface_set_error (surface, CAIRO_STATUS_SURFACE_TYPE_MISMATCH);
+ status = _cairo_surface_set_error (surface, status);
return FALSE;
}
@@ -1066,7 +1062,7 @@ cairo_ps_surface_set_size (cairo_surface_t *surface,
status = _extract_ps_surface (surface, &ps_surface);
if (status) {
- _cairo_surface_set_error (surface, CAIRO_STATUS_SURFACE_TYPE_MISMATCH);
+ status = _cairo_surface_set_error (surface, status);
return;
}
@@ -1076,7 +1072,7 @@ cairo_ps_surface_set_size (cairo_surface_t *surface,
width_in_points,
height_in_points);
if (status)
- _cairo_surface_set_error (surface, status);
+ status = _cairo_surface_set_error (surface, status);
}
/**
@@ -1177,32 +1173,32 @@ cairo_ps_surface_dsc_comment (cairo_surface_t *surface,
status = _extract_ps_surface (surface, &ps_surface);
if (status) {
- _cairo_surface_set_error (surface, CAIRO_STATUS_SURFACE_TYPE_MISMATCH);
+ status = _cairo_surface_set_error (surface, status);
return;
}
/* A couple of sanity checks on the comment value. */
if (comment == NULL) {
- _cairo_surface_set_error (surface, CAIRO_STATUS_NULL_POINTER);
+ status = _cairo_surface_set_error (surface, CAIRO_STATUS_NULL_POINTER);
return;
}
if (comment[0] != '%' || strlen (comment) > 255) {
- _cairo_surface_set_error (surface, CAIRO_STATUS_INVALID_DSC_COMMENT);
+ status = _cairo_surface_set_error (surface, CAIRO_STATUS_INVALID_DSC_COMMENT);
return;
}
/* Then, copy the comment and store it in the appropriate array. */
comment_copy = strdup (comment);
if (comment_copy == NULL) {
- _cairo_surface_set_error (surface, CAIRO_STATUS_NO_MEMORY);
+ status = _cairo_surface_set_error (surface, CAIRO_STATUS_NO_MEMORY);
return;
}
status = _cairo_array_append (ps_surface->dsc_comment_target, &comment_copy);
if (status) {
free (comment_copy);
- _cairo_surface_set_error (surface, status);
+ status = _cairo_surface_set_error (surface, status);
return;
}
}
@@ -1231,7 +1227,7 @@ cairo_ps_surface_dsc_begin_setup (cairo_surface_t *surface)
status = _extract_ps_surface (surface, &ps_surface);
if (status) {
- _cairo_surface_set_error (surface, CAIRO_STATUS_SURFACE_TYPE_MISMATCH);
+ status = _cairo_surface_set_error (surface, status);
return;
}
@@ -1266,7 +1262,7 @@ cairo_ps_surface_dsc_begin_page_setup (cairo_surface_t *surface)
status = _extract_ps_surface (surface, &ps_surface);
if (status) {
- _cairo_surface_set_error (surface, CAIRO_STATUS_SURFACE_TYPE_MISMATCH);
+ status = _cairo_surface_set_error (surface, status);
return;
}
@@ -1568,7 +1564,7 @@ _string_array_stream_create (cairo_output_stream_t *output)
stream = malloc (sizeof (string_array_stream_t));
if (stream == NULL) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
+ _cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
return (cairo_output_stream_t *) &_cairo_output_stream_nil;
}
@@ -1610,7 +1606,7 @@ _cairo_ps_surface_emit_image (cairo_ps_surface_t *surface,
image->width,
image->height);
if (opaque->status) {
- status = CAIRO_STATUS_NO_MEMORY;
+ status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto bail0;
}
@@ -1650,8 +1646,7 @@ _cairo_ps_surface_emit_image (cairo_ps_surface_t *surface,
rgb_size = 3 * opaque_image->width * opaque_image->height;
rgb = malloc (rgb_size);
if (rgb == NULL) {
- status = CAIRO_STATUS_NO_MEMORY;
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
+ status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto bail1;
}
@@ -1670,7 +1665,7 @@ _cairo_ps_surface_emit_image (cairo_ps_surface_t *surface,
compressed_size = rgb_size;
compressed = _cairo_lzw_compress (rgb, &compressed_size);
if (compressed == NULL) {
- status = CAIRO_STATUS_NO_MEMORY;
+ status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto bail2;
}
@@ -2122,10 +2117,8 @@ _cairo_ps_surface_stroke (void *abstract_surface,
*/
if (num_dashes % 2) {
dash = _cairo_malloc_abc (num_dashes, 2, sizeof (double));
- if (dash == NULL) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
- return CAIRO_STATUS_NO_MEMORY;
- }
+ if (dash == NULL)
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
memcpy (dash, style->dash, num_dashes * sizeof (double));
memcpy (dash + num_dashes, style->dash, num_dashes * sizeof (double));
@@ -2306,10 +2299,8 @@ _cairo_ps_surface_show_glyphs (void *abstract_surface,
_cairo_ps_surface_emit_pattern (surface, source);
glyph_ids = _cairo_malloc_ab (num_glyphs_unsigned, sizeof (cairo_ps_glyph_id_t));
- if (glyph_ids == NULL) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
- return CAIRO_STATUS_NO_MEMORY;
- }
+ if (glyph_ids == NULL)
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
for (i = 0; i < num_glyphs_unsigned; i++) {
status = _cairo_scaled_font_subsets_map_glyph (surface->font_subsets,
diff --git a/src/cairo-quartz-surface.c b/src/cairo-quartz-surface.c
index 8a90f309..88fe4b06 100644
--- a/src/cairo-quartz-surface.c
+++ b/src/cairo-quartz-surface.c
@@ -1256,10 +1256,8 @@ _cairo_quartz_surface_stroke (void *abstract_surface,
unsigned int k;
if (style->num_dashes > STATIC_DASH)
fdash = _cairo_malloc_ab (style->num_dashes, sizeof (float));
- if (fdash == NULL) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
- return CAIRO_STATUS_NO_MEMORY;
- }
+ if (fdash == NULL)
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
for (k = 0; k < style->num_dashes; k++)
fdash[k] = (float) style->dash[k];
@@ -1399,16 +1397,13 @@ _cairo_quartz_surface_show_glyphs (void *abstract_surface,
if (num_glyphs > STATIC_BUF_SIZE) {
cg_glyphs = (CGGlyph*) _cairo_malloc_ab (num_glyphs, sizeof(CGGlyph));
- if (cg_glyphs == NULL) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
- return CAIRO_STATUS_NO_MEMORY;
- }
+ if (cg_glyphs == NULL)
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
cg_advances = (CGSize*) _cairo_malloc_ab (num_glyphs, sizeof(CGSize));
if (cg_glyphs == NULL) {
free (cg_advances);
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
- return CAIRO_STATUS_NO_MEMORY;
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
}
}
diff --git a/src/cairo-region.c b/src/cairo-region.c
index ea4ccc37..b4b91177 100644
--- a/src/cairo-region.c
+++ b/src/cairo-region.c
@@ -66,10 +66,8 @@ _cairo_region_init_boxes (cairo_region_t *region,
if (count > ARRAY_LENGTH(stack_pboxes)) {
pboxes = _cairo_malloc_ab (count, sizeof(pixman_box16_t));
- if (pboxes == NULL) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
- return CAIRO_STATUS_NO_MEMORY;
- }
+ if (pboxes == NULL)
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
}
for (i = 0; i < count; i++) {
@@ -80,7 +78,7 @@ _cairo_region_init_boxes (cairo_region_t *region,
}
if (!pixman_region_init_rects (&region->rgn, pboxes, count))
- status = CAIRO_STATUS_NO_MEMORY;
+ status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
if (pboxes != stack_pboxes)
free (pboxes);
@@ -98,7 +96,7 @@ cairo_int_status_t
_cairo_region_copy (cairo_region_t *dst, cairo_region_t *src)
{
if (!pixman_region_copy (&dst->rgn, &src->rgn))
- return CAIRO_STATUS_NO_MEMORY;
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
return CAIRO_STATUS_SUCCESS;
}
@@ -126,10 +124,8 @@ _cairo_region_get_boxes (cairo_region_t *region, int *num_boxes, cairo_box_int_t
}
cboxes = _cairo_malloc_ab (nboxes, sizeof(cairo_box_int_t));
- if (cboxes == NULL) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
- return CAIRO_STATUS_NO_MEMORY;
- }
+ if (cboxes == NULL)
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
for (i = 0; i < nboxes; i++) {
cboxes[i].p1.x = pboxes[i].x1;
@@ -172,7 +168,7 @@ cairo_int_status_t
_cairo_region_subtract (cairo_region_t *dst, cairo_region_t *a, cairo_region_t *b)
{
if (!pixman_region_subtract (&dst->rgn, &a->rgn, &b->rgn))
- return CAIRO_STATUS_NO_MEMORY;
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
return CAIRO_STATUS_SUCCESS;
}
@@ -181,7 +177,7 @@ cairo_int_status_t
_cairo_region_intersect (cairo_region_t *dst, cairo_region_t *a, cairo_region_t *b)
{
if (!pixman_region_intersect (&dst->rgn, &a->rgn, &b->rgn))
- return CAIRO_STATUS_NO_MEMORY;
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
return CAIRO_STATUS_SUCCESS;
}
@@ -194,7 +190,7 @@ _cairo_region_union_rect (cairo_region_t *dst,
if (!pixman_region_union_rect (&dst->rgn, &src->rgn,
rect->x, rect->y,
rect->width, rect->height))
- return CAIRO_STATUS_NO_MEMORY;
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
return CAIRO_STATUS_SUCCESS;
}
diff --git a/src/cairo-scaled-font-subsets.c b/src/cairo-scaled-font-subsets.c
index a5d9c49e..efc79993 100644
--- a/src/cairo-scaled-font-subsets.c
+++ b/src/cairo-scaled-font-subsets.c
@@ -125,7 +125,7 @@ _cairo_sub_font_glyph_create (unsigned long scaled_font_glyph_index,
sub_font_glyph = malloc (sizeof (cairo_sub_font_glyph_t));
if (sub_font_glyph == NULL) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
+ _cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
return NULL;
}
@@ -217,7 +217,7 @@ _cairo_sub_font_create (cairo_scaled_font_subsets_t *parent,
sub_font = malloc (sizeof (cairo_sub_font_t));
if (sub_font == NULL) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
+ _cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
return NULL;
}
@@ -289,7 +289,7 @@ _cairo_sub_font_lookup_glyph (cairo_sub_font_t *sub_font,
return CAIRO_STATUS_SUCCESS;
}
- return CAIRO_STATUS_NULL_POINTER;
+ return _cairo_error (CAIRO_STATUS_NULL_POINTER);
}
static cairo_status_t
@@ -328,7 +328,7 @@ _cairo_sub_font_map_glyph (cairo_sub_font_t *sub_font,
sub_font->num_glyphs_in_current_subset++,
scaled_glyph->metrics.x_advance);
if (sub_font_glyph == NULL)
- return CAIRO_STATUS_NO_MEMORY;
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
if (sub_font->is_scaled)
{
@@ -416,7 +416,7 @@ _cairo_scaled_font_subsets_create_internal (cairo_subsets_type_t type)
subsets = malloc (sizeof (cairo_scaled_font_subsets_t));
if (subsets == NULL) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
+ _cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
return NULL;
}
@@ -563,7 +563,7 @@ _cairo_scaled_font_subsets_map_glyph (cairo_scaled_font_subsets_t *subsets,
subset_glyph->is_composite);
if (sub_font == NULL) {
cairo_scaled_font_destroy (unscaled_font);
- return CAIRO_STATUS_NO_MEMORY;
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
}
status = _cairo_hash_table_insert (subsets->unscaled_sub_fonts,
@@ -595,7 +595,7 @@ _cairo_scaled_font_subsets_map_glyph (cairo_scaled_font_subsets_t *subsets,
subset_glyph->is_composite);
if (sub_font == NULL) {
cairo_scaled_font_destroy (scaled_font);
- return CAIRO_STATUS_NO_MEMORY;
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
}
status = _cairo_hash_table_insert (subsets->scaled_sub_fonts,
@@ -629,10 +629,8 @@ _cairo_scaled_font_subsets_foreach_internal (cairo_scaled_font_subsets_t
return CAIRO_STATUS_SUCCESS;
collection.glyphs = _cairo_malloc_ab (collection.glyphs_size, sizeof(unsigned long));
- if (collection.glyphs == NULL) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
- return CAIRO_STATUS_NO_MEMORY;
- }
+ if (collection.glyphs == NULL)
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
collection.font_subset_callback = font_subset_callback;
collection.font_subset_callback_closure = closure;
diff --git a/src/cairo-scaled-font.c b/src/cairo-scaled-font.c
index 08d426f7..47f06e7c 100644
--- a/src/cairo-scaled-font.c
+++ b/src/cairo-scaled-font.c
@@ -223,7 +223,7 @@ _cairo_scaled_font_set_error (cairo_scaled_font_t *scaled_font,
* error, which is the most significant. */
_cairo_status_set_error (&scaled_font->status, status);
- _cairo_error (status);
+ _cairo_error_throw (status);
}
/**
@@ -323,7 +323,7 @@ _cairo_scaled_font_map_lock (void)
cairo_scaled_font_map = NULL;
CLEANUP_MUTEX_LOCK:
CAIRO_MUTEX_UNLOCK (_cairo_scaled_font_map_mutex);
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
+ _cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
return NULL;
}
@@ -481,7 +481,7 @@ _cairo_scaled_font_init (cairo_scaled_font_t *scaled_font,
_cairo_scaled_glyph_destroy,
MAX_GLYPHS_CACHED_PER_FONT);
if (scaled_font->glyphs == NULL)
- return CAIRO_STATUS_NO_MEMORY;
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
CAIRO_REFERENCE_COUNT_INIT (&scaled_font->ref_count, 1);
@@ -827,7 +827,7 @@ cairo_scaled_font_set_user_data (cairo_scaled_font_t *scaled_font,
cairo_destroy_func_t destroy)
{
if (CAIRO_REFERENCE_COUNT_IS_INVALID (&scaled_font->ref_count))
- return CAIRO_STATUS_NO_MEMORY;
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
return _cairo_user_data_array_set_data (&scaled_font->user_data,
key, user_data, destroy);
@@ -1035,8 +1035,7 @@ _cairo_scaled_font_text_to_glyphs (cairo_scaled_font_t *scaled_font,
*glyphs = (cairo_glyph_t *) _cairo_malloc_ab ((*num_glyphs), sizeof (cairo_glyph_t));
if (*glyphs == NULL) {
- status = CAIRO_STATUS_NO_MEMORY;
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
+ status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto DONE;
}
@@ -1443,7 +1442,7 @@ _cairo_scaled_font_glyph_path (cairo_scaled_font_t *scaled_font,
glyph_path = _cairo_path_fixed_create ();
if (glyph_path == NULL)
- return CAIRO_STATUS_NO_MEMORY;
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
status = _trace_mask_to_path (scaled_glyph->surface, glyph_path);
if (status) {
@@ -1626,8 +1625,7 @@ _cairo_scaled_glyph_lookup (cairo_scaled_font_t *scaled_font,
*/
scaled_glyph = malloc (sizeof (cairo_scaled_glyph_t));
if (scaled_glyph == NULL) {
- status = CAIRO_STATUS_NO_MEMORY;
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
+ status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto CLEANUP;
}
diff --git a/src/cairo-skiplist.c b/src/cairo-skiplist.c
index fe80263f..ebeb52c8 100644
--- a/src/cairo-skiplist.c
+++ b/src/cairo-skiplist.c
@@ -356,7 +356,7 @@ _cairo_skip_list_insert (cairo_skip_list_t *list, void *data, int unique)
data_and_elt = alloc_node_for_level (list, level);
if (data_and_elt == NULL) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
+ _cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
return NULL;
}
diff --git a/src/cairo-spline.c b/src/cairo-spline.c
index f22f6464..898ce7c3 100644
--- a/src/cairo-spline.c
+++ b/src/cairo-spline.c
@@ -117,10 +117,8 @@ _cairo_spline_grow (cairo_spline_t *spline)
new_size, sizeof (cairo_point_t));
}
- if (new_points == NULL) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
- return CAIRO_STATUS_NO_MEMORY;
- }
+ if (new_points == NULL)
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
spline->points = new_points;
spline->points_size = new_size;
diff --git a/src/cairo-stroke-style.c b/src/cairo-stroke-style.c
index ea6b4128..a7c17b2f 100644
--- a/src/cairo-stroke-style.c
+++ b/src/cairo-stroke-style.c
@@ -63,10 +63,8 @@ _cairo_stroke_style_init_copy (cairo_stroke_style_t *style,
style->dash = NULL;
} else {
style->dash = _cairo_malloc_ab (style->num_dashes, sizeof (double));
- if (style->dash == NULL) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
- return CAIRO_STATUS_NO_MEMORY;
- }
+ if (style->dash == NULL)
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
memcpy (style->dash, other->dash,
style->num_dashes * sizeof (double));
diff --git a/src/cairo-surface-fallback.c b/src/cairo-surface-fallback.c
index 37aee51f..e9a77add 100644
--- a/src/cairo-surface-fallback.c
+++ b/src/cairo-surface-fallback.c
@@ -125,7 +125,7 @@ _create_composite_mask_pattern (cairo_surface_pattern_t *mask_pattern,
extents->width,
extents->height);
if (mask->status)
- return CAIRO_STATUS_NO_MEMORY;
+ return mask->status;
status = (*draw_func) (draw_closure, CAIRO_OPERATOR_ADD,
NULL, mask,
@@ -211,7 +211,7 @@ _clip_and_composite_combine (cairo_clip_t *clip,
extents->width,
extents->height);
if (intermediate->status)
- return CAIRO_STATUS_NO_MEMORY;
+ return intermediate->status;
/* Initialize the intermediate surface from the destination surface
*/
@@ -1171,8 +1171,7 @@ _cairo_surface_fallback_fill_rectangles (cairo_surface_t *surface,
if (state.image_rect.x != 0 || state.image_rect.y != 0) {
offset_rects = _cairo_malloc_ab (num_rects, sizeof (cairo_rectangle_int_t));
if (offset_rects == NULL) {
- status = CAIRO_STATUS_NO_MEMORY;
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
+ status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto DONE;
}
@@ -1228,8 +1227,7 @@ _cairo_surface_fallback_composite_trapezoids (cairo_operator_t op,
if (state.image_rect.x != 0 || state.image_rect.y != 0) {
offset_traps = _cairo_malloc_ab (num_traps, sizeof (cairo_trapezoid_t));
if (!offset_traps) {
- status = CAIRO_STATUS_NO_MEMORY;
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
+ status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto DONE;
}
diff --git a/src/cairo-surface.c b/src/cairo-surface.c
index 86976898..3c95198a 100644
--- a/src/cairo-surface.c
+++ b/src/cairo-surface.c
@@ -104,8 +104,10 @@ _cairo_surface_copy_pattern_for_destination (const cairo_pattern_t *pattern,
* The purpose of this function is to allow the user to set a
* breakpoint in _cairo_error() to generate a stack trace for when the
* user causes cairo to detect an error.
+ *
+ * Return value: the error status.
**/
-void
+cairo_status_t
_cairo_surface_set_error (cairo_surface_t *surface,
cairo_status_t status)
{
@@ -113,7 +115,7 @@ _cairo_surface_set_error (cairo_surface_t *surface,
* error, which is the most significant. */
_cairo_status_set_error (&surface->status, status);
- _cairo_error (status);
+ return _cairo_error (status);
}
/**
@@ -287,7 +289,7 @@ cairo_surface_create_similar (cairo_surface_t *other,
return (cairo_surface_t*) &_cairo_surface_nil;
if (! CAIRO_CONTENT_VALID (content)) {
- _cairo_error (CAIRO_STATUS_INVALID_CONTENT);
+ _cairo_error_throw (CAIRO_STATUS_INVALID_CONTENT);
return (cairo_surface_t*) &_cairo_surface_nil;
}
@@ -313,7 +315,7 @@ _cairo_surface_create_similar_solid (cairo_surface_t *other,
surface = _cairo_surface_create_similar_scratch (other, content,
width, height);
if (surface->status) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
+ _cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
return (cairo_surface_t*) &_cairo_surface_nil;
}
@@ -321,7 +323,7 @@ _cairo_surface_create_similar_solid (cairo_surface_t *other,
source = _cairo_pattern_create_solid (color, content);
if (source->status) {
cairo_surface_destroy (surface);
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
+ _cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
return (cairo_surface_t*) &_cairo_surface_nil;
}
} else
@@ -337,7 +339,7 @@ _cairo_surface_create_similar_solid (cairo_surface_t *other,
if (status) {
cairo_surface_destroy (surface);
- _cairo_error (status);
+ _cairo_error_throw (status);
return (cairo_surface_t*) &_cairo_surface_nil;
}
@@ -492,7 +494,7 @@ cairo_surface_finish (cairo_surface_t *surface)
return;
if (surface->finished) {
- _cairo_surface_set_error (surface, CAIRO_STATUS_SURFACE_FINISHED);
+ status = _cairo_surface_set_error (surface, CAIRO_STATUS_SURFACE_FINISHED);
return;
}
@@ -504,14 +506,14 @@ cairo_surface_finish (cairo_surface_t *surface)
if (!surface->status && surface->backend->flush) {
status = surface->backend->flush (surface);
if (status) {
- _cairo_surface_set_error (surface, status);
+ status = _cairo_surface_set_error (surface, status);
return;
}
}
status = surface->backend->finish (surface);
if (status)
- _cairo_surface_set_error (surface, status);
+ status = _cairo_surface_set_error (surface, status);
surface->finished = TRUE;
}
@@ -560,7 +562,7 @@ cairo_surface_set_user_data (cairo_surface_t *surface,
cairo_destroy_func_t destroy)
{
if (CAIRO_REFERENCE_COUNT_IS_INVALID (&surface->ref_count))
- return CAIRO_STATUS_NO_MEMORY;
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
return _cairo_user_data_array_set_data (&surface->user_data,
key, user_data, destroy);
@@ -640,21 +642,20 @@ slim_hidden_def (cairo_surface_get_font_options);
void
cairo_surface_flush (cairo_surface_t *surface)
{
+ cairo_status_t status;
+
if (surface->status)
return;
if (surface->finished) {
- _cairo_surface_set_error (surface, CAIRO_STATUS_SURFACE_FINISHED);
+ status = _cairo_surface_set_error (surface, CAIRO_STATUS_SURFACE_FINISHED);
return;
}
if (surface->backend->flush) {
- cairo_status_t status;
-
status = surface->backend->flush (surface);
-
if (status)
- _cairo_surface_set_error (surface, status);
+ status = _cairo_surface_set_error (surface, status);
}
}
@@ -697,13 +698,15 @@ cairo_surface_mark_dirty_rectangle (cairo_surface_t *surface,
int width,
int height)
{
+ cairo_status_t status;
+
assert (! surface->is_snapshot);
if (surface->status)
return;
if (surface->finished) {
- _cairo_surface_set_error (surface, CAIRO_STATUS_SURFACE_FINISHED);
+ status = _cairo_surface_set_error (surface, CAIRO_STATUS_SURFACE_FINISHED);
return;
}
@@ -715,8 +718,6 @@ cairo_surface_mark_dirty_rectangle (cairo_surface_t *surface,
surface->current_clip_serial = -1;
if (surface->backend->mark_dirty_rectangle) {
- cairo_status_t status;
-
/* XXX: FRAGILE: We're ignoring the scaling component of
* device_transform here. I don't know what the right thing to
* do would actually be if there were some scaling here, but
@@ -728,7 +729,7 @@ cairo_surface_mark_dirty_rectangle (cairo_surface_t *surface,
width, height);
if (status)
- _cairo_surface_set_error (surface, status);
+ status = _cairo_surface_set_error (surface, status);
}
}
slim_hidden_def (cairo_surface_mark_dirty_rectangle);
@@ -758,13 +759,15 @@ _cairo_surface_set_device_scale (cairo_surface_t *surface,
double sx,
double sy)
{
+ cairo_status_t status;
+
assert (! surface->is_snapshot);
if (surface->status)
return;
if (surface->finished) {
- _cairo_surface_set_error (surface, CAIRO_STATUS_SURFACE_FINISHED);
+ status = _cairo_surface_set_error (surface, CAIRO_STATUS_SURFACE_FINISHED);
return;
}
@@ -798,13 +801,15 @@ cairo_surface_set_device_offset (cairo_surface_t *surface,
double x_offset,
double y_offset)
{
+ cairo_status_t status;
+
assert (! surface->is_snapshot);
if (surface->status)
return;
if (surface->finished) {
- _cairo_surface_set_error (surface, CAIRO_STATUS_SURFACE_FINISHED);
+ status = _cairo_surface_set_error (surface, CAIRO_STATUS_SURFACE_FINISHED);
return;
}
@@ -1036,7 +1041,7 @@ _cairo_surface_clone_similar (cairo_surface_t *surface,
void *image_extra;
if (surface->finished)
- return CAIRO_STATUS_SURFACE_FINISHED;
+ return _cairo_error (CAIRO_STATUS_SURFACE_FINISHED);
if (surface->backend->clone_similar) {
status = surface->backend->clone_similar (surface, src, src_x, src_y,
@@ -1164,7 +1169,7 @@ _cairo_surface_composite (cairo_operator_t op,
return dst->status;
if (dst->finished)
- return CAIRO_STATUS_SURFACE_FINISHED;
+ return _cairo_error (CAIRO_STATUS_SURFACE_FINISHED);
if (dst->backend->composite) {
status = dst->backend->composite (op,
@@ -1217,7 +1222,7 @@ _cairo_surface_fill_rectangle (cairo_surface_t *surface,
return surface->status;
if (surface->finished)
- return CAIRO_STATUS_SURFACE_FINISHED;
+ return _cairo_error (CAIRO_STATUS_SURFACE_FINISHED);
rect.x = x;
rect.y = y;
@@ -1267,8 +1272,7 @@ _cairo_surface_fill_region (cairo_surface_t *surface,
rects = _cairo_malloc_ab (num_boxes, sizeof (cairo_rectangle_int_t));
if (!rects) {
_cairo_region_boxes_fini (region, boxes);
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
- return CAIRO_STATUS_NO_MEMORY;
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
}
}
@@ -1321,7 +1325,7 @@ _cairo_surface_fill_rectangles (cairo_surface_t *surface,
return surface->status;
if (surface->finished)
- return CAIRO_STATUS_SURFACE_FINISHED;
+ return _cairo_error (CAIRO_STATUS_SURFACE_FINISHED);
if (num_rects == 0)
return CAIRO_STATUS_SUCCESS;
@@ -1571,7 +1575,7 @@ _cairo_surface_composite_trapezoids (cairo_operator_t op,
return dst->status;
if (dst->finished)
- return CAIRO_STATUS_SURFACE_FINISHED;
+ return _cairo_error (CAIRO_STATUS_SURFACE_FINISHED);
if (dst->backend->composite_trapezoids) {
status = dst->backend->composite_trapezoids (op,
@@ -1613,7 +1617,7 @@ cairo_surface_copy_page (cairo_surface_t *surface)
return surface->status;
if (surface->finished)
- return CAIRO_STATUS_SURFACE_FINISHED;
+ return _cairo_error (CAIRO_STATUS_SURFACE_FINISHED);
/* It's fine if some backends don't implement copy_page */
if (surface->backend->copy_page == NULL)
@@ -1642,7 +1646,7 @@ cairo_surface_show_page (cairo_surface_t *surface)
return surface->status;
if (surface->finished)
- return CAIRO_STATUS_SURFACE_FINISHED;
+ return _cairo_error (CAIRO_STATUS_SURFACE_FINISHED);
/* It's fine if some backends don't implement show_page */
if (surface->backend->show_page == NULL)
@@ -1708,7 +1712,7 @@ _cairo_surface_reset_clip (cairo_surface_t *surface)
return surface->status;
if (surface->finished)
- return CAIRO_STATUS_SURFACE_FINISHED;
+ return _cairo_error (CAIRO_STATUS_SURFACE_FINISHED);
surface->current_clip_serial = 0;
@@ -1752,7 +1756,7 @@ _cairo_surface_set_clip_region (cairo_surface_t *surface,
return surface->status;
if (surface->finished)
- return CAIRO_STATUS_SURFACE_FINISHED;
+ return _cairo_error (CAIRO_STATUS_SURFACE_FINISHED);
assert (surface->backend->set_clip_region != NULL);
@@ -1777,7 +1781,7 @@ _cairo_surface_intersect_clip_path (cairo_surface_t *surface,
return surface->status;
if (surface->finished)
- return CAIRO_STATUS_SURFACE_FINISHED;
+ return _cairo_error (CAIRO_STATUS_SURFACE_FINISHED);
assert (surface->backend->intersect_clip_path != NULL);
@@ -1830,7 +1834,7 @@ _cairo_surface_set_clip_path (cairo_surface_t *surface,
return surface->status;
if (surface->finished)
- return CAIRO_STATUS_SURFACE_FINISHED;
+ return _cairo_error (CAIRO_STATUS_SURFACE_FINISHED);
assert (surface->backend->intersect_clip_path != NULL);
@@ -1857,13 +1861,13 @@ _cairo_surface_set_clip (cairo_surface_t *surface, cairo_clip_t *clip)
unsigned int serial = 0;
if (!surface)
- return CAIRO_STATUS_NULL_POINTER;
+ return _cairo_error (CAIRO_STATUS_NULL_POINTER);
if (surface->status)
return surface->status;
if (surface->finished)
- return CAIRO_STATUS_SURFACE_FINISHED;
+ return _cairo_error (CAIRO_STATUS_SURFACE_FINISHED);
if (clip) {
serial = clip->serial;
@@ -1923,7 +1927,7 @@ _cairo_surface_get_extents (cairo_surface_t *surface,
return surface->status;
if (surface->finished)
- return CAIRO_STATUS_SURFACE_FINISHED;
+ return _cairo_error (CAIRO_STATUS_SURFACE_FINISHED);
return surface->backend->get_extents (surface, rectangle);
}
@@ -2036,7 +2040,7 @@ _cairo_surface_old_show_glyphs (cairo_scaled_font_t *scaled_font,
return dst->status;
if (dst->finished)
- return CAIRO_STATUS_SURFACE_FINISHED;
+ return _cairo_error (CAIRO_STATUS_SURFACE_FINISHED);
if (dst->backend->old_show_glyphs) {
status = dst->backend->old_show_glyphs (scaled_font,
@@ -2095,7 +2099,7 @@ _cairo_surface_composite_fixup_unbounded_internal (cairo_surface_t *dst,
if (_cairo_region_subtract (&clear_region, &clear_region, &drawn_region)
!= CAIRO_STATUS_SUCCESS)
{
- status = CAIRO_STATUS_NO_MEMORY;
+ status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto CLEANUP_REGIONS;
}
diff --git a/src/cairo-svg-surface.c b/src/cairo-svg-surface.c
index b4e9270a..cc909f5c 100644
--- a/src/cairo-svg-surface.c
+++ b/src/cairo-svg-surface.c
@@ -178,10 +178,8 @@ cairo_svg_surface_create_for_stream (cairo_write_func_t write_func,
stream = _cairo_output_stream_create (write_func, NULL, closure);
status = _cairo_output_stream_get_status (stream);
- if (status) {
- _cairo_error (status);
+ if (status)
return (cairo_surface_t *) &_cairo_surface_nil;
- }
return _cairo_svg_surface_create_for_stream_internal (stream, width, height, CAIRO_SVG_VERSION_1_1);
}
@@ -215,12 +213,10 @@ cairo_svg_surface_create (const char *filename,
stream = _cairo_output_stream_create_for_filename (filename);
status = _cairo_output_stream_get_status (stream);
- if (status) {
- _cairo_error (status);
+ if (status)
return (status == CAIRO_STATUS_WRITE_ERROR) ?
(cairo_surface_t *) &_cairo_surface_nil_write_error :
(cairo_surface_t *) &_cairo_surface_nil;
- }
return _cairo_svg_surface_create_for_stream_internal (stream, width, height, CAIRO_SVG_VERSION_1_1);
}
@@ -242,12 +238,12 @@ _extract_svg_surface (cairo_surface_t *surface,
cairo_surface_t *target;
if (! _cairo_surface_is_paginated (surface))
- return CAIRO_STATUS_SURFACE_TYPE_MISMATCH;
+ return _cairo_error (CAIRO_STATUS_SURFACE_TYPE_MISMATCH);
target = _cairo_paginated_surface_get_target (surface);
if (! _cairo_surface_is_svg (target))
- return CAIRO_STATUS_SURFACE_TYPE_MISMATCH;
+ return _cairo_error (CAIRO_STATUS_SURFACE_TYPE_MISMATCH);
*svg_surface = (cairo_svg_surface_t *) target;
@@ -273,13 +269,12 @@ void
cairo_svg_surface_restrict_to_version (cairo_surface_t *abstract_surface,
cairo_svg_version_t version)
{
- cairo_svg_surface_t *surface;
+ cairo_svg_surface_t *surface = NULL; /* hide compiler warning */
cairo_status_t status;
status = _extract_svg_surface (abstract_surface, &surface);
if (status) {
- _cairo_surface_set_error (abstract_surface,
- CAIRO_STATUS_SURFACE_TYPE_MISMATCH);
+ status = _cairo_surface_set_error (abstract_surface, status);
return;
}
@@ -339,7 +334,7 @@ _cairo_svg_surface_create_for_document (cairo_svg_document_t *document,
surface = malloc (sizeof (cairo_svg_surface_t));
if (surface == NULL) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
+ _cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
return (cairo_surface_t*) &_cairo_surface_nil;
}
@@ -389,7 +384,7 @@ _cairo_svg_surface_create_for_stream_internal (cairo_output_stream_t *stream,
document = _cairo_svg_document_create (stream, width, height, version);
if (document == NULL) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
+ _cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
return (cairo_surface_t *) &_cairo_surface_nil;
}
@@ -2119,14 +2114,13 @@ _cairo_svg_document_create (cairo_output_stream_t *output_stream,
document = malloc (sizeof (cairo_svg_document_t));
if (document == NULL) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
+ _cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
return NULL;
}
/* The use of defs for font glyphs imposes no per-subset limit. */
document->font_subsets = _cairo_scaled_font_subsets_create_scaled ();
if (document->font_subsets == NULL) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
free (document);
return NULL;
}
diff --git a/src/cairo-traps.c b/src/cairo-traps.c
index 32743b4f..1893fc20 100644
--- a/src/cairo-traps.c
+++ b/src/cairo-traps.c
@@ -270,8 +270,7 @@ _cairo_traps_grow (cairo_traps_t *traps)
}
if (new_traps == NULL) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
- traps->status = CAIRO_STATUS_NO_MEMORY;
+ traps->status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
return traps->status;
}
@@ -615,10 +614,8 @@ _cairo_traps_extract_region (cairo_traps_t *traps,
if (traps->num_traps > ARRAY_LENGTH(stack_boxes)) {
boxes = _cairo_malloc_ab (traps->num_traps, sizeof(cairo_box_int_t));
- if (boxes == NULL) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
- return CAIRO_STATUS_NO_MEMORY;
- }
+ if (boxes == NULL)
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
}
box_count = 0;
diff --git a/src/cairo-truetype-subset.c b/src/cairo-truetype-subset.c
index 5afab3a3..0064bbb1 100644
--- a/src/cairo-truetype-subset.c
+++ b/src/cairo-truetype-subset.c
@@ -144,7 +144,7 @@ _cairo_truetype_font_create (cairo_scaled_font_subset_t *scaled_font_subset,
name = malloc(size);
if (name == NULL)
- return CAIRO_STATUS_NO_MEMORY;
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
status = backend->load_truetype_table (scaled_font_subset->scaled_font,
TT_TAG_name, 0, (unsigned char *) name,
@@ -154,7 +154,7 @@ _cairo_truetype_font_create (cairo_scaled_font_subset_t *scaled_font_subset,
font = malloc (sizeof (cairo_truetype_font_t));
if (font == NULL) {
- status = CAIRO_STATUS_NO_MEMORY;
+ status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto fail0;
}
@@ -171,13 +171,13 @@ _cairo_truetype_font_create (cairo_scaled_font_subset_t *scaled_font_subset,
font->glyphs = calloc (font->num_glyphs_in_face + 1, sizeof (subset_glyph_t));
if (font->glyphs == NULL) {
- status = CAIRO_STATUS_NO_MEMORY;
+ status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto fail1;
}
font->parent_to_subset = calloc (font->num_glyphs_in_face, sizeof (int));
if (font->parent_to_subset == NULL) {
- status = CAIRO_STATUS_NO_MEMORY;
+ status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto fail2;
}
@@ -221,7 +221,7 @@ _cairo_truetype_font_create (cairo_scaled_font_subset_t *scaled_font_subset,
if (font->base.base_font == NULL) {
font->base.base_font = malloc (30);
if (font->base.base_font == NULL) {
- status = CAIRO_STATUS_NO_MEMORY;
+ status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto fail3;
}
@@ -239,7 +239,7 @@ _cairo_truetype_font_create (cairo_scaled_font_subset_t *scaled_font_subset,
font->base.widths = calloc (font->num_glyphs_in_face, sizeof (int));
if (font->base.widths == NULL) {
- status = CAIRO_STATUS_NO_MEMORY;
+ status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto fail4;
}
@@ -248,7 +248,7 @@ _cairo_truetype_font_create (cairo_scaled_font_subset_t *scaled_font_subset,
if (status)
goto fail5;
- font->status = CAIRO_STATUS_SUCCESS;
+ font->status = _cairo_error (CAIRO_STATUS_SUCCESS);
*font_return = font;
@@ -270,8 +270,7 @@ _cairo_truetype_font_create (cairo_scaled_font_subset_t *scaled_font_subset,
if (name)
free (name);
- _cairo_error (status);
- return status;
+ return _cairo_error (status);
}
static void
@@ -511,8 +510,7 @@ cairo_truetype_font_write_glyf_table (cairo_truetype_font_t *font,
u.bytes = malloc (size);
if (u.bytes == NULL) {
- font->status = CAIRO_STATUS_NO_MEMORY;
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
+ font->status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
return font->status;
}
@@ -977,7 +975,7 @@ _cairo_truetype_subset_init (cairo_truetype_subset_t *truetype_subset,
truetype_subset->base_font = strdup (font->base.base_font);
if (truetype_subset->base_font == NULL) {
- status = CAIRO_STATUS_NO_MEMORY;
+ status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto fail1;
}
@@ -987,7 +985,7 @@ _cairo_truetype_subset_init (cairo_truetype_subset_t *truetype_subset,
truetype_subset->widths = calloc (sizeof (double),
font->scaled_font_subset->num_glyphs);
if (truetype_subset->widths == NULL) {
- status = CAIRO_STATUS_NO_MEMORY;
+ status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto fail2;
}
for (i = 0; i < font->scaled_font_subset->num_glyphs; i++)
@@ -1003,7 +1001,7 @@ _cairo_truetype_subset_init (cairo_truetype_subset_t *truetype_subset,
if (length) {
truetype_subset->data = malloc (length);
if (truetype_subset->data == NULL) {
- status = CAIRO_STATUS_NO_MEMORY;
+ status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto fail3;
}
@@ -1016,7 +1014,7 @@ _cairo_truetype_subset_init (cairo_truetype_subset_t *truetype_subset,
offsets_length = num_strings * sizeof (unsigned long);
truetype_subset->string_offsets = malloc (offsets_length);
if (truetype_subset->string_offsets == NULL) {
- status = CAIRO_STATUS_NO_MEMORY;
+ status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto fail4;
}
@@ -1040,8 +1038,7 @@ _cairo_truetype_subset_init (cairo_truetype_subset_t *truetype_subset,
fail1:
cairo_truetype_font_destroy (font);
- _cairo_error (status);
- return status;
+ return _cairo_error (status);
}
void
@@ -1086,10 +1083,8 @@ _cairo_truetype_map_glyphs_to_unicode (cairo_scaled_font_subset_t *font_subset,
size = be16_to_cpu (map->length);
map = malloc (size);
- if (map == NULL) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
- return CAIRO_STATUS_NO_MEMORY;
- }
+ if (map == NULL)
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
if (backend->load_truetype_table (font_subset->scaled_font,
TT_TAG_cmap, table_offset,
@@ -1173,10 +1168,8 @@ _cairo_truetype_create_glyph_to_unicode_map (cairo_scaled_font_subset_t *font_su
num_tables = be16_to_cpu (cmap->num_tables);
size = 4 + num_tables*sizeof(tt_cmap_index_t);
cmap = malloc (size);
- if (cmap == NULL) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
- return CAIRO_STATUS_NO_MEMORY;
- }
+ if (cmap == NULL)
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
if (backend->load_truetype_table (font_subset->scaled_font,
TT_TAG_cmap, 0, (unsigned char *) cmap,
diff --git a/src/cairo-type1-fallback.c b/src/cairo-type1-fallback.c
index 564b4b06..7f91643f 100644
--- a/src/cairo-type1-fallback.c
+++ b/src/cairo-type1-fallback.c
@@ -80,17 +80,14 @@ cairo_type1_font_create (cairo_scaled_font_subset_t *scaled_font_subset,
cairo_font_options_t font_options;
font = calloc (1, sizeof (cairo_type1_font_t));
- if (font == NULL) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
- return CAIRO_STATUS_NO_MEMORY;
- }
+ if (font == NULL)
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
font->widths = calloc (scaled_font_subset->num_glyphs,
sizeof (int));
if (font->widths == NULL) {
free (font);
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
- return CAIRO_STATUS_NO_MEMORY;
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
}
font->scaled_font_subset = scaled_font_subset;
@@ -122,7 +119,7 @@ fail:
free (font->widths);
free (font);
- return CAIRO_STATUS_NO_MEMORY;
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
}
/* Charstring commands. If the high byte is 0 the command is encoded
@@ -592,7 +589,7 @@ cairo_type1_font_write_private_dict (cairo_type1_font_t *font,
NULL,
font);
if (encrypted_output == NULL) {
- status = CAIRO_STATUS_NO_MEMORY;
+ status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto fail;
}
@@ -732,13 +729,13 @@ _cairo_type1_fallback_init_internal (cairo_type1_subset_t *type1_subset,
type1_subset->base_font = strdup (name);
if (type1_subset->base_font == NULL) {
- status = CAIRO_STATUS_NO_MEMORY;
+ status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto fail1;
}
type1_subset->widths = calloc (sizeof (int), font->scaled_font_subset->num_glyphs);
if (type1_subset->widths == NULL) {
- status = CAIRO_STATUS_NO_MEMORY;
+ status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto fail2;
}
for (i = 0; i < font->scaled_font_subset->num_glyphs; i++)
@@ -755,7 +752,7 @@ _cairo_type1_fallback_init_internal (cairo_type1_subset_t *type1_subset,
font->trailer_size;
type1_subset->data = malloc (length);
if (type1_subset->data == NULL) {
- status = CAIRO_STATUS_NO_MEMORY;
+ status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto fail3;
}
memcpy (type1_subset->data,
@@ -784,8 +781,7 @@ _cairo_type1_fallback_init_internal (cairo_type1_subset_t *type1_subset,
/* status is already set, ignore further errors */
cairo_type1_font_destroy (font);
- _cairo_error (status);
- return status;
+ return _cairo_error (status);
}
cairo_status_t
@@ -833,7 +829,7 @@ _cairo_type2_charstrings_init (cairo_type2_charstrings_t *type2_subset,
type2_subset->widths = calloc (sizeof (int), font->scaled_font_subset->num_glyphs);
if (type2_subset->widths == NULL) {
- status = CAIRO_STATUS_NO_MEMORY;
+ status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto fail1;
}
@@ -877,8 +873,7 @@ fail2:
_cairo_type2_charstrings_fini (type2_subset);
fail1:
cairo_type1_font_destroy (font);
- _cairo_error (status);
- return status;
+ return _cairo_error (status);
}
void
diff --git a/src/cairo-type1-subset.c b/src/cairo-type1-subset.c
index 793faf35..cbc4126d 100644
--- a/src/cairo-type1-subset.c
+++ b/src/cairo-type1-subset.c
@@ -120,7 +120,7 @@ _cairo_type1_font_subset_create (cairo_unscaled_font_t *unscaled_font,
face = _cairo_ft_unscaled_font_lock_face (ft_unscaled_font);
if (!face)
- return CAIRO_STATUS_NO_MEMORY;
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
if (FT_Get_PS_Font_Info(face, &font_info) != 0) {
status = CAIRO_INT_STATUS_UNSUPPORTED;
@@ -129,7 +129,7 @@ _cairo_type1_font_subset_create (cairo_unscaled_font_t *unscaled_font,
font = calloc (sizeof (cairo_type1_font_subset_t), 1);
if (font == NULL) {
- status = CAIRO_STATUS_NO_MEMORY;
+ status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto fail1;
}
@@ -143,7 +143,7 @@ _cairo_type1_font_subset_create (cairo_unscaled_font_t *unscaled_font,
font->base.descent = face->descender;
font->base.base_font = strdup (face->family_name);
if (font->base.base_font == NULL) {
- status = CAIRO_STATUS_NO_MEMORY;
+ status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto fail2;
}
@@ -156,7 +156,7 @@ _cairo_type1_font_subset_create (cairo_unscaled_font_t *unscaled_font,
font->glyphs = calloc (face->num_glyphs, sizeof font->glyphs[0]);
if (font->glyphs == NULL) {
- status = CAIRO_STATUS_NO_MEMORY;
+ status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto fail3;
}
@@ -182,7 +182,7 @@ _cairo_type1_font_subset_create (cairo_unscaled_font_t *unscaled_font,
_cairo_ft_unscaled_font_unlock_face (ft_unscaled_font);
if (status != CAIRO_INT_STATUS_UNSUPPORTED)
- _cairo_error (status);
+ status = _cairo_error (status);
return status;
}
@@ -373,8 +373,8 @@ cairo_type1_font_subset_decrypt_eexec_segment (cairo_type1_font_subset_t *font)
font->cleartext = malloc (font->eexec_segment_size);
if (font->cleartext == NULL) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
- return font->status = CAIRO_STATUS_NO_MEMORY;
+ font->status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
+ return font->status;
}
out = font->cleartext;
@@ -445,7 +445,7 @@ cairo_type1_font_subset_get_glyph_names_and_widths (cairo_type1_font_subset_t *f
FT_LOAD_NO_BITMAP | FT_LOAD_IGNORE_TRANSFORM);
if (error != 0) {
printf ("could not load glyph %d\n", i);
- return font->status = CAIRO_STATUS_NO_MEMORY;
+ return font->status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
}
font->glyphs[i].width = font->face->glyph->metrics.horiAdvance;
@@ -453,12 +453,12 @@ cairo_type1_font_subset_get_glyph_names_and_widths (cairo_type1_font_subset_t *f
error = FT_Get_Glyph_Name(font->face, i, buffer, sizeof buffer);
if (error != 0) {
printf ("could not get glyph name for glyph %d\n", i);
- return font->status = CAIRO_STATUS_NO_MEMORY;
+ return font->status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
}
font->glyphs[i].name = strdup (buffer);
if (font->glyphs[i].name == NULL)
- return font->status = CAIRO_STATUS_NO_MEMORY;
+ return font->status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
}
return CAIRO_STATUS_SUCCESS;
@@ -720,7 +720,7 @@ cairo_type1_font_subset_look_for_seac(cairo_type1_font_subset_t *font,
charstring = malloc (encrypted_charstring_length);
if (charstring == NULL) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
+ _cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
return;
}
@@ -1054,12 +1054,12 @@ cairo_type1_font_subset_generate (void *abstract_font,
font->face = _cairo_ft_unscaled_font_lock_face (ft_unscaled_font);
if (!font->face)
- return CAIRO_STATUS_NO_MEMORY;
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
font->type1_length = font->face->stream->size;
font->type1_data = malloc (font->type1_length);
if (font->type1_data == NULL) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
+ _cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
goto fail;
}
@@ -1123,7 +1123,7 @@ _cairo_type1_subset_init (cairo_type1_subset_t *type1_subset,
cairo_scaled_font_subset_t *scaled_font_subset,
cairo_bool_t hex_encode)
{
- cairo_type1_font_subset_t *font;
+ cairo_type1_font_subset_t *font = NULL; /* hide compiler warning */
cairo_status_t status;
unsigned long parent_glyph, length;
unsigned int i;
@@ -1197,7 +1197,7 @@ _cairo_type1_subset_init (cairo_type1_subset_t *type1_subset,
cairo_type1_font_subset_destroy (font);
if (status != CAIRO_INT_STATUS_UNSUPPORTED)
- _cairo_error (status);
+ status = _cairo_error (status);
return status;
}
diff --git a/src/cairo-unicode.c b/src/cairo-unicode.c
index 8ee6d246..2b224a3a 100644
--- a/src/cairo-unicode.c
+++ b/src/cairo-unicode.c
@@ -231,20 +231,18 @@ _cairo_utf8_to_ucs4 (const unsigned char *str,
{
uint32_t wc = _utf8_get_char_extended (in, str + len - in);
if (wc & 0x80000000 || !UNICODE_VALID (wc))
- return CAIRO_STATUS_INVALID_STRING;
+ return _cairo_error (CAIRO_STATUS_INVALID_STRING);
n_chars++;
if (n_chars == INT_MAX)
- return CAIRO_STATUS_INVALID_STRING;
+ return _cairo_error (CAIRO_STATUS_INVALID_STRING);
in = UTF8_NEXT_CHAR (in);
}
str32 = _cairo_malloc_ab (n_chars + 1, sizeof (uint32_t));
- if (!str32) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
- return CAIRO_STATUS_NO_MEMORY;
- }
+ if (!str32)
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
in = str;
for (i=0; i < n_chars; i++) {
@@ -296,7 +294,7 @@ _cairo_utf8_to_utf16 (const unsigned char *str,
while ((len < 0 || str + len - in > 0) && *in) {
uint32_t wc = _utf8_get_char_extended (in, str + len - in);
if (wc & 0x80000000 || !UNICODE_VALID (wc))
- return CAIRO_STATUS_INVALID_STRING;
+ return _cairo_error (CAIRO_STATUS_INVALID_STRING);
if (wc < 0x10000)
n16 += 1;
@@ -304,16 +302,14 @@ _cairo_utf8_to_utf16 (const unsigned char *str,
n16 += 2;
if (n16 == INT_MAX - 1 || n16 == INT_MAX)
- return CAIRO_STATUS_INVALID_STRING;
+ return _cairo_error (CAIRO_STATUS_INVALID_STRING);
in = UTF8_NEXT_CHAR (in);
}
str16 = _cairo_malloc_ab (n16 + 1, sizeof (uint16_t));
- if (!str16) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
- return CAIRO_STATUS_NO_MEMORY;
- }
+ if (!str16)
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
in = str;
for (i = 0; i < n16;) {
diff --git a/src/cairo-win32-font.c b/src/cairo-win32-font.c
index a883490e..9e6c3402 100644
--- a/src/cairo-win32-font.c
+++ b/src/cairo-win32-font.c
@@ -455,7 +455,7 @@ _cairo_win32_scaled_font_select_unscaled_font (cairo_scaled_font_t *scaled_font,
hfont = _win32_scaled_font_get_unscaled_hfont ((cairo_win32_scaled_font_t *)scaled_font, hdc);
if (!hfont)
- return CAIRO_STATUS_NO_MEMORY;
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
old_hfont = SelectObject (hdc, hfont);
if (!old_hfont)
@@ -499,7 +499,7 @@ _cairo_win32_scaled_font_create_toy (cairo_toy_font_face_t *toy_face,
if (face_name_len > LF_FACESIZE - 1) {
free (face_name);
- return CAIRO_STATUS_INVALID_STRING;
+ return _cairo_error (CAIRO_STATUS_INVALID_STRING);
}
memcpy (logfont.lfFaceName, face_name, sizeof (uint16_t) * (face_name_len + 1));
@@ -544,12 +544,12 @@ _cairo_win32_scaled_font_create_toy (cairo_toy_font_face_t *toy_face,
logfont.lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE;
if (!logfont.lfFaceName)
- return CAIRO_STATUS_NO_MEMORY;
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
scaled_font = _win32_scaled_font_create (&logfont, NULL, &toy_face->base,
font_matrix, ctm, options);
if (!scaled_font)
- return CAIRO_STATUS_NO_MEMORY;
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
*scaled_font_out = scaled_font;
@@ -610,13 +610,13 @@ _cairo_win32_scaled_font_text_to_glyphs (void *abstract_font,
buffer_size = MAX (n16 * 1.2, 16); /* Initially guess number of chars plus a few */
if (buffer_size > INT_MAX) {
- status = CAIRO_STATUS_NO_MEMORY;
+ status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto FAIL1;
}
hdc = _get_global_font_dc ();
if (!hdc) {
- status = CAIRO_STATUS_NO_MEMORY;
+ status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto FAIL1;
}
@@ -637,7 +637,7 @@ _cairo_win32_scaled_font_text_to_glyphs (void *abstract_font,
glyph_indices = _cairo_malloc_ab (buffer_size, sizeof (WCHAR));
dx = _cairo_malloc_ab (buffer_size, sizeof (int));
if (!glyph_indices || !dx) {
- status = CAIRO_STATUS_NO_MEMORY;
+ status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto FAIL2;
}
@@ -660,7 +660,7 @@ _cairo_win32_scaled_font_text_to_glyphs (void *abstract_font,
buffer_size *= 1.5;
if (buffer_size > INT_MAX) {
- status = CAIRO_STATUS_NO_MEMORY;
+ status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto FAIL2;
}
}
@@ -668,7 +668,7 @@ _cairo_win32_scaled_font_text_to_glyphs (void *abstract_font,
*num_glyphs = gcp_results.nGlyphs;
*glyphs = _cairo_malloc_ab (gcp_results.nGlyphs, sizeof (cairo_glyph_t));
if (!*glyphs) {
- status = CAIRO_STATUS_NO_MEMORY;
+ status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto FAIL2;
}
@@ -710,7 +710,7 @@ _cairo_win32_scaled_font_set_metrics (cairo_win32_scaled_font_t *scaled_font)
hdc = _get_global_font_dc ();
if (!hdc)
- return CAIRO_STATUS_NO_MEMORY;
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
if (scaled_font->preserve_axes || scaled_font->base.options.hint_metrics == CAIRO_HINT_METRICS_OFF) {
/* For 90-degree rotations (including 0), we get the metrics
@@ -773,7 +773,7 @@ _cairo_win32_scaled_font_init_glyph_metrics (cairo_win32_scaled_font_t *scaled_f
hdc = _get_global_font_dc ();
if (!hdc)
- return CAIRO_STATUS_NO_MEMORY;
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
if (scaled_font->glyph_indexing)
glyph_index_option = GGO_GLYPH_INDEX;
@@ -873,7 +873,7 @@ _cairo_win32_scaled_font_glyph_bbox (void *abstract_font,
UINT glyph_index_option;
if (!hdc)
- return CAIRO_STATUS_NO_MEMORY;
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
status = cairo_win32_scaled_font_select_font (&scaled_font->base, hdc);
if (status)
@@ -1215,7 +1215,7 @@ _cairo_win32_scaled_font_show_glyphs (void *abstract_font,
tmp_surface = (cairo_win32_surface_t *)cairo_win32_surface_create_with_dib (CAIRO_FORMAT_ARGB32, width, height);
if (tmp_surface->base.status)
- return CAIRO_STATUS_NO_MEMORY;
+ return tmp_surface->base.status;
r.left = 0;
r.top = 0;
@@ -1248,7 +1248,7 @@ _cairo_win32_scaled_font_show_glyphs (void *abstract_font,
mask_surface = _compute_a8_mask (tmp_surface);
cairo_surface_destroy (&tmp_surface->base);
if (!mask_surface)
- return CAIRO_STATUS_NO_MEMORY;
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
}
/* For op == OVER, no-cleartype, a possible optimization here is to
@@ -1286,7 +1286,7 @@ _cairo_win32_scaled_font_load_truetype_table (void *abstract_font,
cairo_win32_scaled_font_t *scaled_font = abstract_font;
hdc = _get_global_font_dc ();
if (!hdc)
- return CAIRO_STATUS_NO_MEMORY;
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
tag = (tag&0x000000ff)<<24 | (tag&0x0000ff00)<<8 | (tag&0x00ff0000)>>8 | (tag&0xff000000)>>24;
status = _cairo_win32_scaled_font_select_unscaled_font (&scaled_font->base, hdc);
@@ -1345,11 +1345,11 @@ _cairo_win32_scaled_font_init_glyph_path (cairo_win32_scaled_font_t *scaled_font
hdc = _get_global_font_dc ();
if (!hdc)
- return CAIRO_STATUS_NO_MEMORY;
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
path = _cairo_path_fixed_create ();
if (!path)
- return CAIRO_STATUS_NO_MEMORY;
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
if (scaled_font->base.options.hint_style == CAIRO_HINT_STYLE_NONE) {
status = _cairo_win32_scaled_font_select_unscaled_font (&scaled_font->base, hdc);
@@ -1379,7 +1379,7 @@ _cairo_win32_scaled_font_init_glyph_path (cairo_win32_scaled_font_t *scaled_font
ptr = buffer = malloc (bytesGlyph);
if (!buffer) {
- status = CAIRO_STATUS_NO_MEMORY;
+ status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto CLEANUP_FONT;
}
@@ -1557,7 +1557,7 @@ _cairo_win32_font_face_scaled_font_create (void *abstract_face,
if (*font)
return CAIRO_STATUS_SUCCESS;
else
- return CAIRO_STATUS_NO_MEMORY;
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
}
static const cairo_font_face_backend_t _cairo_win32_font_face_backend = {
@@ -1694,7 +1694,7 @@ cairo_win32_scaled_font_select_font (cairo_scaled_font_t *scaled_font,
hfont = _win32_scaled_font_get_scaled_hfont ((cairo_win32_scaled_font_t *)scaled_font);
if (!hfont)
- return CAIRO_STATUS_NO_MEMORY;
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
old_hfont = SelectObject (hdc, hfont);
if (!old_hfont)
diff --git a/src/cairo-win32-surface.c b/src/cairo-win32-surface.c
index 4b27a8db..7b943251 100644
--- a/src/cairo-win32-surface.c
+++ b/src/cairo-win32-surface.c
@@ -105,7 +105,7 @@ _cairo_win32_print_gdi_error (const char *context)
* is no CAIRO_STATUS_UNKNOWN_ERROR.
*/
- return CAIRO_STATUS_NO_MEMORY;
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
}
uint32_t
@@ -187,10 +187,8 @@ _create_dc_and_bitmap (cairo_win32_surface_t *surface,
if (num_palette > 2) {
bitmap_info = _cairo_malloc_ab_plus_c (num_palette, sizeof(RGBQUAD), sizeof(BITMAPINFOHEADER));
- if (!bitmap_info) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
- return CAIRO_STATUS_NO_MEMORY;
- }
+ if (!bitmap_info)
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
} else {
bitmap_info = (BITMAPINFO *)&bmi_stack;
}
@@ -349,7 +347,7 @@ _cairo_win32_surface_create_for_dc (HDC original_dc,
surface->image = cairo_image_surface_create_for_data (bits, format,
width, height, rowstride);
if (surface->image->status) {
- status = CAIRO_STATUS_NO_MEMORY;
+ status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto FAIL;
}
@@ -517,7 +515,7 @@ _cairo_win32_surface_get_subimage (cairo_win32_surface_t *surface,
(cairo_win32_surface_t *) _cairo_win32_surface_create_similar_internal
(surface, content, width, height, TRUE);
if (local->base.status)
- return CAIRO_STATUS_NO_MEMORY;
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
status = CAIRO_INT_STATUS_UNSUPPORTED;
@@ -1452,6 +1450,7 @@ _cairo_win32_surface_set_clip_region (void *abstract_surface,
} else {
cairo_rectangle_int_t extents;
cairo_box_int_t *boxes;
+ cairo_status_t status;
int num_boxes;
RGNDATA *data;
size_t data_size;
@@ -1462,15 +1461,15 @@ _cairo_win32_surface_set_clip_region (void *abstract_surface,
/* Create a GDI region for the cairo region */
_cairo_region_get_extents (region, &extents);
- if (_cairo_region_get_boxes (region, &num_boxes, &boxes) != CAIRO_STATUS_SUCCESS)
- return CAIRO_STATUS_NO_MEMORY;
+ status = _cairo_region_get_boxes (region, &num_boxes, &boxes);
+ if (status)
+ return status;
data_size = sizeof (RGNDATAHEADER) + num_boxes * sizeof (RECT);
data = malloc (data_size);
if (!data) {
_cairo_region_boxes_fini (region, boxes);
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
- return CAIRO_STATUS_NO_MEMORY;
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
}
rects = (RECT *)data->Buffer;
@@ -1496,7 +1495,7 @@ _cairo_win32_surface_set_clip_region (void *abstract_surface,
free (data);
if (!gdi_region)
- return CAIRO_STATUS_NO_MEMORY;
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
/* Combine the new region with the original clip */
diff --git a/src/cairo-xcb-surface.c b/src/cairo-xcb-surface.c
index d5c27d65..451cc8f4 100644
--- a/src/cairo-xcb-surface.c
+++ b/src/cairo-xcb-surface.c
@@ -398,7 +398,7 @@ _get_image_surface (cairo_xcb_surface_t *surface,
}
if (!imagerep)
- return CAIRO_STATUS_NO_MEMORY;
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
bpp = _bits_per_pixel(surface->dpy, imagerep->depth);
bytes_per_line = _bytes_per_line(surface->dpy, surface->width, bpp);
@@ -406,8 +406,7 @@ _get_image_surface (cairo_xcb_surface_t *surface,
data = _cairo_malloc_ab (surface->height, bytes_per_line);
if (data == NULL) {
free (imagerep);
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
- return CAIRO_STATUS_NO_MEMORY;
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
}
memcpy (data, xcb_get_image_data (imagerep), bytes_per_line * surface->height);
@@ -480,7 +479,7 @@ _get_image_surface (cairo_xcb_surface_t *surface,
FAIL:
free (data);
- return CAIRO_STATUS_NO_MEMORY;
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
}
static void
@@ -592,7 +591,8 @@ _draw_image_surface (cairo_xcb_surface_t *surface,
data_len = height * data_bpl;
data_line = data = malloc(data_len);
if (data == NULL)
- return CAIRO_STATUS_NO_MEMORY;
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
+
image_line = image->data + src_y * bpl + (src_x * bpp / 8);
while (line++ < height) {
memcpy(data_line, image_line, data_bpl);
@@ -721,7 +721,7 @@ _cairo_xcb_surface_clone_similar (void *abstract_surface,
_cairo_xcb_surface_create_similar (surface, content,
image_src->width, image_src->height);
if (clone->base.status)
- return CAIRO_STATUS_NO_MEMORY;
+ return clone->base.status;
_draw_image_surface (clone, image_src, src_x, src_y,
width, height, src_x, src_y);
@@ -1266,10 +1266,8 @@ _cairo_xcb_surface_fill_rectangles (void *abstract_surface,
if (num_rects > ARRAY_LENGTH(static_xrects)) {
xrects = _cairo_malloc_ab (num_rects, sizeof(xcb_rectangle_t));
- if (xrects == NULL) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
- return CAIRO_STATUS_NO_MEMORY;
- }
+ if (xrects == NULL)
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
}
for (i = 0; i < num_rects; i++) {
@@ -1468,7 +1466,7 @@ _cairo_xcb_surface_composite_trapezoids (cairo_operator_t op,
dst_x, dst_y, width, height,
render_format);
if (!mask_picture) {
- status = CAIRO_STATUS_NO_MEMORY;
+ status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto BAIL;
}
@@ -1500,8 +1498,7 @@ _cairo_xcb_surface_composite_trapezoids (cairo_operator_t op,
if (num_traps > ARRAY_LENGTH(xtraps_stack)) {
xtraps = _cairo_malloc_ab (num_traps, sizeof(xcb_render_trapezoid_t));
if (xtraps == NULL) {
- status = CAIRO_STATUS_NO_MEMORY;
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
+ status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto BAIL;
}
}
@@ -1561,18 +1558,19 @@ _cairo_xcb_surface_set_clip_region (void *abstract_surface,
XCB_RENDER_CP_CLIP_MASK, none);
} else {
cairo_box_int_t *boxes;
+ cairo_status_t status;
xcb_rectangle_t *rects = NULL;
int n_boxes, i;
- if (_cairo_region_get_boxes (region, &n_boxes, &boxes) != CAIRO_STATUS_SUCCESS)
- return CAIRO_STATUS_NO_MEMORY;
+ status = _cairo_region_get_boxes (region, &n_boxes, &boxes);
+ if (status)
+ return status;
if (n_boxes > 0) {
rects = _cairo_malloc_ab (n_boxes, sizeof(xcb_rectangle_t));
if (rects == NULL) {
_cairo_region_boxes_fini (region, boxes);
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
- return CAIRO_STATUS_NO_MEMORY;
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
}
} else {
rects = NULL;
@@ -1996,10 +1994,8 @@ _cairo_xcb_surface_font_init (xcb_connection_t *dpy,
cairo_xcb_surface_font_private_t *font_private;
font_private = malloc (sizeof (cairo_xcb_surface_font_private_t));
- if (!font_private) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
- return CAIRO_STATUS_NO_MEMORY;
- }
+ if (!font_private)
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
font_private->dpy = dpy;
font_private->format = format;
@@ -2117,8 +2113,7 @@ _cairo_xcb_surface_add_glyph (xcb_connection_t *dpy,
new = malloc (c);
if (!new) {
- status = CAIRO_STATUS_NO_MEMORY;
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
+ status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto BAIL;
}
n = new;
@@ -2144,8 +2139,7 @@ _cairo_xcb_surface_add_glyph (xcb_connection_t *dpy,
new = malloc (c);
if (new == NULL) {
- status = CAIRO_STATUS_NO_MEMORY;
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
+ status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto BAIL;
}
n = new;
@@ -2385,10 +2379,8 @@ _cairo_xcb_surface_show_glyphs (void *abstract_dst,
* glyphs to workaround an X server bug, (present in at least Xorg
* 7.1 without EXA). */
output_glyphs = _cairo_malloc_ab (num_glyphs, sizeof (cairo_glyph_t));
- if (output_glyphs == NULL) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
- return CAIRO_STATUS_NO_MEMORY;
- }
+ if (output_glyphs == NULL)
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
/* After passing all those tests, we're now committed to rendering
* these glyphs or to fail trying. We first upload any glyphs to
diff --git a/src/cairo-xlib-display.c b/src/cairo-xlib-display.c
index 6e8f2ba5..83170f59 100644
--- a/src/cairo-xlib-display.c
+++ b/src/cairo-xlib-display.c
@@ -252,7 +252,7 @@ _cairo_xlib_display_get (Display *dpy)
display = malloc (sizeof (cairo_xlib_display_t));
if (display == NULL) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
+ _cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
goto UNLOCK;
}
diff --git a/src/cairo-xlib-surface.c b/src/cairo-xlib-surface.c
index 65e2d6a8..e67a5f91 100644
--- a/src/cairo-xlib-surface.c
+++ b/src/cairo-xlib-surface.c
@@ -172,7 +172,7 @@ _cairo_xlib_surface_create_similar_with_format (void *abstract_src,
width, height);
if (surface->base.status != CAIRO_STATUS_SUCCESS) {
XFreePixmap (dpy, pix);
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
+ _cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
return (cairo_surface_t*) &_cairo_surface_nil;
}
@@ -252,7 +252,7 @@ _cairo_xlib_surface_create_similar (void *abstract_src,
width, height);
if (surface->base.status != CAIRO_STATUS_SUCCESS) {
XFreePixmap (src->dpy, pix);
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
+ _cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
return (cairo_surface_t*) &_cairo_surface_nil;
}
@@ -558,7 +558,7 @@ _get_image_surface (cairo_xlib_surface_t *surface,
}
}
if (!ximage)
- return CAIRO_STATUS_NO_MEMORY;
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
_swap_ximage_to_native (ximage);
@@ -615,7 +615,7 @@ _get_image_surface (cairo_xlib_surface_t *surface,
FAIL:
XDestroyImage (ximage);
- return CAIRO_STATUS_NO_MEMORY;
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
}
static void
@@ -694,7 +694,7 @@ _cairo_xlib_surface_ensure_gc (cairo_xlib_surface_t *surface)
surface->gc = XCreateGC (surface->dpy, surface->drawable,
GCGraphicsExposures, &gcv);
if (!surface->gc)
- return CAIRO_STATUS_NO_MEMORY;
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
}
_cairo_xlib_surface_set_gc_clip_rects (surface);
@@ -863,7 +863,7 @@ _cairo_xlib_surface_clone_similar (void *abstract_surface,
_cairo_xlib_surface_create_similar_with_format (surface, image_src->format,
image_src->width, image_src->height);
if (clone->base.status)
- return CAIRO_STATUS_NO_MEMORY;
+ return clone->base.status;
status = _draw_image_surface (clone, image_src, src_x, src_y,
width, height, src_x, src_y);
@@ -1445,10 +1445,8 @@ _cairo_xlib_surface_fill_rectangles (void *abstract_surface,
if (num_rects > ARRAY_LENGTH(static_xrects)) {
xrects = _cairo_malloc_ab (num_rects, sizeof(XRectangle));
- if (xrects == NULL) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
- return CAIRO_STATUS_NO_MEMORY;
- }
+ if (xrects == NULL)
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
}
for (i = 0; i < num_rects; i++) {
@@ -1536,7 +1534,7 @@ _create_trapezoid_mask (cairo_xlib_surface_t *dst,
offset_traps = _cairo_malloc_ab (num_traps, sizeof (XTrapezoid));
if (!offset_traps) {
XRenderFreePicture (dst->dpy, mask_picture);
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
+ _cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
return None;
}
@@ -1654,7 +1652,7 @@ _cairo_xlib_surface_composite_trapezoids (cairo_operator_t op,
dst_x, dst_y, width, height,
pict_format);
if (!mask_picture) {
- status = CAIRO_STATUS_NO_MEMORY;
+ status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto BAIL;
}
@@ -1686,8 +1684,7 @@ _cairo_xlib_surface_composite_trapezoids (cairo_operator_t op,
if (num_traps > ARRAY_LENGTH(xtraps_stack)) {
xtraps = _cairo_malloc_ab (num_traps, sizeof(XTrapezoid));
if (xtraps == NULL) {
- status = CAIRO_STATUS_NO_MEMORY;
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
+ status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto BAIL;
}
}
@@ -1742,18 +1739,19 @@ _cairo_xlib_surface_set_clip_region (void *abstract_surface,
if (region != NULL) {
cairo_box_int_t *boxes;
+ cairo_status_t status;
XRectangle *rects = NULL;
int n_boxes, i;
- if (_cairo_region_get_boxes (region, &n_boxes, &boxes) != CAIRO_STATUS_SUCCESS)
- return CAIRO_STATUS_NO_MEMORY;
+ status = _cairo_region_get_boxes (region, &n_boxes, &boxes);
+ if (status)
+ return status;
if (n_boxes > ARRAY_LENGTH (surface->embedded_clip_rects)) {
rects = _cairo_malloc_ab (n_boxes, sizeof(XRectangle));
if (rects == NULL) {
_cairo_region_boxes_fini (region, boxes);
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
- return CAIRO_STATUS_NO_MEMORY;
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
}
} else {
rects = surface->embedded_clip_rects;
@@ -1942,14 +1940,14 @@ _cairo_xlib_surface_create_internal (Display *dpy,
screen_info = _cairo_xlib_screen_info_get (dpy, screen);
if (screen_info == NULL) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
+ _cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
return (cairo_surface_t*) &_cairo_surface_nil;
}
surface = malloc (sizeof (cairo_xlib_surface_t));
if (surface == NULL) {
_cairo_xlib_screen_info_destroy (screen_info);
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
+ _cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
return (cairo_surface_t*) &_cairo_surface_nil;
}
@@ -1957,7 +1955,7 @@ _cairo_xlib_surface_create_internal (Display *dpy,
_cairo_xlib_surface_detach_display, surface, surface)) {
free (surface);
_cairo_xlib_screen_info_destroy (screen_info);
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
+ _cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
return (cairo_surface_t*) &_cairo_surface_nil;
}
@@ -2096,7 +2094,7 @@ cairo_xlib_surface_create (Display *dpy,
Screen *screen = _cairo_xlib_screen_from_visual (dpy, visual);
if (screen == NULL) {
- _cairo_error (CAIRO_STATUS_INVALID_VISUAL);
+ _cairo_error_throw (CAIRO_STATUS_INVALID_VISUAL);
return (cairo_surface_t*) &_cairo_surface_nil;
}
@@ -2185,10 +2183,11 @@ cairo_xlib_surface_set_size (cairo_surface_t *abstract_surface,
int height)
{
cairo_xlib_surface_t *surface = (cairo_xlib_surface_t *) abstract_surface;
+ cairo_status_t status;
if (! _cairo_surface_is_xlib (abstract_surface)) {
- _cairo_surface_set_error (abstract_surface,
- CAIRO_STATUS_SURFACE_TYPE_MISMATCH);
+ status = _cairo_surface_set_error (abstract_surface,
+ CAIRO_STATUS_SURFACE_TYPE_MISMATCH);
return;
}
@@ -2219,7 +2218,8 @@ cairo_xlib_surface_set_drawable (cairo_surface_t *abstract_surface,
cairo_status_t status;
if (! _cairo_surface_is_xlib (abstract_surface)) {
- _cairo_surface_set_error (abstract_surface, CAIRO_STATUS_SURFACE_TYPE_MISMATCH);
+ status = _cairo_surface_set_error (abstract_surface,
+ CAIRO_STATUS_SURFACE_TYPE_MISMATCH);
return;
}
@@ -2234,7 +2234,7 @@ cairo_xlib_surface_set_drawable (cairo_surface_t *abstract_surface,
XRenderFreePicture,
surface->dst_picture);
if (status) {
- _cairo_surface_set_error (&surface->base, status);
+ status = _cairo_surface_set_error (&surface->base, status);
return;
}
@@ -2247,7 +2247,7 @@ cairo_xlib_surface_set_drawable (cairo_surface_t *abstract_surface,
XRenderFreePicture,
surface->src_picture);
if (status) {
- _cairo_surface_set_error (&surface->base, status);
+ status = _cairo_surface_set_error (&surface->base, status);
return;
}
@@ -2276,7 +2276,7 @@ cairo_xlib_surface_get_display (cairo_surface_t *abstract_surface)
cairo_xlib_surface_t *surface = (cairo_xlib_surface_t *) abstract_surface;
if (! _cairo_surface_is_xlib (abstract_surface)) {
- _cairo_error (CAIRO_STATUS_SURFACE_TYPE_MISMATCH);
+ _cairo_error_throw (CAIRO_STATUS_SURFACE_TYPE_MISMATCH);
return NULL;
}
@@ -2299,7 +2299,7 @@ cairo_xlib_surface_get_drawable (cairo_surface_t *abstract_surface)
cairo_xlib_surface_t *surface = (cairo_xlib_surface_t *) abstract_surface;
if (! _cairo_surface_is_xlib (abstract_surface)) {
- _cairo_error (CAIRO_STATUS_SURFACE_TYPE_MISMATCH);
+ _cairo_error_throw (CAIRO_STATUS_SURFACE_TYPE_MISMATCH);
return 0;
}
@@ -2322,7 +2322,7 @@ cairo_xlib_surface_get_screen (cairo_surface_t *abstract_surface)
cairo_xlib_surface_t *surface = (cairo_xlib_surface_t *) abstract_surface;
if (! _cairo_surface_is_xlib (abstract_surface)) {
- _cairo_error (CAIRO_STATUS_SURFACE_TYPE_MISMATCH);
+ _cairo_error_throw (CAIRO_STATUS_SURFACE_TYPE_MISMATCH);
return NULL;
}
@@ -2345,7 +2345,7 @@ cairo_xlib_surface_get_visual (cairo_surface_t *abstract_surface)
cairo_xlib_surface_t *surface = (cairo_xlib_surface_t *) abstract_surface;
if (! _cairo_surface_is_xlib (abstract_surface)) {
- _cairo_error (CAIRO_STATUS_SURFACE_TYPE_MISMATCH);
+ _cairo_error_throw (CAIRO_STATUS_SURFACE_TYPE_MISMATCH);
return NULL;
}
@@ -2368,7 +2368,7 @@ cairo_xlib_surface_get_depth (cairo_surface_t *abstract_surface)
cairo_xlib_surface_t *surface = (cairo_xlib_surface_t *) abstract_surface;
if (! _cairo_surface_is_xlib (abstract_surface)) {
- _cairo_error (CAIRO_STATUS_SURFACE_TYPE_MISMATCH);
+ _cairo_error_throw (CAIRO_STATUS_SURFACE_TYPE_MISMATCH);
return 0;
}
@@ -2391,7 +2391,7 @@ cairo_xlib_surface_get_width (cairo_surface_t *abstract_surface)
cairo_xlib_surface_t *surface = (cairo_xlib_surface_t *) abstract_surface;
if (! _cairo_surface_is_xlib (abstract_surface)) {
- _cairo_error (CAIRO_STATUS_SURFACE_TYPE_MISMATCH);
+ _cairo_error_throw (CAIRO_STATUS_SURFACE_TYPE_MISMATCH);
return -1;
}
@@ -2414,7 +2414,7 @@ cairo_xlib_surface_get_height (cairo_surface_t *abstract_surface)
cairo_xlib_surface_t *surface = (cairo_xlib_surface_t *) abstract_surface;
if (! _cairo_surface_is_xlib (abstract_surface)) {
- _cairo_error (CAIRO_STATUS_SURFACE_TYPE_MISMATCH);
+ _cairo_error_throw (CAIRO_STATUS_SURFACE_TYPE_MISMATCH);
return -1;
}
@@ -2456,17 +2456,14 @@ _cairo_xlib_surface_font_init (Display *dpy,
cairo_xlib_surface_font_private_t *font_private;
font_private = malloc (sizeof (cairo_xlib_surface_font_private_t));
- if (!font_private) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
- return CAIRO_STATUS_NO_MEMORY;
- }
+ if (!font_private)
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
if (!_cairo_xlib_add_close_display_hook (dpy,
_cairo_xlib_surface_remove_scaled_font,
scaled_font, scaled_font)) {
free (font_private);
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
- return CAIRO_STATUS_NO_MEMORY;
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
}
@@ -2624,7 +2621,7 @@ _cairo_xlib_surface_add_glyph (Display *dpy,
new = malloc (c);
if (!new) {
- status = CAIRO_STATUS_NO_MEMORY;
+ status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto BAIL;
}
n = new;
@@ -2650,8 +2647,7 @@ _cairo_xlib_surface_add_glyph (Display *dpy,
new = malloc (c);
if (new == NULL) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
- status = CAIRO_STATUS_NO_MEMORY;
+ status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto BAIL;
}
n = new;
@@ -2778,10 +2774,8 @@ _cairo_xlib_surface_emit_glyphs_chunk (cairo_xlib_surface_t *dst,
elts = stack_elts;
} else {
elts = _cairo_malloc_ab (num_elts, sizeof (XGlyphElt8));
- if (elts == NULL) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
- return CAIRO_STATUS_NO_MEMORY;
- }
+ if (elts == NULL)
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
}
/* Fill them in */
diff --git a/src/cairo.c b/src/cairo.c
index 5273cb0d..ef628e71 100644
--- a/src/cairo.c
+++ b/src/cairo.c
@@ -118,7 +118,7 @@ _cairo_set_error (cairo_t *cr, cairo_status_t status)
* error, which is the most significant. */
_cairo_status_set_error (&cr->status, status);
- _cairo_error (status);
+ status = _cairo_error (status);
}
/**
@@ -199,7 +199,7 @@ cairo_create (cairo_surface_t *target)
cr = malloc (sizeof (cairo_t));
if (cr == NULL) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
+ status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
return (cairo_t *) &_cairo_nil;
}
@@ -327,7 +327,7 @@ cairo_set_user_data (cairo_t *cr,
cairo_destroy_func_t destroy)
{
if (CAIRO_REFERENCE_COUNT_IS_INVALID (&cr->ref_count))
- return CAIRO_STATUS_NO_MEMORY;
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
return _cairo_user_data_array_set_data (&cr->user_data,
key, user_data, destroy);
@@ -2419,7 +2419,7 @@ _cairo_rectangle_list_create_in_error (cairo_status_t status)
list = malloc (sizeof (cairo_rectangle_list_t));
if (list == NULL) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
+ status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
return (cairo_rectangle_list_t*) &_cairo_rectangles_nil;
}
diff --git a/src/cairoint.h b/src/cairoint.h
index cb764d2c..73822922 100644
--- a/src/cairoint.h
+++ b/src/cairoint.h
@@ -1623,7 +1623,7 @@ extern const cairo_private cairo_surface_t _cairo_surface_nil_read_error;
extern const cairo_private cairo_surface_t _cairo_surface_nil_write_error;
extern const cairo_private cairo_surface_t _cairo_surface_nil_file_not_found;
-cairo_private void
+cairo_private cairo_status_t
_cairo_surface_set_error (cairo_surface_t *surface,
cairo_status_t status);
@@ -2302,6 +2302,12 @@ _cairo_utf8_to_utf16 (const unsigned char *str,
cairo_private cairo_status_t
_cairo_error (cairo_status_t status);
+/* hide compiler warnings when discarding the return value */
+#define _cairo_error_throw(status) do { \
+ cairo_status_t status__ = _cairo_error (status); \
+ (void) status__; \
+} while (0)
+
/* Avoid unnecessary PLT entries. */
slim_hidden_proto (cairo_clip_preserve);
slim_hidden_proto (cairo_close_path);
diff --git a/src/test-fallback-surface.c b/src/test-fallback-surface.c
index db258741..3db945de 100644
--- a/src/test-fallback-surface.c
+++ b/src/test-fallback-surface.c
@@ -81,7 +81,7 @@ _cairo_test_fallback_surface_create (cairo_content_t content,
surface = malloc (sizeof (test_fallback_surface_t));
if (surface == NULL) {
cairo_surface_destroy (backing);
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
+ _cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
return (cairo_surface_t*) &_cairo_surface_nil;
}
diff --git a/src/test-meta-surface.c b/src/test-meta-surface.c
index 82fde5fc..773d0115 100644
--- a/src/test-meta-surface.c
+++ b/src/test-meta-surface.c
@@ -76,10 +76,8 @@ _cairo_test_meta_surface_create (cairo_content_t content,
test_meta_surface_t *surface;
surface = malloc (sizeof (test_meta_surface_t));
- if (surface == NULL) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
+ if (surface == NULL)
goto FAIL;
- }
_cairo_surface_init (&surface->base, &test_meta_surface_backend,
content);
@@ -102,7 +100,7 @@ _cairo_test_meta_surface_create (cairo_content_t content,
FAIL_CLEANUP_SURFACE:
free (surface);
FAIL:
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
+ _cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
return (cairo_surface_t*) &_cairo_surface_nil;
}
diff --git a/src/test-paginated-surface.c b/src/test-paginated-surface.c
index 1e08c2d8..3e9bad8c 100644
--- a/src/test-paginated-surface.c
+++ b/src/test-paginated-surface.c
@@ -75,14 +75,12 @@ _cairo_test_paginated_surface_create_for_data (unsigned char *data,
width, height,
stride);
status = cairo_surface_status (target);
- if (status) {
- _cairo_error (status);
+ if (status)
return (cairo_surface_t *) &_cairo_surface_nil;
- }
surface = malloc (sizeof (test_paginated_surface_t));
if (surface == NULL) {
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
+ _cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
return (cairo_surface_t *) &_cairo_surface_nil;
}