summaryrefslogtreecommitdiff
path: root/pdf/pdf_stream.c
diff options
context:
space:
mode:
authorRobin Watts <robin.watts@artifex.com>2011-12-08 14:24:33 +0000
committerRobin Watts <robin.watts@artifex.com>2011-12-08 14:24:33 +0000
commit0e6931ad400fbf2780bd06530a3135653f8c9b4f (patch)
tree392572d681660f3af0749f30f1102b42ff6d51c7 /pdf/pdf_stream.c
parent31d174bb39bfbde8861882c128dafd383a8fed7d (diff)
downloadmupdf-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_stream.c')
-rw-r--r--pdf/pdf_stream.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/pdf/pdf_stream.c b/pdf/pdf_stream.c
index 614f076a..0a38d20f 100644
--- a/pdf/pdf_stream.c
+++ b/pdf/pdf_stream.c
@@ -228,9 +228,11 @@ pdf_open_inline_stream(fz_stream *chain, pdf_xref *xref, fz_obj *stmobj, int len
fz_stream *
pdf_open_raw_stream(pdf_xref *xref, int num, int gen)
{
- pdf_xref_entry * volatile x;
+ pdf_xref_entry *x;
fz_stream *stm;
+ fz_var(x);
+
if (num < 0 || num >= xref->len)
fz_throw(xref->ctx, "object id out of range (%d %d R)", num, gen);
@@ -341,7 +343,9 @@ pdf_load_stream(pdf_xref *xref, int num, int gen)
fz_stream *stm;
fz_obj *dict, *obj;
int i, len, n;
- fz_buffer * volatile buf;
+ fz_buffer *buf;
+
+ fz_var(buf);
stm = pdf_open_stream(xref, num, gen);
/* RJW: "cannot open stream (%d %d R)", num, gen */