summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin Watts <robin.watts@artifex.com>2017-03-28 10:55:24 +0100
committerRobin Watts <robin.watts@artifex.com>2017-03-28 10:56:21 +0100
commita7e597397133d4aaa717869258eac6ae34c7dad0 (patch)
treece8c4a2c34f4282b69ddd24531ae1c319470e8c4
parent57b2ee8fe52cf9e2eaf4095b8697f33e17a5529f (diff)
downloadmupdf-a7e597397133d4aaa717869258eac6ae34c7dad0.tar.xz
Rejig fz_new_device to be fz_new_derived_device.
In keeping with the rest of the code.
-rw-r--r--include/mupdf/fitz/device.h5
-rw-r--r--platform/java/mupdf_native.c2
-rw-r--r--source/fitz/bbox-device.c2
-rw-r--r--source/fitz/device.c4
-rw-r--r--source/fitz/draw-device.c2
-rw-r--r--source/fitz/list-device.c2
-rw-r--r--source/fitz/stext-device.c2
-rw-r--r--source/fitz/svg-device.c2
-rw-r--r--source/fitz/test-device.c2
-rw-r--r--source/fitz/trace-device.c2
-rw-r--r--source/pdf/pdf-device.c2
-rw-r--r--source/tools/murun.c2
12 files changed, 16 insertions, 13 deletions
diff --git a/include/mupdf/fitz/device.h b/include/mupdf/fitz/device.h
index e40cc2a5..d65bfcb8 100644
--- a/include/mupdf/fitz/device.h
+++ b/include/mupdf/fitz/device.h
@@ -147,7 +147,10 @@ int fz_begin_tile_id(fz_context *ctx, fz_device *dev, const fz_rect *area, const
void fz_end_tile(fz_context *ctx, fz_device *dev);
void fz_render_flags(fz_context *ctx, fz_device *dev, int set, int clear);
-void *fz_new_device(fz_context *ctx, int size);
+fz_device *fz_new_device_of_size(fz_context *ctx, int size);
+
+#define fz_new_derived_device(CTX, TYPE) \
+ ((TYPE *)Memento_label(fz_new_device_of_size(ctx,sizeof(TYPE)),#TYPE))
/*
fz_close_device: Signal the end of input, and flush any buffered output.
diff --git a/platform/java/mupdf_native.c b/platform/java/mupdf_native.c
index a7ebddee..a4136004 100644
--- a/platform/java/mupdf_native.c
+++ b/platform/java/mupdf_native.c
@@ -2036,7 +2036,7 @@ static fz_device *fz_new_java_device(fz_context *ctx, JNIEnv *env, jobject self)
fz_try(ctx)
{
- dev = fz_new_device(ctx, sizeof(fz_java_device));
+ dev = fz_new_derived_device(ctx, fz_java_device);
dev->env = env;
dev->self = jself;
diff --git a/source/fitz/bbox-device.c b/source/fitz/bbox-device.c
index 340eef3c..26268712 100644
--- a/source/fitz/bbox-device.c
+++ b/source/fitz/bbox-device.c
@@ -189,7 +189,7 @@ fz_bbox_drop_device(fz_context *ctx, fz_device *dev)
fz_device *
fz_new_bbox_device(fz_context *ctx, fz_rect *result)
{
- fz_bbox_device *dev = fz_new_device(ctx, sizeof *dev);
+ fz_bbox_device *dev = fz_new_derived_device(ctx, fz_bbox_device);
dev->super.drop_device = fz_bbox_drop_device;
diff --git a/source/fitz/device.c b/source/fitz/device.c
index 727000e8..f79c8edf 100644
--- a/source/fitz/device.c
+++ b/source/fitz/device.c
@@ -1,7 +1,7 @@
#include "fitz-imp.h"
-void *
-fz_new_device(fz_context *ctx, int size)
+fz_device *
+fz_new_device_of_size(fz_context *ctx, int size)
{
fz_device *dev = Memento_label(fz_calloc(ctx, 1, size), "fz_device");
dev->refs = 1;
diff --git a/source/fitz/draw-device.c b/source/fitz/draw-device.c
index 857844fe..25323b15 100644
--- a/source/fitz/draw-device.c
+++ b/source/fitz/draw-device.c
@@ -2294,7 +2294,7 @@ fz_draw_render_flags(fz_context *ctx, fz_device *devp, int set, int clear)
fz_device *
fz_new_draw_device(fz_context *ctx, const fz_matrix *transform, fz_pixmap *dest)
{
- fz_draw_device *dev = fz_new_device(ctx, sizeof *dev);
+ fz_draw_device *dev = fz_new_derived_device(ctx, fz_draw_device);
dev->super.drop_device = fz_draw_drop_device;
diff --git a/source/fitz/list-device.c b/source/fitz/list-device.c
index b12612b4..1f0d19d6 100644
--- a/source/fitz/list-device.c
+++ b/source/fitz/list-device.c
@@ -1209,7 +1209,7 @@ fz_new_list_device(fz_context *ctx, fz_display_list *list)
{
fz_list_device *dev;
- dev = fz_new_device(ctx, sizeof(fz_list_device));
+ dev = fz_new_derived_device(ctx, fz_list_device);
dev->super.fill_path = fz_list_fill_path;
dev->super.stroke_path = fz_list_stroke_path;
diff --git a/source/fitz/stext-device.c b/source/fitz/stext-device.c
index 06a06e83..d0d9d401 100644
--- a/source/fitz/stext-device.c
+++ b/source/fitz/stext-device.c
@@ -1097,7 +1097,7 @@ fz_parse_stext_options(fz_context *ctx, fz_stext_options *opts, const char *stri
fz_device *
fz_new_stext_device(fz_context *ctx, fz_stext_sheet *sheet, fz_stext_page *page, const fz_stext_options *opts)
{
- fz_stext_device *dev = fz_new_device(ctx, sizeof *dev);
+ fz_stext_device *dev = fz_new_derived_device(ctx, fz_stext_device);
dev->super.hints = FZ_IGNORE_IMAGE | FZ_IGNORE_SHADE;
diff --git a/source/fitz/svg-device.c b/source/fitz/svg-device.c
index e80682fd..9ae4f189 100644
--- a/source/fitz/svg-device.c
+++ b/source/fitz/svg-device.c
@@ -1255,7 +1255,7 @@ svg_dev_drop_device(fz_context *ctx, fz_device *dev)
fz_device *fz_new_svg_device(fz_context *ctx, fz_output *out, float page_width, float page_height, int text_format, int reuse_images)
{
- svg_device *dev = fz_new_device(ctx, sizeof *dev);
+ svg_device *dev = fz_new_derived_device(ctx, svg_device);
dev->super.close_device = svg_dev_close_device;
dev->super.drop_device = svg_dev_drop_device;
diff --git a/source/fitz/test-device.c b/source/fitz/test-device.c
index abe27dbb..f12a294b 100644
--- a/source/fitz/test-device.c
+++ b/source/fitz/test-device.c
@@ -462,7 +462,7 @@ fz_test_end_tile(fz_context *ctx, fz_device *dev_)
fz_device *
fz_new_test_device(fz_context *ctx, int *is_color, float threshold, int options, fz_device *passthrough)
{
- fz_test_device *dev = fz_new_device(ctx, sizeof *dev);
+ fz_test_device *dev = fz_new_derived_device(ctx, fz_test_device);
dev->super.fill_path = fz_test_fill_path;
dev->super.stroke_path = fz_test_stroke_path;
diff --git a/source/fitz/trace-device.c b/source/fitz/trace-device.c
index d306297f..c2f8b4c2 100644
--- a/source/fitz/trace-device.c
+++ b/source/fitz/trace-device.c
@@ -350,7 +350,7 @@ fz_trace_end_tile(fz_context *ctx, fz_device *dev)
fz_device *fz_new_trace_device(fz_context *ctx, fz_output *out)
{
- fz_trace_device *dev = fz_new_device(ctx, sizeof *dev);
+ fz_trace_device *dev = fz_new_derived_device(ctx, fz_trace_device);
dev->super.fill_path = fz_trace_fill_path;
dev->super.stroke_path = fz_trace_stroke_path;
diff --git a/source/pdf/pdf-device.c b/source/pdf/pdf-device.c
index 8a5b17e2..ec247cec 100644
--- a/source/pdf/pdf-device.c
+++ b/source/pdf/pdf-device.c
@@ -1081,7 +1081,7 @@ pdf_dev_drop_device(fz_context *ctx, fz_device *dev)
fz_device *pdf_new_pdf_device(fz_context *ctx, pdf_document *doc, const fz_matrix *topctm, const fz_rect *mediabox, pdf_obj *resources, fz_buffer *buf)
{
- pdf_device *dev = fz_new_device(ctx, sizeof *dev);
+ pdf_device *dev = fz_new_derived_device(ctx, pdf_device);
dev->super.close_device = pdf_dev_close_device;
dev->super.drop_device = pdf_dev_drop_device;
diff --git a/source/tools/murun.c b/source/tools/murun.c
index 9ee0f0da..c5cefb62 100644
--- a/source/tools/murun.c
+++ b/source/tools/murun.c
@@ -1073,7 +1073,7 @@ js_dev_end_tile(fz_context *ctx, fz_device *dev)
static fz_device *new_js_device(fz_context *ctx, js_State *J)
{
- js_device *dev = fz_new_device(ctx, sizeof *dev);
+ js_device *dev = fz_new_derived_device(ctx, js_device);
dev->super.fill_path = js_dev_fill_path;
dev->super.stroke_path = js_dev_stroke_path;