diff options
author | Robin Watts <robin.watts@artifex.com> | 2011-12-16 16:26:48 +0000 |
---|---|---|
committer | Robin Watts <robin.watts@artifex.com> | 2011-12-16 16:26:48 +0000 |
commit | 09a016ee7c5c81580b27db3bd193b38cb3bd4f0e (patch) | |
tree | 90d0fad103f7aa592451f493a3d091ca9db7c866 /xps | |
parent | 1f8cccdeca9cf9082061b40d66fc8201c8b3ce80 (diff) | |
download | mupdf-09a016ee7c5c81580b27db3bd193b38cb3bd4f0e.tar.xz |
Add fz_malloc_struct, and make code use it.
The new fz_malloc_struct(A,B) macro allocates sizeof(B) bytes using
fz_malloc, and then passes the resultant pointer to Memento_label
to label it with "B".
This costs nothing in non-memento builds, but gives much nicer
listings of leaked blocks when memento is enabled.
Diffstat (limited to 'xps')
-rw-r--r-- | xps/xps_doc.c | 6 | ||||
-rw-r--r-- | xps/xps_glyphs.c | 2 | ||||
-rw-r--r-- | xps/xps_gradient.c | 4 | ||||
-rw-r--r-- | xps/xps_outline.c | 2 | ||||
-rw-r--r-- | xps/xps_resource.c | 2 | ||||
-rw-r--r-- | xps/xps_xml.c | 4 | ||||
-rw-r--r-- | xps/xps_zip.c | 4 |
7 files changed, 12 insertions, 12 deletions
diff --git a/xps/xps_doc.c b/xps/xps_doc.c index 3304e1b9..b7bba194 100644 --- a/xps/xps_doc.c +++ b/xps/xps_doc.c @@ -52,7 +52,7 @@ xps_add_fixed_document(xps_document *doc, char *name) if (!strcmp(fixdoc->name, name)) return; - fixdoc = fz_malloc(doc->ctx, sizeof(xps_fixdoc)); + fixdoc = fz_malloc_struct(doc->ctx, xps_fixdoc); fixdoc->name = fz_strdup(doc->ctx, name); fixdoc->outline = NULL; fixdoc->next = NULL; @@ -79,7 +79,7 @@ xps_add_fixed_page(xps_document *doc, char *name, int width, int height) if (!strcmp(page->name, name)) return; - page = fz_malloc(doc->ctx, sizeof(xps_page)); + page = fz_malloc_struct(doc->ctx, xps_page); page->name = fz_strdup(doc->ctx, name); page->number = doc->page_count++; page->width = width; @@ -103,7 +103,7 @@ static void xps_add_link_target(xps_document *doc, char *name) { xps_page *page = doc->last_page; - xps_target *target = fz_malloc(doc->ctx, sizeof *target); + xps_target *target = fz_malloc_struct(doc->ctx, xps_target); target->name = fz_strdup(doc->ctx, name); target->page = page->number; target->next = doc->target; diff --git a/xps/xps_glyphs.c b/xps/xps_glyphs.c index 9731a448..030ca0e5 100644 --- a/xps/xps_glyphs.c +++ b/xps/xps_glyphs.c @@ -81,7 +81,7 @@ xps_lookup_font(xps_document *doc, char *name) static void xps_insert_font(xps_document *doc, char *name, fz_font *font) { - xps_font_cache *cache = fz_malloc(doc->ctx, sizeof(xps_font_cache)); + xps_font_cache *cache = fz_malloc_struct(doc->ctx, xps_font_cache); cache->name = fz_strdup(doc->ctx, name); cache->font = fz_keep_font(font); cache->next = doc->font_table; diff --git a/xps/xps_gradient.c b/xps/xps_gradient.c index e5acc8a0..8bdc3cc5 100644 --- a/xps/xps_gradient.c +++ b/xps/xps_gradient.c @@ -212,7 +212,7 @@ xps_draw_one_radial_gradient(xps_document *doc, fz_matrix ctm, fz_shade *shade; /* TODO: this (and the stuff in pdf_shade) should move to res_shade.c */ - shade = fz_malloc(doc->ctx, sizeof(fz_shade)); + shade = fz_malloc_struct(doc->ctx, fz_shade); FZ_INIT_STORABLE(shade, 1, fz_free_shade_imp); shade->colorspace = fz_device_rgb; shade->bbox = fz_infinite_rect; @@ -253,7 +253,7 @@ xps_draw_one_linear_gradient(xps_document *doc, fz_matrix ctm, fz_shade *shade; /* TODO: this (and the stuff in pdf_shade) should move to res_shade.c */ - shade = fz_malloc(doc->ctx, sizeof(fz_shade)); + shade = fz_malloc_struct(doc->ctx, fz_shade); FZ_INIT_STORABLE(shade, 1, fz_free_shade_imp); shade->colorspace = fz_device_rgb; shade->bbox = fz_infinite_rect; diff --git a/xps/xps_outline.c b/xps/xps_outline.c index ae43a4e8..6252a6c1 100644 --- a/xps/xps_outline.c +++ b/xps/xps_outline.c @@ -31,7 +31,7 @@ xps_parse_document_outline(xps_document *doc, xml_element *root) if (!target || !description) continue; - entry = fz_malloc(doc->ctx, sizeof *entry); + entry = fz_malloc_struct(doc->ctx, fz_outline); entry->title = fz_strdup(doc->ctx, description); entry->page = xps_find_link_target(doc, target); entry->down = NULL; diff --git a/xps/xps_resource.c b/xps/xps_resource.c index 3701f079..fad60488 100644 --- a/xps/xps_resource.c +++ b/xps/xps_resource.c @@ -105,7 +105,7 @@ xps_parse_resource_dictionary(xps_document *doc, char *base_uri, xml_element *ro key = xml_att(node, "x:Key"); if (key) { - entry = fz_malloc(doc->ctx, sizeof(xps_resource)); + entry = fz_malloc_struct(doc->ctx, xps_resource); entry->name = key; entry->base_uri = NULL; entry->base_xml = NULL; diff --git a/xps/xps_xml.c b/xps/xps_xml.c index b6dc63c3..15c510a6 100644 --- a/xps/xps_xml.c +++ b/xps/xps_xml.c @@ -134,7 +134,7 @@ static void xml_emit_open_tag(struct parser *parser, char *a, char *b) { struct element *head, *tail; - head = fz_malloc(parser->ctx, sizeof(struct element)); + head = fz_malloc_struct(parser->ctx, struct element); if (b - a > sizeof(head->name)) b = a + sizeof(head->name); memcpy(head->name, a, b - a); @@ -163,7 +163,7 @@ static void xml_emit_att_name(struct parser *parser, char *a, char *b) struct element *head = parser->head; struct attribute *att; - att = fz_malloc(parser->ctx, sizeof(struct attribute)); + att = fz_malloc_struct(parser->ctx, struct attribute); if (b - a > sizeof(att->name)) b = a + sizeof(att->name); memcpy(att->name, a, b - a); diff --git a/xps/xps_zip.c b/xps/xps_zip.c index f8099296..42d6b3c4 100644 --- a/xps/xps_zip.c +++ b/xps/xps_zip.c @@ -449,7 +449,7 @@ xps_open_directory(fz_context *ctx, char *directory) { xps_document *doc; - doc = fz_malloc(ctx, sizeof(xps_document)); + doc = fz_malloc_struct(ctx, xps_document); memset(doc, 0, sizeof *doc); doc->ctx = ctx; @@ -474,7 +474,7 @@ xps_open_stream(fz_stream *file) fz_context *ctx = file->ctx; xps_document *doc; - doc = fz_malloc(ctx, sizeof(xps_document)); + doc = fz_malloc_struct(ctx, xps_document); memset(doc, 0, sizeof *doc); doc->ctx = ctx; |