[cairo] [PATCH 2/2] test: Release owned pattern

Andrea Canciani ranma42 at gmail.com
Thu Nov 20 08:53:46 PST 2014


On Thu, Nov 20, 2014 at 5:50 PM, Chris Wilson <chris at chris-wilson.co.uk>
wrote:

> On Thu, Nov 20, 2014 at 05:22:31PM +0100, Andrea Canciani wrote:
> > The pattern created by cairo_pattern_create_rgb() is owned by the
> > caller, hence it needs to be released.
> >
> > Fixes:
> >
> > malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
> > _cairo_pattern_create_solid (cairo-pattern.c:605)
> > _cairo_pattern_create_in_error (cairo-pattern.c:628)
> > cairo_pop_group (cairo.c:552)
> > test_cairo_push_group (api-special-cases.c:157)
> > preamble (api-special-cases.c:1766)
> > main (cairo-test-runner.c:228)
> > ---
> >  test/api-special-cases.c | 4 +++-
> >  1 file changed, 3 insertions(+), 1 deletion(-)
> >
> > diff --git a/test/api-special-cases.c b/test/api-special-cases.c
> > index e861152..c4a754d 100644
> > --- a/test/api-special-cases.c
> > +++ b/test/api-special-cases.c
> > @@ -181,7 +181,9 @@ test_cairo_set_operator (cairo_t *cr)
> >  static cairo_test_status_t
> >  test_cairo_set_source (cairo_t *cr)
> >  {
> > -    cairo_set_source (cr, cairo_pattern_create_rgb (0, 0, 0));
>
> cairo_set_source_rgb (cr, 0, 0, 0) ?
>

I know that it would be more natural to code it the way you suggest, but I
think that the purpose of that part of the test is exactly to check
cairo_set_source().
The cairo_set_source_rgb() function is tested in
test_cairo_set_source_rgb(), exactly with the code you proposed.

Andrea


>
> > +    cairo_pattern_t *source = cairo_pattern_create_rgb (0, 0, 0);
> > +    cairo_set_source (cr, source);
> > +    cairo_pattern_destroy (source);
>
> --
> Chris Wilson, Intel Open Source Technology Centre
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cairographics.org/archives/cairo/attachments/20141120/78cd0dd4/attachment.html>


More information about the cairo mailing list