From f35a03322e1a9fd9e43fa53e2c5635f56ec74bb0 Mon Sep 17 00:00:00 2001 From: Nicola Fontana Date: Sat, 20 Feb 2010 12:20:59 +0100 Subject: [PATCH] [CpmlPrimitive] Make cpml_primitive_from_segment() void Do not return anything from the primitive constructor: the fake-fluent interface has been proved to be confusing. --- cpml/cpml-primitive.c | 10 +++------- cpml/cpml-primitive.h | 2 +- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/cpml/cpml-primitive.c b/cpml/cpml-primitive.c index c719de93..a2f1d6ab 100644 --- a/cpml/cpml-primitive.c +++ b/cpml/cpml-primitive.c @@ -109,10 +109,8 @@ cpml_primitive_type_get_n_points(CpmlPrimitiveType type) * @segment: the source segment * * Initializes @primitive to the first primitive of @segment. - * - * Returns: @primitive **/ -CpmlPrimitive * +void cpml_primitive_from_segment(CpmlPrimitive *primitive, CpmlSegment *segment) { primitive->segment = segment; @@ -120,13 +118,11 @@ cpml_primitive_from_segment(CpmlPrimitive *primitive, CpmlSegment *segment) /* The first element of a CpmlSegment is always a CPML_MOVE, * as ensured by cpml_segment_from_cairo() and by the browsing APIs, * so the origin is in the second data item */ - primitive->org = &segment->data[1]; + primitive->org = segment->data + 1; /* Also, the segment APIs ensure that @segment is prepended by * only one CPML_MOVE */ - primitive->data = segment->data + segment->data[0].header.length; - - return primitive; + primitive->data = segment->data + segment->data->header.length; } /** diff --git a/cpml/cpml-primitive.h b/cpml/cpml-primitive.h index 20bb8a5f..4b96db68 100644 --- a/cpml/cpml-primitive.h +++ b/cpml/cpml-primitive.h @@ -43,7 +43,7 @@ struct _CpmlPrimitive { size_t cpml_primitive_type_get_n_points (CpmlPrimitiveType type); -CpmlPrimitive * cpml_primitive_from_segment(CpmlPrimitive *primitive, +void cpml_primitive_from_segment(CpmlPrimitive *primitive, CpmlSegment *segment); void cpml_primitive_copy (CpmlPrimitive *primitive, const CpmlPrimitive *src); -- 2.11.4.GIT