From 13fea96f5290a7abd52611bb96c2486e2ecc2169 Mon Sep 17 00:00:00 2001 From: Sebastian Rasmussen Date: Sun, 14 Jul 2013 15:52:08 +0200 Subject: Update single- and multi-threaded example mupdf usage. --- docs/example.c | 8 ++++++-- docs/multi-threaded.c | 13 ++++++++----- 2 files changed, 14 insertions(+), 7 deletions(-) (limited to 'docs') diff --git a/docs/example.c b/docs/example.c index 1a21c200..cf7d0176 100644 --- a/docs/example.c +++ b/docs/example.c @@ -2,7 +2,11 @@ // Compile a debug build of mupdf, then compile and run this example: // -// gcc -g -o build/debug/example -Iinclude doc/example.c build/debug/lib*.a -lm +// gcc -g -o build/debug/example -Iinclude docs/example.c \ +// build/debug/libmupdf.a build/debug/libmupdf-js-none.a \ +// build/debug/libfreetype.a build/debug/libjbig2dec.a \ +// build/debug/libjpeg.a build/debug/libopenjpeg.a \ +// build/debug/libz.a -lm // // build/debug/example /path/to/document.pdf 1 200 25 @@ -90,7 +94,7 @@ render(char *filename, int pagenumber, int zoom, int rotation) int main(int argc, char **argv) { - char *filename = argv[1]; + char *filename = argc >= 2 ? argv[1] : ""; int pagenumber = argc > 2 ? atoi(argv[2]) : 1; int zoom = argc > 3 ? atoi(argv[3]) : 100; int rotation = argc > 4 ? atoi(argv[4]) : 0; diff --git a/docs/multi-threaded.c b/docs/multi-threaded.c index 3141e3c4..57e76070 100644 --- a/docs/multi-threaded.c +++ b/docs/multi-threaded.c @@ -13,8 +13,11 @@ // Compile a debug build of mupdf, then compile and run this example: // -// gcc -g -o build/debug/example-mt -Iinclude doc/multi-threading.c \ -// build/debug/lib*.a -lpthread -lm +// gcc -g -o build/debug/example-mt -Iinclude docs/multi-threaded.c \ +// build/debug/libmupdf.a build/debug/libmupdf-js-none.a \ +// build/debug/libfreetype.a build/debug/libjbig2dec.a \ +// build/debug/libjpeg.a build/debug/libopenjpeg.a \ +// build/debug/libz.a -lpthread -lm // // build/debug/example-mt /path/to/document.pdf // @@ -32,7 +35,7 @@ void fail(char *msg) { - fprintf(stderr, "%s", msg); + fprintf(stderr, "%s\n", msg); abort(); } @@ -127,7 +130,7 @@ void unlock_mutex(void *user, int lock) int main(int argc, char **argv) { - char *filename = argv[1]; + char *filename = argc >= 2 ? argv[1] : ""; pthread_t *thread = NULL; fz_locks_context locks; pthread_mutex_t mutex[FZ_LOCK_MAX]; @@ -243,7 +246,7 @@ int main(int argc, char **argv) // they were allocated by the main thread above. fz_drop_pixmap(ctx, data->pix); - fz_free_display_list(ctx, data->list); + fz_drop_display_list(ctx, data->list); // Free the data structured passed back and forth // between the main thread and rendering thread. -- cgit v1.2.3