diff options
author | Behdad Esfahbod <behdad@behdad.org> | 2008-05-09 13:25:16 +0200 |
---|---|---|
committer | Behdad Esfahbod <behdad@behdad.org> | 2008-05-09 15:54:12 +0200 |
commit | f81b857e1ffa48559c794e2fb427413e3a88a271 (patch) | |
tree | f1f0725d3cb9f05a821126fbaea46739ac252db8 /src/test-paginated-surface.c | |
parent | 440b339da793ba2f71f504328417aefc7d44ee7f (diff) | |
download | cairo-f81b857e1ffa48559c794e2fb427413e3a88a271.tar.gz |
[cairo-paginated-surface] Clean up reference counting mess
Previously the paginated constructor didn't reference the target surface, but
simply assume ownership of the reference, and then unref it when shutting
down. The callers to paginated constructor then, where just give away their
reference to paginated and not unref the reference they were holding. While
this works correctly, it's against the usual idioms that everyone is
responsible for the reference they are holding, and should get their own
reference if they need to keep an object alive. Fix it all.
Diffstat (limited to 'src/test-paginated-surface.c')
-rw-r--r-- | src/test-paginated-surface.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/test-paginated-surface.c b/src/test-paginated-surface.c index f640b6068..f7cc4db6d 100644 --- a/src/test-paginated-surface.c +++ b/src/test-paginated-surface.c @@ -93,9 +93,12 @@ _cairo_test_paginated_surface_create_for_data (unsigned char *data, paginated = _cairo_paginated_surface_create (&surface->base, content, width, height, &test_paginated_surface_paginated_backend); + + /* paginated keeps the only reference to surface now, drop ours */ + cairo_surface_destroy (&surface->base); + if (paginated->status) { cairo_surface_destroy (target); - free (surface); } return paginated; } |