From 09a016ee7c5c81580b27db3bd193b38cb3bd4f0e Mon Sep 17 00:00:00 2001 From: Robin Watts Date: Fri, 16 Dec 2011 16:26:48 +0000 Subject: 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. --- fitz/dev_list.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'fitz/dev_list.c') diff --git a/fitz/dev_list.c b/fitz/dev_list.c index 47e8b069..03c65f49 100644 --- a/fitz/dev_list.c +++ b/fitz/dev_list.c @@ -70,7 +70,7 @@ fz_new_display_node(fz_context *ctx, fz_display_command cmd, fz_matrix ctm, fz_display_node *node; int i; - node = fz_malloc(ctx, sizeof(fz_display_node)); + node = fz_malloc_struct(ctx, fz_display_node); node->cmd = cmd; node->next = NULL; node->rect = fz_empty_rect; @@ -99,7 +99,7 @@ fz_new_display_node(fz_context *ctx, fz_display_command cmd, fz_matrix ctm, static fz_stroke_state * fz_clone_stroke_state(fz_context *ctx, fz_stroke_state *stroke) { - fz_stroke_state *newstroke = fz_malloc(ctx, sizeof(fz_stroke_state)); + fz_stroke_state *newstroke = fz_malloc_struct(ctx, fz_stroke_state); *newstroke = *stroke; return newstroke; } @@ -482,7 +482,7 @@ fz_new_list_device(fz_context *ctx, fz_display_list *list) fz_display_list * fz_new_display_list(fz_context *ctx) { - fz_display_list *list = fz_malloc(ctx, sizeof(fz_display_list)); + fz_display_list *list = fz_malloc_struct(ctx, fz_display_list); list->first = NULL; list->last = NULL; list->top = 0; -- cgit v1.2.3