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_repair.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_repair.c')
-rw-r--r-- | pdf/pdf_repair.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/pdf/pdf_repair.c b/pdf/pdf_repair.c index 7930b5b5..bfa89751 100644 --- a/pdf/pdf_repair.c +++ b/pdf/pdf_repair.c @@ -192,12 +192,12 @@ pdf_repair_xref(pdf_xref *xref, char *buf, int bufsize) fz_obj *dict, *obj; fz_obj *length; - fz_obj * volatile encrypt = NULL; - fz_obj * volatile id = NULL; - fz_obj * volatile root = NULL; - fz_obj * volatile info = NULL; + fz_obj *encrypt = NULL; + fz_obj *id = NULL; + fz_obj *root = NULL; + fz_obj *info = NULL; - struct entry * volatile list = NULL; + struct entry *list = NULL; int listlen; int listcap; int maxnum = 0; @@ -211,6 +211,12 @@ pdf_repair_xref(pdf_xref *xref, char *buf, int bufsize) int i, n, c; fz_context *ctx = xref->ctx; + fz_var(encrypt); + fz_var(id); + fz_var(root); + fz_var(info); + fz_var(list); + fz_seek(xref->file, 0, 0); fz_try(ctx) |