summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin Watts <robin.watts@artifex.com>2017-03-28 11:37:30 +0100
committerRobin Watts <robin.watts@artifex.com>2017-03-28 11:38:28 +0100
commit2c6de6e7a8374ba454f1852377fa65ac1216e626 (patch)
treec701b01dd8f9d5f02e846cc648c360c2ccdc20f5
parenta7e597397133d4aaa717869258eac6ae34c7dad0 (diff)
downloadmupdf-2c6de6e7a8374ba454f1852377fa65ac1216e626.tar.xz
Rejig fz_new_annot to fz_new_derived_annot.
More consistent with the rest of the code.
-rw-r--r--include/mupdf/fitz/annotation.h7
-rw-r--r--source/fitz/document.c4
-rw-r--r--source/pdf/pdf-annot.c2
3 files changed, 8 insertions, 5 deletions
diff --git a/include/mupdf/fitz/annotation.h b/include/mupdf/fitz/annotation.h
index b602409f..0521be77 100644
--- a/include/mupdf/fitz/annotation.h
+++ b/include/mupdf/fitz/annotation.h
@@ -7,9 +7,12 @@
#include "mupdf/fitz/document.h"
/*
- fz_new_annot: Create and initialize an annotation struct.
+ fz_new_annot_of_size: Create and initialize an annotation struct.
*/
-void *fz_new_annot(fz_context *ctx, int size);
+fz_annot *fz_new_annot_of_size(fz_context *ctx, int size);
+
+#define fz_new_derived_annot(CTX, TYPE) \
+ ((TYPE *)Memento_label(fz_new_annot_of_size(CTX,sizeof(TYPE)),#TYPE))
/*
fz_keep_annot: Take a new reference to an annotation.
diff --git a/source/fitz/document.c b/source/fitz/document.c
index 2fb64ad9..8bf8d348 100644
--- a/source/fitz/document.c
+++ b/source/fitz/document.c
@@ -385,8 +385,8 @@ fz_run_page(fz_context *ctx, fz_page *page, fz_device *dev, const fz_matrix *tra
}
}
-void *
-fz_new_annot(fz_context *ctx, int size)
+fz_annot *
+fz_new_annot_of_size(fz_context *ctx, int size)
{
fz_annot *annot = Memento_label(fz_calloc(ctx, 1, size), "fz_annot");
annot->refs = 1;
diff --git a/source/pdf/pdf-annot.c b/source/pdf/pdf-annot.c
index 6f622da4..539c4882 100644
--- a/source/pdf/pdf-annot.c
+++ b/source/pdf/pdf-annot.c
@@ -371,7 +371,7 @@ pdf_annot_transform(fz_context *ctx, pdf_annot *annot, fz_matrix *annot_ctm)
pdf_annot *pdf_new_annot(fz_context *ctx, pdf_page *page)
{
- pdf_annot *annot = fz_new_annot(ctx, sizeof(pdf_annot));
+ pdf_annot *annot = fz_new_derived_annot(ctx, pdf_annot);
annot->super.drop_annot = (fz_annot_drop_fn*)pdf_drop_annot_imp;
annot->super.bound_annot = (fz_annot_bound_fn*)pdf_bound_annot;