[cairo-commit] 3 commits - src/cairo-analysis-surface.c src/cairo-array.c src/cairo-atomic.c src/cairo-atomic-private.h src/cairo-atsui-font.c src/cairo-base85-stream.c src/cairo-bentley-ottmann.c src/cairo.c src/cairo-cache.c src/cairo-cff-subset.c src/cairo-clip.c src/cairo-deflate-stream.c src/cairo-directfb-surface.c src/cairo-font-face.c src/cairo-font-options.c src/cairo-ft-font.c src/cairo-glitz-surface.c src/cairo-gstate.c src/cairo-hash.c src/cairo-hull.c src/cairo-image-surface.c src/cairoint.h src/cairo-lzw.c src/cairo-matrix.c src/cairo-meta-surface.c src/cairo-os2-surface.c src/cairo-output-stream.c src/cairo-paginated-surface.c src/cairo-path.c src/cairo-path-fixed.c src/cairo-path-stroke.c src/cairo-pattern.c src/cairo-pdf-surface.c src/cairo-pen.c src/cairo-png.c src/cairo-polygon.c src/cairo-ps-surface.c src/cairo-quartz-surface.c src/cairo-region.c src/cairo-scaled-font.c src/cairo-scaled-font-subsets.c src/cairo-skiplist.c src/cairo-spline.c src/cairo-stroke-style.c src/cairo-surface.c src/cairo-surface-fallback.c src/cairo-svg-surface.c src/cairo-traps.c src/cairo-truetype-subset.c src/cairo-type1-fallback.c src/cairo-type1-subset.c src/cairo-unicode.c src/cairo-win32-font.c src/cairo-win32-surface.c src/cairo-xcb-surface.c src/cairo-xlib-display.c src/cairo-xlib-surface.c src/test-fallback-surface.c src/test-meta-surface.c src/test-paginated-surface.c
Chris Wilson
ickle at kemper.freedesktop.org
Thu Oct 4 06:07:10 PDT 2007
src/cairo-analysis-surface.c | 4 -
src/cairo-array.c | 9 --
src/cairo-atomic-private.h | 8 ++
src/cairo-atomic.c | 15 ++++
src/cairo-atsui-font.c | 18 ++---
src/cairo-base85-stream.c | 2
src/cairo-bentley-ottmann.c | 22 ++-----
src/cairo-cache.c | 4 -
src/cairo-cff-subset.c | 122 +++++++++++++++-------------------------
src/cairo-clip.c | 18 ++---
src/cairo-deflate-stream.c | 2
src/cairo-directfb-surface.c | 49 +++++++---------
src/cairo-font-face.c | 6 -
src/cairo-font-options.c | 4 -
src/cairo-ft-font.c | 111 ++++++++++++++----------------------
src/cairo-glitz-surface.c | 89 ++++++++++++-----------------
src/cairo-gstate.c | 37 ++++--------
src/cairo-hash.c | 10 +--
src/cairo-hull.c | 2
src/cairo-image-surface.c | 47 ++++++---------
src/cairo-lzw.c | 6 -
src/cairo-matrix.c | 4 -
src/cairo-meta-surface.c | 48 +++++----------
src/cairo-os2-surface.c | 24 +++----
src/cairo-output-stream.c | 18 ++---
src/cairo-paginated-surface.c | 8 --
src/cairo-path-fixed.c | 14 ++--
src/cairo-path-stroke.c | 6 -
src/cairo-path.c | 16 ++---
src/cairo-pattern.c | 80 +++++++++++---------------
src/cairo-pdf-surface.c | 62 ++++++++------------
src/cairo-pen.c | 19 ++----
src/cairo-png.c | 24 +++----
src/cairo-polygon.c | 6 -
src/cairo-ps-surface.c | 63 ++++++++------------
src/cairo-quartz-surface.c | 15 +---
src/cairo-region.c | 22 ++-----
src/cairo-scaled-font-subsets.c | 20 ++----
src/cairo-scaled-font.c | 29 ++++-----
src/cairo-skiplist.c | 2
src/cairo-spline.c | 6 -
src/cairo-stroke-style.c | 6 -
src/cairo-surface-fallback.c | 10 +--
src/cairo-surface.c | 95 ++++++++++++++++---------------
src/cairo-svg-surface.c | 24 ++-----
src/cairo-traps.c | 9 --
src/cairo-truetype-subset.c | 43 +++++---------
src/cairo-type1-fallback.c | 27 +++-----
src/cairo-type1-subset.c | 30 ++++-----
src/cairo-unicode.c | 20 ++----
src/cairo-win32-font.c | 40 ++++++-------
src/cairo-win32-surface.c | 23 +++----
src/cairo-xcb-surface.c | 50 ++++++----------
src/cairo-xlib-display.c | 2
src/cairo-xlib-surface.c | 88 +++++++++++++---------------
src/cairo.c | 26 ++++----
src/cairoint.h | 10 ++-
src/test-fallback-surface.c | 2
src/test-meta-surface.c | 6 -
src/test-paginated-surface.c | 6 -
60 files changed, 701 insertions(+), 887 deletions(-)
New commits:
diff-tree bed8239f03773ad1584c8ba48ceb0b34bbe69453 (from d90d4bb6b99e0a912650234e28d097ea76c1cecc)
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date: Thu Oct 4 13:15:46 2007 +0100
[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.
diff --git a/src/cairo-analysis-surface.c b/src/cairo-analysis-surface.c
index 067543f..97b245e 100644
--- a/src/cairo-analysis-surface.c
+++ b/src/cairo-analysis-surface.c
@@ -76,7 +76,7 @@ _cairo_analysis_surface_analyze_meta_sur
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_su
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 58c699e..0313caa 100644
--- a/src/cairo-array.c
+++ b/src/cairo-array.c
@@ -132,10 +132,8 @@ _cairo_array_grow_by (cairo_array_t *arr
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 *arr
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 ab567c6..b677185 100644
--- a/src/cairo-atsui-font.c
+++ b/src/cairo-atsui-font.c
@@ -213,7 +213,7 @@ _cairo_atsui_font_set_metrics (cairo_ats
}
}
- 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_f
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_f
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 (ca
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
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_surf
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
*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 bfde0cf..97ef263 100644
--- a/src/cairo-base85-stream.c
+++ b/src/cairo-base85-stream.c
@@ -115,7 +115,7 @@ _cairo_base85_stream_create (cairo_outpu
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 679b532..b8a5f81 100644
--- a/src/cairo-bentley-ottmann.c
+++ b/src/cairo-bentley-ottmann.c
@@ -701,7 +701,7 @@ _cairo_bo_event_queue_insert (cairo_bo_e
/* 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_eve
* 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_sw
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 (c
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_polygo
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 a7c27c1..9bb4de5 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_eq
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 aac1378..7bc7cb9 100644
--- a/src/cairo-cff-subset.c
+++ b/src/cairo-cff-subset.c
@@ -389,10 +389,8 @@ cff_index_append_copy (cairo_array_t *in
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
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
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,
_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_
{
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_
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_
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_
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_
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_
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_cf
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 (cair
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_fon
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_fon
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_fon
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_fon
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_fon
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_fon
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
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_s
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_s
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_s
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 4f42414..43b25ca 100644
--- a/src/cairo-clip.c
+++ b/src/cairo-clip.c
@@ -86,7 +86,7 @@ _cairo_clip_init_copy (cairo_clip_t *cli
{
_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
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
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_c
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_c
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_c
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 618c6be..73746fe 100644
--- a/src/cairo-deflate-stream.c
+++ b/src/cairo-deflate-stream.c
@@ -119,7 +119,7 @@ _cairo_deflate_stream_create (cairo_outp
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 50f926c..b79f8e2 100644
--- a/src/cairo-directfb-surface.c
+++ b/src/cairo-directfb-surface.c
@@ -390,7 +390,7 @@ _directfb_acquire_surface (cairo_directf
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 (
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 (v
_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_direc
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
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
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
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_recta
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
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_dire
/* 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_dire
"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_dire
"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_dire
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
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 b3bcc84..0285b52 100644
--- a/src/cairo-font-face.c
+++ b/src/cairo-font-face.c
@@ -231,7 +231,7 @@ cairo_font_face_set_user_data (cairo_fon
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_fon
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
/* 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 b3a5660..c5d5c12 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_fon
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 753810a..7768a77 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_u
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_patte
/* 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
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
{
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
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
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 *bi
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 *bi
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 *bi
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 *bi
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 *bi
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
(*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
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 fac
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
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_u
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_
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_
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 fac
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 fac
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 *abs
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 *abs
/* 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 *abs
}
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 *abs
/* 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
#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 (
&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_uns
/* 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 (F
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 (F
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 4d781cf..83a5109 100644
--- a/src/cairo-glitz-surface.c
+++ b/src/cairo-glitz-surface.c
@@ -89,7 +89,7 @@ _cairo_glitz_surface_create_similar (voi
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 (voi
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 (cair
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_gl
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_gl
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_gl
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
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
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 (ca
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 (ca
{
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 (vo
(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_trapezoid
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_trapezoid
&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_trapezoid
&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_trapezoid
_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_trapezoid
{
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_trapezoid
_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 (vo
{
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_ro
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 = _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_gl
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_gl
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_gl
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 (ca
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_surfac
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 4097a65..b1fc6b3 100644
--- a/src/cairo-gstate.c
+++ b/src/cairo-gstate.c
@@ -94,7 +94,7 @@ _cairo_gstate_init (cairo_gstate_t *gst
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 *oth
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 **gst
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 **
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->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 *
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 *gst
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_
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
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 7051860..c419e9e 100644
--- a/src/cairo-hash.c
+++ b/src/cairo-hash.c
@@ -150,7 +150,7 @@ _cairo_hash_table_create (cairo_hash_key
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_key
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_ta
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 f5d05e4..9eed671 100644
--- a/src/cairo-hull.c
+++ b/src/cairo-hull.c
@@ -64,7 +64,7 @@ _cairo_hull_create (cairo_pen_vertex_t *
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 091a957..3331e55 100644
--- a/src/cairo-image-surface.c
+++ b/src/cairo-image-surface.c
@@ -214,7 +214,7 @@ _cairo_image_surface_create_for_pixman_i
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_
(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
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
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 (uns
* 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_wit
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_surf
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_su
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_sur
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_su
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_su
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_i
_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 (vo
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 (vo
&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_trapezoid
/* 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_trapezoid
/* 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 (vo
cairo_image_surface_t *surface = (cairo_image_surface_t *) abstract_surface;
if (!pixman_image_set_clip_region (surface->pixman_image, ®ion->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 73d82a3..6158eaf 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 17b11ef..cf31c5d 100644
--- a/src/cairo-matrix.c
+++ b/src/cairo-matrix.c
@@ -473,11 +473,11 @@ cairo_matrix_invert (cairo_matrix_t *mat
_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 ac43be9..d353d2e 100644
--- a/src/cairo-meta-surface.c
+++ b/src/cairo-meta-surface.c
@@ -85,7 +85,7 @@ _cairo_meta_surface_create (cairo_conten
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 *abstr
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 *abstra
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 *abst
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 *abstra
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
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
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
_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 *abst
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
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 (cai
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 b448887..0d888ed 100644
--- a/src/cairo-os2-surface.c
+++ b/src/cairo-os2-surface.c
@@ -473,7 +473,7 @@ _cairo_os2_surface_acquire_source_image
(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 (v
(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
(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_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);
}
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_surfac
/* 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_surfac
* 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_surfac
*/
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_surfac
/* 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_surfac
*/
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 *abstrac
(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
(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 a0add6d..791c0f2 100644
--- a/src/cairo-output-stream.c
+++ b/src/cairo-output-stream.c
@@ -120,7 +120,7 @@ _cairo_output_stream_create (cairo_write
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_outp
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 (FI
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
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 76eb661..d7f02f3 100644
--- a/src/cairo-paginated-surface.c
+++ b/src/cairo-paginated-surface.c
@@ -76,10 +76,8 @@ _cairo_paginated_surface_create (cairo_s
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_s
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 *
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 56b1df2..1ed674e 100644
--- a/src/cairo-path-fixed.c
+++ b/src/cairo-path-fixed.c
@@ -108,7 +108,7 @@ _cairo_path_fixed_init_copy (cairo_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_pat
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_pat
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_pa
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 (cai
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_
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 0a295ba..ce523b0 100644
--- a/src/cairo-path-stroke.c
+++ b/src/cairo-path-stroke.c
@@ -1066,10 +1066,8 @@ _cairo_rectilinear_stroker_add_segment (
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 b1ef44e..90b726d 100644
--- a/src/cairo-path.c
+++ b/src/cairo-path.c
@@ -353,7 +353,7 @@ _cairo_path_create_in_error (cairo_statu
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_
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_
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 cai
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 cai
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 a7e804e..6eea9a6 100644
--- a/src/cairo-pattern.c
+++ b/src/cairo-pattern.c
@@ -77,7 +77,7 @@ const cairo_solid_pattern_t cairo_patter
* 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_
* 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
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_st
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, do
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, d
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_
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,
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,
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_patte
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_grad
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_gra
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_
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_gradi
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_gradi
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_gradi
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_gradi
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_gradi
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
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
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
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 (cair
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_p
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_
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 043d8f4..3a5b637 100644
--- a/src/cairo-pdf-surface.c
+++ b/src/cairo-pdf-surface.c
@@ -305,7 +305,7 @@ _cairo_pdf_surface_create_for_stream_int
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_int
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 (cai
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 *f
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
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_surfac
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_surfac
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
*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
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
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
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
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 (c
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_p
}
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_s
} 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_
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 (cair
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_su
&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
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_subse
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 471849b..0f0dee8 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,
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,
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 8ad4c9a..2715067 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_surfac
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 (con
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 3aa0c4c..125d54d 100644
--- a/src/cairo-polygon.c
+++ b/src/cairo-polygon.c
@@ -101,10 +101,8 @@ _cairo_polygon_grow (cairo_polygon_t *po
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 77d3820..23a478c 100644
--- a/src/cairo-ps-surface.c
+++ b/src/cairo-ps-surface.c
@@ -150,7 +150,7 @@ _word_wrap_stream_create (cairo_output_s
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_s
"\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_inte
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_inte
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 *fi
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 (cair
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 *s
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_
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_
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
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
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_surf
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_
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 (c
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_outpu
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_s
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_s
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_s
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 *abstra
*/
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
_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 8a90f30..88fe4b0 100644
--- a/src/cairo-quartz-surface.c
+++ b/src/cairo-quartz-surface.c
@@ -1256,10 +1256,8 @@ _cairo_quartz_surface_stroke (void *abst
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
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 ea4ccc3..b4b9117 100644
--- a/src/cairo-region.c
+++ b/src/cairo-region.c
@@ -66,10 +66,8 @@ _cairo_region_init_boxes (cairo_region_t
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
}
if (!pixman_region_init_rects (®ion->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
}
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
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 a5d9c49..efc7999 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 l
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_fon
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_
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_fon
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_intern
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 (ca
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 (ca
subset_glyph->is_composite);
if (sub_font == NULL) {
cairo_scaled_font_destroy (scaled_font);
- return CAIRO_STATUS_NO