summaryrefslogtreecommitdiff
path: root/src/cairo-hull.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2008-02-29 17:06:30 +0000
committerChris Wilson <chris@chris-wilson.co.uk>2008-03-04 09:31:21 +0000
commit5efc5238d548599a90a02d922d031a899424d1c1 (patch)
tree27c4cd1546e82b18acc232f029f827c0b0579416 /src/cairo-hull.c
parent11a2444ec875aaaed12c1f1cfed5eb8e139c306d (diff)
downloadcairo-5efc5238d548599a90a02d922d031a899424d1c1.tar.gz
[cairo-hull] Propagate error during hull computation.
Propagate the original error status instead of returning a new NO_MEMORY error.
Diffstat (limited to 'src/cairo-hull.c')
-rw-r--r--src/cairo-hull.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/src/cairo-hull.c b/src/cairo-hull.c
index d4e4af834..a9e55e6c5 100644
--- a/src/cairo-hull.c
+++ b/src/cairo-hull.c
@@ -44,8 +44,10 @@ typedef struct cairo_hull
int id;
} cairo_hull_t;
-static cairo_hull_t *
-_cairo_hull_create (cairo_pen_vertex_t *vertices, int num_vertices)
+static cairo_status_t
+_cairo_hull_create (cairo_pen_vertex_t *vertices,
+ int num_vertices,
+ cairo_hull_t **out)
{
int i;
cairo_hull_t *hull;
@@ -63,10 +65,8 @@ _cairo_hull_create (cairo_pen_vertex_t *vertices, int num_vertices)
vertices[0].point = tmp;
hull = _cairo_malloc_ab (num_vertices, sizeof (cairo_hull_t));
- if (hull == NULL) {
- _cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
- return NULL;
- }
+ if (hull == NULL)
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
for (i = 0; i < num_vertices; i++) {
hull[i].point = vertices[i].point;
@@ -83,7 +83,8 @@ _cairo_hull_create (cairo_pen_vertex_t *vertices, int num_vertices)
hull[i].discard = 1;
}
- return hull;
+ *out = hull;
+ return CAIRO_STATUS_SUCCESS;
}
static int
@@ -190,12 +191,13 @@ _cairo_hull_to_pen (cairo_hull_t *hull, cairo_pen_vertex_t *vertices, int *num_v
cairo_status_t
_cairo_hull_compute (cairo_pen_vertex_t *vertices, int *num_vertices)
{
+ cairo_status_t status;
cairo_hull_t *hull;
int num_hull = *num_vertices;
- hull = _cairo_hull_create (vertices, num_hull);
- if (hull == NULL)
- return CAIRO_STATUS_NO_MEMORY;
+ status = _cairo_hull_create (vertices, num_hull, &hull);
+ if (status)
+ return status;
qsort (hull + 1, num_hull - 1,
sizeof (cairo_hull_t), _cairo_hull_vertex_compare);