From 2c6de6e7a8374ba454f1852377fa65ac1216e626 Mon Sep 17 00:00:00 2001 From: Robin Watts Date: Tue, 28 Mar 2017 11:37:30 +0100 Subject: Rejig fz_new_annot to fz_new_derived_annot. More consistent with the rest of the code. --- include/mupdf/fitz/annotation.h | 7 +++++-- source/fitz/document.c | 4 ++-- source/pdf/pdf-annot.c | 2 +- 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; -- cgit v1.2.3