diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/cairo-png.c | 3 | ||||
-rw-r--r-- | src/cairo-surface.c | 9 | ||||
-rw-r--r-- | src/cairo-types-private.h | 1 | ||||
-rw-r--r-- | src/cairo.h | 11 |
4 files changed, 15 insertions, 9 deletions
diff --git a/src/cairo-png.c b/src/cairo-png.c index a130ba25d..e8f61b5da 100644 --- a/src/cairo-png.c +++ b/src/cairo-png.c @@ -662,7 +662,8 @@ read_png (struct png_read_closure_t *png_closure) CAIRO_MIME_TYPE_PNG, mime_data, mime_data_length, - free); + free, + mime_data); if (status) { free (mime_data); cairo_surface_destroy (surface); diff --git a/src/cairo-surface.c b/src/cairo-surface.c index 9df75ca49..c419bd5f3 100644 --- a/src/cairo-surface.c +++ b/src/cairo-surface.c @@ -640,8 +640,8 @@ _cairo_mime_data_destroy (void *ptr) if (! _cairo_reference_count_dec_and_test (&mime_data->ref_count)) return; - if (mime_data->destroy && mime_data->data) - mime_data->destroy (mime_data->data); + if (mime_data->destroy && mime_data->closure) + mime_data->destroy (mime_data->closure); free (mime_data); } @@ -655,6 +655,7 @@ _cairo_mime_data_destroy (void *ptr) * @destroy: a #cairo_destroy_func_t which will be called when the * surface is destroyed or when new image data is attached using the * same mime type. + * @closure: the data to be passed to the @destroy notifier * * Attach an image in the format @mime_type to @surface. To remove * the data from a surface, call this function with same mime type @@ -670,7 +671,8 @@ cairo_surface_set_mime_data (cairo_surface_t *surface, const char *mime_type, const unsigned char *data, unsigned int length, - cairo_destroy_func_t destroy) + cairo_destroy_func_t destroy, + void *closure) { cairo_status_t status; cairo_mime_data_t *mime_data; @@ -692,6 +694,7 @@ cairo_surface_set_mime_data (cairo_surface_t *surface, mime_data->data = (unsigned char *) data; mime_data->length = length; mime_data->destroy = destroy; + mime_data->closure = closure; } else mime_data = NULL; diff --git a/src/cairo-types-private.h b/src/cairo-types-private.h index 30180b0cc..77f8184bf 100644 --- a/src/cairo-types-private.h +++ b/src/cairo-types-private.h @@ -349,6 +349,7 @@ struct _cairo_mime_data { unsigned char *data; unsigned int length; cairo_destroy_func_t destroy; + void *closure; }; #endif /* CAIRO_TYPES_PRIVATE_H */ diff --git a/src/cairo.h b/src/cairo.h index cbc109f34..27d56f5af 100644 --- a/src/cairo.h +++ b/src/cairo.h @@ -1957,11 +1957,12 @@ cairo_surface_get_mime_data (cairo_surface_t *surface, unsigned int *length); cairo_public cairo_status_t -cairo_surface_set_mime_data (cairo_surface_t *surface, - const char *mime_type, - const unsigned char *data, - unsigned int length, - cairo_destroy_func_t destroy); +cairo_surface_set_mime_data (cairo_surface_t *surface, + const char *mime_type, + const unsigned char *data, + unsigned int length, + cairo_destroy_func_t destroy, + void *closure); cairo_public void cairo_surface_get_font_options (cairo_surface_t *surface, |