summaryrefslogtreecommitdiff
path: root/scripts/cmapdump.c
diff options
context:
space:
mode:
authorRobin Watts <robin.watts@artifex.com>2011-09-14 17:36:57 +0100
committerRobin Watts <Robin.Watts@artifex.com>2011-09-15 14:50:17 +0100
commitb51ef0eea028c73b6379e832eaa34fff3fbbb927 (patch)
tree1ab685ccd356e7fdc832b2e3322c0486b2670cfb /scripts/cmapdump.c
parent89ae81f651bfa112b8e07317eb6983beaf7cb212 (diff)
downloadmupdf-b51ef0eea028c73b6379e832eaa34fff3fbbb927.tar.xz
Add context to mupdf.
Huge pervasive change to lots of files, adding a context for exception handling and allocation. In time we'll move more statics into there. Also fix some for(i = 0; i < function(...); i++) calls.
Diffstat (limited to 'scripts/cmapdump.c')
-rw-r--r--scripts/cmapdump.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/scripts/cmapdump.c b/scripts/cmapdump.c
index b1e91f9b..06e74beb 100644
--- a/scripts/cmapdump.c
+++ b/scripts/cmapdump.c
@@ -15,6 +15,8 @@
#include "../fitz/stm_buffer.c"
#include "../fitz/stm_open.c"
#include "../fitz/stm_read.c"
+#include "../fitz/context.c"
+#include "../fitz/except.c"
#include "../pdf/pdf_lex.c"
#include "../pdf/pdf_cmap.c"
@@ -41,6 +43,7 @@ main(int argc, char **argv)
char name[256];
char *realname;
int i, k;
+ fz_context *ctx;
if (argc < 3)
{
@@ -48,6 +51,13 @@ main(int argc, char **argv)
return 1;
}
+ ctx = fz_context_init(&fz_alloc_default);
+ if (ctx == NULL)
+ {
+ fprintf(stderr, "failed to initialise!\n");
+ return 1;
+ }
+
fo = fopen(argv[1], "wb");
if (!fo)
{
@@ -76,7 +86,7 @@ main(int argc, char **argv)
strcpy(name, realname);
clean(name);
- fi = fz_open_file(argv[i]);
+ fi = fz_open_file(ctx, argv[i]);
if (!fi)
fz_error_make("cmapdump: could not open input file '%s'\n", argv[i]);
@@ -156,5 +166,6 @@ main(int argc, char **argv)
return 1;
}
+ fz_context_fin(ctx);
return 0;
}