diff options
author | Robin Watts <robin.watts@artifex.com> | 2011-09-14 17:36:57 +0100 |
---|---|---|
committer | Robin Watts <Robin.Watts@artifex.com> | 2011-09-15 14:50:17 +0100 |
commit | b51ef0eea028c73b6379e832eaa34fff3fbbb927 (patch) | |
tree | 1ab685ccd356e7fdc832b2e3322c0486b2670cfb /apps/win_main.c | |
parent | 89ae81f651bfa112b8e07317eb6983beaf7cb212 (diff) | |
download | mupdf-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 'apps/win_main.c')
-rw-r--r-- | apps/win_main.c | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/apps/win_main.c b/apps/win_main.c index 92f7f085..24279e1d 100644 --- a/apps/win_main.c +++ b/apps/win_main.c @@ -37,6 +37,7 @@ static pdfapp_t gapp; static wchar_t wbuf[1024]; static char filename[1024]; +static fz_context *context; /* * Create registry keys to associate MuPDF with PDF and XPS files. @@ -240,33 +241,33 @@ dloginfoproc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) SetDlgItemTextA(hwnd, 0x13, "n/a"); } - info = fz_dict_gets(xref->trailer, "Info"); + info = fz_dict_gets(xref->ctx, xref->trailer, "Info"); if (!info) return TRUE; #define SETUCS(ID) \ { \ unsigned short *ucs; \ - ucs = pdf_to_ucs2(obj); \ + ucs = pdf_to_ucs2(xref->ctx, obj); \ SetDlgItemTextW(hwnd, ID, ucs); \ - fz_free(ucs); \ + fz_free(context, ucs); \ } - if ((obj = fz_dict_gets(info, "Title"))) + if ((obj = fz_dict_gets(xref->ctx, info, "Title"))) SETUCS(0x20); - if ((obj = fz_dict_gets(info, "Author"))) + if ((obj = fz_dict_gets(xref->ctx, info, "Author"))) SETUCS(0x21); - if ((obj = fz_dict_gets(info, "Subject"))) + if ((obj = fz_dict_gets(xref->ctx, info, "Subject"))) SETUCS(0x22); - if ((obj = fz_dict_gets(info, "Keywords"))) + if ((obj = fz_dict_gets(xref->ctx, info, "Keywords"))) SETUCS(0x23); - if ((obj = fz_dict_gets(info, "Creator"))) + if ((obj = fz_dict_gets(xref->ctx, info, "Creator"))) SETUCS(0x24); - if ((obj = fz_dict_gets(info, "Producer"))) + if ((obj = fz_dict_gets(xref->ctx, info, "Producer"))) SETUCS(0x25); - if ((obj = fz_dict_gets(info, "CreationDate"))) + if ((obj = fz_dict_gets(xref->ctx, info, "CreationDate"))) SETUCS(0x26); - if ((obj = fz_dict_gets(info, "ModDate"))) + if ((obj = fz_dict_gets(xref->ctx, info, "ModDate"))) SETUCS(0x27); return TRUE; @@ -853,10 +854,17 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShow MSG msg; int fd; int code; + fz_context *ctx; fz_accelerate(); - pdfapp_init(&gapp); + ctx = fz_context_init(&fz_alloc_default); + if (ctx == NULL) + { + fprintf(stderr, "Failed to init context"); + exit(1); + } + pdfapp_init(ctx, &gapp); GetModuleFileNameA(NULL, argv0, sizeof argv0); install_app(argv0); |