From 977ad5326276de29f0b2ae212a1cb4c09d8d94e0 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Fri, 3 Feb 2012 13:58:07 +0100 Subject: Make fz_malloc_struct return zeroed memory. --- fitz/dev_null.c | 1 - fitz/filt_dctd.c | 1 - fitz/fitz.h | 6 +++--- 3 files changed, 3 insertions(+), 5 deletions(-) (limited to 'fitz') diff --git a/fitz/dev_null.c b/fitz/dev_null.c index 183c4e21..b4ba5cbe 100644 --- a/fitz/dev_null.c +++ b/fitz/dev_null.c @@ -4,7 +4,6 @@ fz_device * fz_new_device(fz_context *ctx, void *user) { fz_device *dev = fz_malloc_struct(ctx, fz_device); - memset(dev, 0, sizeof *dev); dev->hints = 0; dev->flags = 0; dev->user = user; diff --git a/fitz/filt_dctd.c b/fitz/filt_dctd.c index 03dfe87c..4357f3d7 100644 --- a/fitz/filt_dctd.c +++ b/fitz/filt_dctd.c @@ -224,7 +224,6 @@ fz_open_dctd(fz_stream *chain, int color_transform) fz_try(ctx) { state = fz_malloc_struct(chain->ctx, fz_dctd); - memset(state, 0, sizeof(fz_dctd)); state->ctx = ctx; state->chain = chain; state->color_transform = color_transform; diff --git a/fitz/fitz.h b/fitz/fitz.h index 3eebaf59..8483817d 100644 --- a/fitz/fitz.h +++ b/fitz/fitz.h @@ -400,8 +400,8 @@ fz_unlock(fz_context *ctx) /* The following throw exceptions on failure to allocate */ void *fz_malloc(fz_context *ctx, unsigned int size); -void *fz_malloc_array(fz_context *ctx, unsigned int count, unsigned int size); void *fz_calloc(fz_context *ctx, unsigned int count, unsigned int size); +void *fz_malloc_array(fz_context *ctx, unsigned int count, unsigned int size); void *fz_resize_array(fz_context *ctx, void *p, unsigned int count, unsigned int size); char *fz_strdup(fz_context *ctx, char *s); @@ -414,9 +414,9 @@ void *fz_calloc_no_throw(fz_context *ctx, unsigned int count, unsigned int size) void *fz_resize_array_no_throw(fz_context *ctx, void *p, unsigned int count, unsigned int size); char *fz_strdup_no_throw(fz_context *ctx, char *s); +/* alloc and zero a struct, and tag it for memento */ #define fz_malloc_struct(CTX, STRUCT) \ - Memento_label(fz_malloc(CTX,sizeof(STRUCT)), #STRUCT) - + Memento_label(fz_calloc(CTX,1,sizeof(STRUCT)), #STRUCT) /* runtime (hah!) test for endian-ness */ int fz_is_big_endian(void); -- cgit v1.2.3