summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/cairo-png.c3
-rw-r--r--src/cairo-surface.c9
-rw-r--r--src/cairo-types-private.h1
-rw-r--r--src/cairo.h11
-rw-r--r--test/mime-data.c3
-rw-r--r--test/pdf-mime-data.c4
-rw-r--r--util/cairo-trace/trace.c6
7 files changed, 24 insertions, 13 deletions
diff --git a/src/cairo-png.c b/src/cairo-png.c
index a130ba25..e8f61b5d 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 9df75ca4..c419bd5f 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 30180b0c..77f8184b 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 cbc109f3..27d56f5a 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,
diff --git a/test/mime-data.c b/test/mime-data.c
index 87fe74c8..ec855f85 100644
--- a/test/mime-data.c
+++ b/test/mime-data.c
@@ -96,7 +96,8 @@ paint_file (cairo_t *cr,
image = cairo_image_surface_create (CAIRO_FORMAT_RGB24, 200, 50);
status = cairo_surface_set_mime_data (image, mime_type,
- mime_data, mime_length, free);
+ mime_data, mime_length,
+ free, mime_data);
if (status) {
cairo_surface_destroy (image);
return cairo_test_status_from_status (ctx, status);
diff --git a/test/pdf-mime-data.c b/test/pdf-mime-data.c
index c949335e..233374dd 100644
--- a/test/pdf-mime-data.c
+++ b/test/pdf-mime-data.c
@@ -106,7 +106,9 @@ preamble (cairo_test_context_t *ctx)
return test_status;
}
- cairo_surface_set_mime_data (image, CAIRO_MIME_TYPE_JPEG, data, len, free);
+ cairo_surface_set_mime_data (image, CAIRO_MIME_TYPE_JPEG,
+ data, len,
+ free, data);
width = cairo_image_surface_get_width (image);
height = cairo_image_surface_get_height (image);
diff --git a/util/cairo-trace/trace.c b/util/cairo-trace/trace.c
index df2ec5c9..03f7c5e5 100644
--- a/util/cairo-trace/trace.c
+++ b/util/cairo-trace/trace.c
@@ -2771,7 +2771,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)
{
if (surface != NULL && _write_lock ()) {
_emit_surface (surface);
@@ -2787,7 +2788,8 @@ cairo_surface_set_mime_data (cairo_surface_t *surface,
surface,
mime_type,
data, length,
- destroy);
+ destroy,
+ closure);
}
cairo_status_t