diff options
author | Robin Watts <robin.watts@artifex.com> | 2011-12-08 14:24:33 +0000 |
---|---|---|
committer | Robin Watts <robin.watts@artifex.com> | 2011-12-08 14:24:33 +0000 |
commit | 0e6931ad400fbf2780bd06530a3135653f8c9b4f (patch) | |
tree | 392572d681660f3af0749f30f1102b42ff6d51c7 /pdf/pdf_parse.c | |
parent | 31d174bb39bfbde8861882c128dafd383a8fed7d (diff) | |
download | mupdf-0e6931ad400fbf2780bd06530a3135653f8c9b4f.tar.xz |
Move from volatile to fz_var.
When using exceptions (which are implemented using setjmp/longjmp), we
need to be careful to ensure that variable values get written back
before any exception happens.
Previously we've done that using volatile, but that produces nasty
warnings (and unduly limits the compilers freedom to optimise). Here
we introduce a new macro fz_var that passes the address of the variable
out of scope. This means that the compiler has to ensure that any
changes to its value are written back to memory before calling any
out of scope function.
Diffstat (limited to 'pdf/pdf_parse.c')
-rw-r--r-- | pdf/pdf_parse.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/pdf/pdf_parse.c b/pdf/pdf_parse.c index 6b7fdb12..7174c23a 100644 --- a/pdf/pdf_parse.c +++ b/pdf/pdf_parse.c @@ -302,14 +302,18 @@ end: fz_obj * pdf_parse_dict(pdf_xref *xref, fz_stream *file, char *buf, int cap) { - fz_obj * volatile dict = NULL; - fz_obj * volatile key = NULL; - fz_obj * volatile val = NULL; + fz_obj *dict = NULL; + fz_obj *key = NULL; + fz_obj *val = NULL; int tok; int len; int a, b; fz_context *ctx = file->ctx; + fz_var(dict); + fz_var(key); + fz_var(val); + dict = fz_new_dict(ctx, 8); fz_try(ctx) @@ -430,13 +434,15 @@ pdf_parse_ind_obj(pdf_xref *xref, fz_stream *file, char *buf, int cap, int *onum, int *ogen, int *ostmofs) { - fz_obj * volatile obj = NULL; + fz_obj *obj = NULL; int num = 0, gen = 0, stm_ofs; int tok; int len; int a, b; fz_context *ctx = file->ctx; + fz_var(obj); + tok = pdf_lex(file, buf, cap, &len); /* RJW: cannot parse indirect object (%d %d R)", num, gen */ if (tok != PDF_TOK_INT) |