Re: [PATCH 03/51] core: allow NULL parameter for _cairo_path_fixed_is_box()
Bryce Harrington <[email protected]>
| Newsgroups | gmane.comp.lib.cairo |
|---|---|
| Message-ID | <[email protected]> |
On Fri, Dec 18, 2015 at 02:28:42PM +0100, Enrico Weigelt, metux IT consult wrote: > Allow that function to be called with NULL parameter for the > return buffer, so we can use it for only checking whether > a path is a box, w/o actually returning the box dimensions. > > This feature will be used in subsequent patches. > > Signed-off-by: Enrico Weigelt, metux IT consult <[email protected]> > --- > src/cairo-path-fixed.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/src/cairo-path-fixed.c b/src/cairo-path-fixed.c > index ac44bb7..df72b47 100644 > --- a/src/cairo-path-fixed.c > +++ b/src/cairo-path-fixed.c > @@ -1295,7 +1295,8 @@ _cairo_path_fixed_is_box (const cairo_path_fixed_t *path, > > buf = cairo_path_head (path); > if (_points_form_rect (buf->points)) { > - _canonical_box (box, &buf->points[0], &buf->points[2]); > + if (box != NULL) > + _canonical_box (box, &buf->points[0], &buf->points[2]); > return TRUE; > } Fwiw, _canonical_box is also used in _cairo_path_fixed_is_stroke_box. If a check should be added to _cairo_path_fixed_is_box then for consistency it should be added there too. Although from the function name I would not expect passing box=NULL would be acceptable. Perhaps the check needs to be further up by whatever is calling in here, since it appears to be an internal routine anyway? Frankly, _cairo_path_fixed_is_box() seems odd even aside from this fix, since it's checking to see if a path is a rectangle and then has a side effect of maybe giving it back as box. Seems like this side-effect ought to be done as a separate activity by the caller. In any case, a little more code doc explaining what these routines are intended to return would likely help. Bryce > -- > 2.6.4.442.g545299f > > -- > cairo mailing list > [email protected] > http://lists.cairographics.org/mailman/listinfo/cairo -- cairo mailing list [email protected] http://lists.cairographics.org/mailman/listinfo/cairo