[gs-commits] mupdf 1.16.1.84 Sprinkle some Memento_label's throughout
[email protected] (Robin Watts) Fri, 4 Oct 2019 11:42:09 +0000 (UTC)
| Newsgroups | gmane.comp.printing.ghostscript.cvs |
|---|---|
| Message-ID | <[email protected]> |
commit c95d3efe1efbabf7510e82f4fbbe4ef62d8f6f65 Author: Robin Watts <[email protected]> Date: Thu Oct 3 14:53:38 2019 +0100 Sprinkle some Memento_label's throughout the code. diff --git a/source/fitz/buffer.c b/source/fitz/buffer.c index b8cb237..edabad4 100644 --- a/source/fitz/buffer.c +++ b/source/fitz/buffer.c @@ -14,7 +14,7 @@ fz_new_buffer(fz_context *ctx, size_t size) b->refs = 1; fz_try(ctx) { - b->data = fz_malloc(ctx, size); + b->data = Memento_label(fz_malloc(ctx, size), "fz_buffer_data"); } fz_catch(ctx) { diff --git a/source/fitz/color-lcms.c b/source/fitz/color-lcms.c index 0d7ae43..6ebfe77 100644 --- a/source/fitz/color-lcms.c +++ b/source/fitz/color-lcms.c @@ -67,13 +67,13 @@ static void fz_lcms_log_error(cmsContext id, cmsUInt32Number error_code, const c static void *fz_lcms_malloc(cmsContext id, unsigned int size) { fz_context *ctx = cmsGetContextUserData(id); - return fz_malloc_no_throw(ctx, size); + return Memento_label(fz_malloc_no_throw(ctx, size), "lcms"); } static void *fz_lcms_realloc(cmsContext id, void *ptr, unsigned int size) { fz_context *ctx = cmsGetContextUserData(id); - return fz_realloc_no_throw(ctx, ptr, size); + return Memento_label(fz_realloc_no_throw(ctx, ptr, size), "lcms"); } static void fz_lcms_free(cmsContext id, void *ptr) diff --git a/source/fitz/colorspace.c b/source/fitz/colorspace.c index 8d245ce..975217c 100644 --- a/source/fitz/colorspace.c +++ b/source/fitz/colorspace.c @@ -327,7 +327,7 @@ fz_new_colorspace(fz_context *ctx, enum fz_colorspace_type type, int flags, int cs->type = type; cs->flags = flags; cs->n = n; - cs->name = fz_strdup(ctx, name ? name : "UNKNOWN"); + cs->name = Memento_label(fz_strdup(ctx, name ? name : "UNKNOWN"), "cs_name"); } fz_catch(ctx) { @@ -819,7 +819,7 @@ fz_find_icc_link(fz_context *ctx, link = fz_find_item(ctx, fz_drop_icc_link_imp, &key, &fz_link_store_type); if (!link) { - new_key = fz_malloc(ctx, sizeof (fz_link_key)); + new_key = fz_malloc_struct(ctx, fz_link_key); memcpy(new_key, &key, sizeof (fz_link_key)); fz_try(ctx) { @@ -1010,7 +1010,7 @@ static void fz_cached_color_convert(fz_context *ctx, fz_color_converter *cc_, co cc->base.convert(ctx, &cc->base, ss, ds); - val = fz_malloc(ctx, n); + val = fz_malloc_array(ctx, cc->base.ds->n, float); memcpy(val, ds, n); fz_try(ctx) fz_hash_insert(ctx, cc->hash, ss, val); diff --git a/source/fitz/compress.c b/source/fitz/compress.c index 2a99562..dd16410 100644 --- a/source/fitz/compress.c +++ b/source/fitz/compress.c @@ -63,7 +63,7 @@ void fz_deflate(fz_context *ctx, unsigned char *dest, size_t *destLen, const uns unsigned char *fz_new_deflated_data(fz_context *ctx, size_t *compressed_length, const unsigned char *source, size_t source_length, fz_deflate_level level) { size_t bound = fz_deflate_bound(ctx, source_length); - unsigned char *cdata = fz_malloc(ctx, bound); + unsigned char *cdata = Memento_label(fz_malloc(ctx, bound), "deflated_data"); *compressed_length = 0; fz_try(ctx) diff --git a/source/fitz/context.c b/source/fitz/context.c index 9ad7c81..e18e56a 100644 --- a/source/fitz/context.c +++ b/source/fitz/context.c @@ -232,7 +232,7 @@ fz_new_context_imp(const fz_alloc_context *alloc, const fz_locks_context *locks, if (!locks) locks = &fz_locks_default; - ctx = alloc->malloc(alloc->user, sizeof(fz_context)); + ctx = Memento_label(alloc->malloc(alloc->user, sizeof(fz_context)), "fz_context"); if (!ctx) { fprintf(stderr, "cannot create context (phase 1)\n"); diff --git a/source/fitz/draw-scale-simple.c b/source/fitz/draw-scale-simple.c index 54c0114..6f08f83 100644 --- a/source/fitz/draw-scale-simple.c +++ b/source/fitz/draw-scale-simple.c @@ -1703,13 +1703,13 @@ fz_scale_pixmap_cached(fz_context *ctx, const fz_pixmap *src, float x, float y, contrib_cols = NULL; else #endif /* SINGLE_PIXEL_SPECIALS */ - contrib_cols = make_weights(ctx, src->w, x, w, filter, 0, dst_w_int, patch.x0, patch.x1, src->n, flip_x, cache_x); + contrib_cols = Memento_label(make_weights(ctx, src->w, x, w, filter, 0, dst_w_int, patch.x0, patch.x1, src->n, flip_x, cache_x), "contrib_cols"); #ifdef SINGLE_PIXEL_SPECIALS if (src->h == 1) contrib_rows = NULL; else #endif /* SINGLE_PIXEL_SPECIALS */ - contrib_rows = make_weights(ctx, src->h, y, h, filter, 1, dst_h_int, patch.y0, patch.y1, src->n, flip_y, cache_y); + contrib_rows = Memento_label(make_weights(ctx, src->h, y, h, filter, 1, dst_h_int, patch.y0, patch.y1, src->n, flip_y, cache_y), "contrib_rows"); output = fz_new_pixmap(ctx, src->colorspace, patch.x1 - patch.x0, patch.y1 - patch.y0, src->seps, src->alpha || forcealpha); } diff --git a/source/fitz/font.c b/source/fitz/font.c index 0ec6c03..2f9a288 100644 --- a/source/fitz/font.c +++ b/source/fitz/font.c @@ -335,7 +335,7 @@ struct ft_error static void *ft_alloc(FT_Memory memory, long size) { fz_context *ctx = (fz_context *) memory->user; - return fz_malloc_no_throw(ctx, size); + return Memento_label(fz_malloc_no_throw(ctx, size), "ft_alloc"); } static void ft_free(FT_Memory memory, void *block) @@ -992,6 +992,7 @@ fz_adjust_ft_glyph_width(fz_context *ctx, fz_font *font, int gid, fz_matrix *trm static fz_glyph * glyph_from_ft_bitmap(fz_context *ctx, int left, int top, FT_Bitmap *bitmap) { + (void)Memento_label(bitmap->buffer, "ft_bitmap"); if (bitmap->pixel_mode == FT_PIXEL_MODE_MONO) return fz_new_glyph_from_1bpp_data(ctx, left, top - bitmap->rows, bitmap->width, bitmap->rows, bitmap->buffer + (bitmap->rows-1)*bitmap->pitch, -bitmap->pitch); else @@ -1001,6 +1002,7 @@ glyph_from_ft_bitmap(fz_context *ctx, int left, int top, FT_Bitmap *bitmap) static fz_pixmap * pixmap_from_ft_bitmap(fz_context *ctx, int left, int top, FT_Bitmap *bitmap) { + (void)Memento_label(bitmap->buffer, "ft_bitmap"); if (bitmap->pixel_mode == FT_PIXEL_MODE_MONO) return fz_new_pixmap_from_1bpp_data(ctx, left, top - bitmap->rows, bitmap->width, bitmap->rows, bitmap->buffer + (bitmap->rows-1)*bitmap->pitch, -bitmap->pitch); else diff --git a/source/fitz/glyph.c b/source/fitz/glyph.c index 4149da3..15e2a99 100644 --- a/source/fitz/glyph.c +++ b/source/fitz/glyph.c @@ -222,7 +222,7 @@ fz_new_glyph_from_8bpp_data(fz_context *ctx, int x, int y, int w, int h, unsigne size = h * w; fill = h * sizeof(int); - glyph = fz_malloc(ctx, sizeof(fz_glyph) + size); + glyph = Memento_label(fz_malloc(ctx, sizeof(fz_glyph) + size), "fz_glyph(8)"); FZ_INIT_STORABLE(glyph, 1, fz_drop_glyph_imp); glyph->x = x; glyph->y = y; @@ -329,7 +329,7 @@ fz_new_glyph_from_8bpp_data(fz_context *ctx, int x, int y, int w, int h, unsigne * and reenter the try context, and this routine is speed * critical. */ try_pixmap: - glyph = fz_realloc(ctx, glyph, sizeof(fz_glyph)); + glyph = Memento_label(fz_realloc(ctx, glyph, sizeof(fz_glyph)), "fz_glyph(8r)"); FZ_INIT_STORABLE(glyph, 1, fz_drop_glyph_imp); pix = fz_new_pixmap_from_8bpp_data(ctx, x, y, w, h, orig_sp, span); glyph->x = pix->x; @@ -384,7 +384,7 @@ fz_new_glyph_from_1bpp_data(fz_context *ctx, int x, int y, int w, int h, unsigne size = h * w; fill = h * sizeof(int); - glyph = fz_malloc(ctx, sizeof(fz_glyph) + size); + glyph = Memento_label(fz_malloc(ctx, sizeof(fz_glyph) + size), "fz_glyph(1)"); FZ_INIT_STORABLE(glyph, 1, fz_drop_glyph_imp); glyph->x = x; glyph->y = y; diff --git a/source/fitz/halftone.c b/source/fitz/halftone.c index 4675b15..22b90d4 100644 --- a/source/fitz/halftone.c +++ b/source/fitz/halftone.c @@ -16,7 +16,7 @@ fz_new_halftone(fz_context *ctx, int comps) fz_halftone *ht; int i; - ht = fz_malloc(ctx, sizeof(fz_halftone) + (comps-1)*sizeof(fz_pixmap *)); + ht = Memento_label(fz_malloc(ctx, sizeof(fz_halftone) + (comps-1)*sizeof(fz_pixmap *)), "fz_halftone"); ht->refs = 1; ht->n = comps; for (i = 0; i < comps; i++) diff --git a/source/fitz/harfbuzz.c b/source/fitz/harfbuzz.c index f24cf87..1e83b95 100644 --- a/source/fitz/harfbuzz.c +++ b/source/fitz/harfbuzz.c @@ -142,7 +142,7 @@ void *fz_hb_malloc(size_t size) assert(ctx != NULL); - return fz_malloc_no_throw(ctx, size); + return Memento_label(fz_malloc_no_throw(ctx, size), "hb"); } void *fz_hb_calloc(size_t n, size_t size) @@ -151,7 +151,7 @@ void *fz_hb_calloc(size_t n, size_t size) assert(ctx != NULL); - return fz_calloc_no_throw(ctx, n, size); + return Memento_label(fz_calloc_no_throw(ctx, n, size), "hb"); } void *fz_hb_realloc(void *ptr, size_t size) @@ -160,7 +160,7 @@ void *fz_hb_realloc(void *ptr, size_t size) assert(ctx != NULL); - return fz_realloc_no_throw(ctx, ptr, size); + return Memento_label(fz_realloc_no_throw(ctx, ptr, size), "hb"); } void fz_hb_free(void *ptr) diff --git a/source/fitz/path.c b/source/fitz/path.c index 8347875..eca4a4a 100644 --- a/source/fitz/path.c +++ b/source/fitz/path.c @@ -1755,10 +1755,10 @@ fz_clone_path(fz_context *ctx, fz_path *path) case FZ_PATH_PACKED_OPEN: new_path->cmd_len = path->cmd_len; new_path->cmd_cap = path->cmd_cap; - new_path->cmds = clone_block(ctx, path->cmds, path->cmd_cap); + new_path->cmds = Memento_label(clone_block(ctx, path->cmds, path->cmd_cap), "path_cmds"); new_path->coord_len = path->coord_len; new_path->coord_cap = path->coord_cap; - new_path->coords = clone_block(ctx, path->coords, sizeof(float)*path->coord_cap); + new_path->coords = Memento_label(clone_block(ctx, path->coords, sizeof(float)*path->coord_cap), "path_coords"); new_path->current = path->current; new_path->begin = path->begin; break; @@ -1774,9 +1774,9 @@ fz_clone_path(fz_context *ctx, fz_path *path) new_path->coord_len = ppath->coord_len; new_path->coord_cap = ppath->coord_len; data = (uint8_t *)&ppath[1]; - new_path->coords = clone_block(ctx, data, sizeof(float)*path->coord_cap); + new_path->coords = Memento_label(clone_block(ctx, data, sizeof(float)*path->coord_cap), "path_coords"); data += sizeof(float) * path->coord_cap; - new_path->cmds = clone_block(ctx, data, path->cmd_cap); + new_path->cmds = Memento_label(clone_block(ctx, data, path->cmd_cap), "path_cmds"); xy = new_path->coords; for (i = 0; i < new_path->cmd_len; i++) { diff --git a/source/fitz/pixmap.c b/source/fitz/pixmap.c index a91fdd3..a53182e 100644 --- a/source/fitz/pixmap.c +++ b/source/fitz/pixmap.c @@ -103,7 +103,7 @@ fz_new_pixmap_with_data(fz_context *ctx, fz_colorspace *colorspace, int w, int h { if (pix->stride - 1 > INT_MAX / pix->n) fz_throw(ctx, FZ_ERROR_GENERIC, "overly wide image"); - pix->samples = fz_malloc(ctx, pix->h * pix->stride); + pix->samples = Memento_label(fz_malloc(ctx, pix->h * pix->stride), "pixmap_data"); } fz_catch(ctx) { diff --git a/source/fitz/pool.c b/source/fitz/pool.c index e7011ce..26ded2d 100644 --- a/source/fitz/pool.c +++ b/source/fitz/pool.c @@ -28,7 +28,7 @@ fz_pool *fz_new_pool(fz_context *ctx) pool = fz_malloc_struct(ctx, fz_pool); fz_try(ctx) { - node = fz_calloc(ctx, offsetof(fz_pool_node, mem) + POOL_SIZE, 1); + node = Memento_label(fz_calloc(ctx, offsetof(fz_pool_node, mem) + POOL_SIZE, 1), "fz_pool_block"); pool->head = pool->tail = node; pool->pos = node->mem; pool->end = node->mem + POOL_SIZE; @@ -47,7 +47,7 @@ static void *fz_pool_alloc_oversize(fz_context *ctx, fz_pool *pool, size_t size) fz_pool_node *node; /* link in memory at the head of the list */ - node = fz_calloc(ctx, offsetof(fz_pool_node, mem) + size, 1); + node = Memento_label(fz_calloc(ctx, offsetof(fz_pool_node, mem) + size, 1), "fz_pool_oversize"); node->next = pool->head; pool->head = node; @@ -66,7 +66,7 @@ void *fz_pool_alloc(fz_context *ctx, fz_pool *pool, size_t size) if (pool->pos + size > pool->end) { - fz_pool_node *node = fz_calloc(ctx, offsetof(fz_pool_node, mem) + POOL_SIZE, 1); + fz_pool_node *node = Memento_label(fz_calloc(ctx, offsetof(fz_pool_node, mem) + POOL_SIZE, 1), "fz_pool_block"); pool->tail = pool->tail->next = node; pool->pos = node->mem; pool->end = node->mem + POOL_SIZE; diff --git a/source/fitz/store.c b/source/fitz/store.c index 58c6e84..77432c3 100644 --- a/source/fitz/store.c +++ b/source/fitz/store.c @@ -450,7 +450,7 @@ fz_store_item(fz_context *ctx, void *key, void *val_, size_t itemsize, const fz_ * All that the above program will see is that we failed to store * the item. */ - item = fz_malloc_no_throw(ctx, sizeof (fz_item)); + item = Memento_label(fz_malloc_no_throw(ctx, sizeof (fz_item)), "fz_item"); if (!item) return NULL; memset(item, 0, sizeof (fz_item)); diff --git a/source/fitz/time.c b/source/fitz/time.c index 9fb8cfa..562a802 100644 --- a/source/fitz/time.c +++ b/source/fitz/time.c @@ -51,7 +51,7 @@ fz_utf8_from_wchar(const wchar_t *s) len += fz_runelen(*src++); } - d = malloc(len); + d = Memento_label(malloc(len), "utf8_from_wchar"); if (d != NULL) { dst = d; @@ -132,7 +132,7 @@ fz_argv_from_wargv(int argc, wchar_t **wargv) char **argv; int i; - argv = calloc(argc, sizeof(char *)); + argv = Memento_label(calloc(argc, sizeof(char *)), "fz_argv"); if (argv == NULL) { fprintf(stderr, "Out of memory while processing command line args!\n"); @@ -141,7 +141,7 @@ fz_argv_from_wargv(int argc, wchar_t **wargv) for (i = 0; i < argc; i++) { - argv[i] = fz_utf8_from_wchar(wargv[i]); + argv[i] = Memento_label(fz_utf8_from_wchar(wargv[i]), "fz_arg"); if (argv[i] == NULL) { fprintf(stderr, "Out of memory while processing command line args!\n"); diff --git a/source/fitz/unzip.c b/source/fitz/unzip.c index adfc84f..e18468d 100644 --- a/source/fitz/unzip.c +++ b/source/fitz/unzip.c @@ -147,7 +147,7 @@ static void read_zip_dir_imp(fz_context *ctx, fz_zip_archive *zip, int64_t start if (namesize < 0 || metasize < 0 || commentsize < 0) fz_throw(ctx, FZ_ERROR_GENERIC, "invalid size in zip entry"); - name = fz_malloc(ctx, namesize + 1); + name = Memento_label(fz_malloc(ctx, namesize + 1), "zip_name"); n = fz_read(ctx, file, (unsigned char*)name, namesize); if (n < (size_t)namesize) @@ -188,7 +188,7 @@ static void read_zip_dir_imp(fz_context *ctx, fz_zip_archive *zip, int64_t start fz_seek(ctx, file, commentsize, 1); - zip->entries = fz_realloc_array(ctx, zip->entries, zip->count + 1, zip_entry); + zip->entries = Memento_label(fz_realloc_array(ctx, zip->entries, zip->count + 1, zip_entry), "zip_entries"); zip->entries[zip->count].offset = offset; zip->entries[zip->count].csize = csize; diff --git a/source/html/epub-doc.c b/source/html/epub-doc.c index 423ca02..5c283df 100644 --- a/source/html/epub-doc.c +++ b/source/html/epub-doc.c @@ -309,7 +309,7 @@ epub_parse_chapter(fz_context *ctx, epub_document *doc, const char *path) fz_try(ctx) { buf = fz_read_archive_entry(ctx, zip, path); - ch->path = fz_strdup(ctx, path); + ch->path = Memento_label(fz_strdup(ctx, path), "chapter_path"); ch->html = fz_parse_html(ctx, doc->set, zip, base_uri, buf, fz_user_css(ctx)); } fz_always(ctx) @@ -351,8 +351,8 @@ epub_parse_ncx_imp(fz_context *ctx, epub_document *doc, fz_xml *node, char *base { *tailp = outline = fz_new_outline(ctx); tailp = &(*tailp)->next; - outline->title = fz_strdup(ctx, text); - outline->uri = fz_strdup(ctx, path); + outline->title = Memento_label(fz_strdup(ctx, text), "outline_title"); + outline->uri = Memento_label(fz_strdup(ctx, path), "outline_uri"); outline->page = -1; outline->down = epub_parse_ncx_imp(ctx, doc, node, base_uri); outline->is_open = 1; @@ -462,8 +462,8 @@ epub_parse_header(fz_context *ctx, epub_document *doc) metadata = fz_xml_find_down(package, "metadata"); if (metadata) { - doc->dc_title = find_metadata(ctx, metadata, "title"); - doc->dc_creator = find_metadata(ctx, metadata, "creator"); + doc->dc_title = Memento_label(find_metadata(ctx, metadata, "title"), "epub_title"); + doc->dc_creator = Memento_label(find_metadata(ctx, metadata, "creator"), "epub_creator"); } manifest = fz_xml_find_down(package, "manifest"); diff --git a/source/html/html-outline.c b/source/html/html-outline.c index a1a2cbf..7e055ea 100644 --- a/source/html/html-outline.c +++ b/source/html/html-outline.c @@ -357,13 +357,13 @@ add_html_outline(fz_context *ctx, struct outline_parser *x, fz_html_box *box) node = fz_new_outline(ctx); fz_try(ctx) { - node->title = fz_strdup(ctx, cat_html_text(ctx, x, box)); + node->title = Memento_label(fz_strdup(ctx, cat_html_text(ctx, x, box)), "outline_title"); if (!box->id) { fz_snprintf(buf, sizeof buf, "'%d", x->id++); - box->id = fz_pool_strdup(ctx, x->html->pool, buf); + box->id = Memento_label(fz_pool_strdup(ctx, x->html->pool, buf), "box_id"); } - node->uri = fz_asprintf(ctx, "#%s", box->id); + node->uri = Memento_label(fz_asprintf(ctx, "#%s", box->id), "outline_uri"); node->is_open = 1; } fz_catch(ctx) diff --git a/source/pdf/pdf-outline.c b/source/pdf/pdf-outline.c index ce14ffa..24fa468 100644 --- a/source/pdf/pdf-outline.c +++ b/source/pdf/pdf-outline.c @@ -24,12 +24,12 @@ pdf_load_outline_imp(fz_context *ctx, pdf_document *doc, pdf_obj *dict) obj = pdf_dict_get(ctx, dict, PDF_NAME(Title)); if (obj) - node->title = fz_strdup(ctx, pdf_to_text_string(ctx, obj)); + node->title = Memento_label(fz_strdup(ctx, pdf_to_text_string(ctx, obj)), "outline_title"); if ((obj = pdf_dict_get(ctx, dict, PDF_NAME(Dest))) != NULL) - node->uri = pdf_parse_link_dest(ctx, doc, obj); + node->uri = Memento_label(pdf_parse_link_dest(ctx, doc, obj), "outline_uri"); else if ((obj = pdf_dict_get(ctx, dict, PDF_NAME(A))) != NULL) - node->uri = pdf_parse_link_action(ctx, doc, obj, -1); + node->uri = Memento_label(pdf_parse_link_action(ctx, doc, obj, -1), "outline_uri"); else node->uri = NULL; diff --git a/source/xps/xps-outline.c b/source/xps/xps-outline.c index bf43f25..dfa5143 100644 --- a/source/xps/xps-outline.c +++ b/source/xps/xps-outline.c @@ -35,8 +35,8 @@ xps_parse_document_outline(fz_context *ctx, xps_document *doc, fz_xml *root) continue; entry = fz_new_outline(ctx); - entry->title = fz_strdup(ctx, description); - entry->uri = fz_strdup(ctx, target); + entry->title = Memento_label(fz_strdup(ctx, description), "outline_title"); + entry->uri = Memento_label(fz_strdup(ctx, target), "outline_uri"); entry->page = xps_lookup_link_target(ctx, (fz_document*)doc, target, NULL, NULL); entry->down = NULL; entry->next = NULL; http://git.ghostscript.com/?p=mupdf.git;a=commit;h=c95d3efe1efbabf7510e82f4fbbe4ef62d8f6f65 -- MuPDF library Artifex Software, Inc.