summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--draw/draw_device.c2
-rw-r--r--fitz/dev_null.c1
-rw-r--r--fitz/filt_dctd.c1
-rw-r--r--fitz/fitz.h6
-rw-r--r--pdf/pdf_crypt.c1
-rw-r--r--pdf/pdf_function.c1
-rw-r--r--xps/xps_zip.c4
7 files changed, 3 insertions, 13 deletions
diff --git a/draw/draw_device.c b/draw/draw_device.c
index 63c2bc32..03e5d268 100644
--- a/draw/draw_device.c
+++ b/draw/draw_device.c
@@ -1567,8 +1567,6 @@ fz_new_draw_device(fz_context *ctx, fz_pixmap *dest)
fz_device *dev = NULL;
fz_draw_device *ddev = fz_malloc_struct(ctx, fz_draw_device);
- memset(ddev, 0, sizeof(*ddev));
-
fz_var(dev);
fz_try(ctx)
{
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);
diff --git a/pdf/pdf_crypt.c b/pdf/pdf_crypt.c
index c3cd5d8c..59423a38 100644
--- a/pdf/pdf_crypt.c
+++ b/pdf/pdf_crypt.c
@@ -54,7 +54,6 @@ pdf_new_crypt(fz_context *ctx, fz_obj *dict, fz_obj *id)
fz_obj *obj;
crypt = fz_malloc_struct(ctx, pdf_crypt);
- memset(crypt, 0, sizeof *crypt);
/* Common to all security handlers (PDF 1.7 table 3.18) */
diff --git a/pdf/pdf_function.c b/pdf/pdf_function.c
index 8d1be207..ff602021 100644
--- a/pdf/pdf_function.c
+++ b/pdf/pdf_function.c
@@ -1365,7 +1365,6 @@ pdf_load_function(pdf_document *xref, fz_obj *dict)
}
func = fz_malloc_struct(ctx, pdf_function);
- memset(func, 0, sizeof *func);
FZ_INIT_STORABLE(func, 1, pdf_free_function_imp);
func->size = sizeof(*func);
diff --git a/xps/xps_zip.c b/xps/xps_zip.c
index f38538c3..38f0cb60 100644
--- a/xps/xps_zip.c
+++ b/xps/xps_zip.c
@@ -456,8 +456,6 @@ xps_open_document_with_directory(fz_context *ctx, char *directory)
xps_document *doc;
doc = fz_malloc_struct(ctx, xps_document);
- memset(doc, 0, sizeof *doc);
-
doc->ctx = ctx;
doc->directory = fz_strdup(ctx, directory);
@@ -481,8 +479,6 @@ xps_open_document_with_stream(fz_stream *file)
xps_document *doc;
doc = fz_malloc_struct(ctx, xps_document);
- memset(doc, 0, sizeof *doc);
-
doc->ctx = ctx;
doc->file = fz_keep_stream(file);