Age | Commit message (Collapse) | Author |
|
|
|
|
|
Add explanations of how to use the macros in fitz.h.
Also included are 2 different formulations, with different strengths/
weaknesses for reference. Will remove these shortly, but I want a
reference to them in git.
Workaround bug in Mac OS Lion gcc (clang works fine).
|
|
|
|
Fixes a bug where objects remained in the store and would
keep stable pointers to the freed xref, later on those
objects could lead to false positive hits.
|
|
Add missing newline and remove excessive arguments.
|
|
Fix 2 places where we were filling a stroked pattern rather than
stroking it.
Cope with being asked to run a NULL buffer.
If running a stream fails, warn and return what we have, rather than
giving up entirely. Should really set a return code for each render.
Only look at the Print flag bit for Print renders. Only look at the
View flag bit for view renders.
If we find an unexpected ) or > during object parsing, warn and continue
rather than giving up entirely.
If optional content groups are broken, render the rest of the page
anyway.
Previously indirect objects that point to another indirection would
cause a failure; now attempt to resolve these. We set an arbitrary
limit of 10 such redirections to avoid infinite loops.
|
|
Various fixes to avoid overflow problems, division by zeros, use
of uninitialised variables etc. All from/suggested by Zenikos patch.
|
|
When repairing, if we hit a problem after having found a root object
live with that root object rather than giving up completely.
Also fix a memory leak, and cope better with trailing crap.
Thanks to Zeniko for these.
|
|
We can't do them properly at the moment, so don't try to do them at
all - only makes stuff worse for now.
Thanks to Zeniko for this.
|
|
In error cases, ensure we free objects correctly. Thanks to Zeniko
for finding the problems (and many of the solutions!)
|
|
In various places in the code, we add markers (".seen") to
dictionaries as we traverse them to ensure that we don't
go into infinite loops.
Adding a dictionary entry is bad as it's a) an expensive
operation, b) a potentially destructive one, and c) produces another
possible point of failure (as mallocs can fail).
Instead, add a flag to each dict to allow them to be marked/unmarked
and use that instead.
Thanks to Zeniko for pointing out various places that could usefully
be protected against infinite recursion.
|
|
A new 'cookie' parameter is added to page rendering/interpretation
functions. Supply this as NULL to get existing behaviour.
If you supply a non-NULL cookie, then this is taken as a pointer to
a struct that can be used for simple, non-thread locked communication
between caller and library.
The entire struct should be memset to zero before entry, except for
specific flags (thus coping with future extensions to this struct).
The abort flag should be zero on entry. It will be checked periodically
by the library - if the caller sets it non-zero (via another thread)
then the current operation will be aborted. No guarantees are given as
to how often this will be checked, or how fast it will be responded to.
The progress_max field will be set to an integer (-1 for unknown)
representing the number of 'things' to do. The progress field will
count up from 0 to this number as time goes by. No guarantees are
made as to the accuracy of this information, but it should be
useful for offering some sort of progress bar etc. Note that
progress_max may increase during the job.
In general, callers should be careful to accept out of range or
invalid data in this structure as this is deliberately
accessed 'unlocked'.
|
|
When the page number is given by an int, rather than an indirect
reference number in a link destination, the page number is already
0 based. Remove the adjustment that I'd been incorrectly doing.
|
|
When reading an XYZ link destination, I was writing Z over X. While
fixing this, change to cryptic enums rather than unexplained magic
numbers.
When reading the outlines out of a pdf file, better to actually store
them in a linked list rather than just dropping them.
|
|
|
|
Move 'kind' into the fz_link_dest structure (as this makes more sense).
Put an fz_link_dest rather than just a page number into the outlines
structure.
Correct parsing of actions and dests from pdf outlines.
|
|
|
|
Move to a non-pdf specific type for links. PDF specific parsing is
done in pdf_annots.c as before, but the essential type (and handling
functions for that type) are in a new file fitz/base_link.c.
The new type is more expressive than before; specifically all the
possible PDF modes are expressable in it. Hopefully this should
allow XPS links to be represented too.
|
|
gcc 4.4.5 gives helpful warnings about variables that can become
unset due to setjmp/longjmp usage. Fix that here.
Thanks to Sebras.
|
|
A couple of bits of the code SEGV in the event that values are NULL.
Fixed here by converting a do...while to a while, and adding an extra
guard in the if.
Thanks to Gaetan Bisson for the report, and patch.
|
|
|
|
One of the previous memsqueezing fixes (specifically that in
close_dctd) appears to cause the Memento fork bases squeezing
process to stop.
This appears to be because old code would do a NULL dereference
causing a SEGV. This would somehow NOT be picked up by the signal
handler, and the child would exit.
If the code is fixed to avoid the SEGV the code then somehow
goes on to do something (not in the close_dctd code) that makes
the mem squeeze process grind to a halt - but NOT in the same
instance of the executable. I am at a loss to explain this, but
would rather the code stays as it is (being as far as I can see
correct) for now.
|
|
|
|
|
|
|
|
Rather than passing a stream to a close function, just pass context
and state - that's all that is required. This enables us to
call close to cleanup neatly if the stream fails to allocate.
|
|
|
|
|
|
|
|
|
|
|
|
The new fz_malloc_struct(A,B) macro allocates sizeof(B) bytes using
fz_malloc, and then passes the resultant pointer to Memento_label
to label it with "B".
This costs nothing in non-memento builds, but gives much nicer
listings of leaked blocks when memento is enabled.
|
|
|
|
|
|
|
|
Fixes for leaks (and SEGVs, division by zeros etc) seen when
Memsqueezing.
|
|
Fix warnings/errors thrown up by the last few commits (which were
only tested on windows).
|
|
The substitute fonts used in a fontdesc are held in ROM, and as such
should not count towards the size of a fontdesc. Simple fix; remove
the lines that adds that in.
|
|
|
|
Change the fz_store to be limited to 256 Megs. Remove the soft limit
for pixmaps; the store will automatically throw old resources away
to stay below the limit.
|
|
Firstly, we rename pdf_store to fz_store, reflecting the fact that
there are no pdf specific dependencies on it.
Next, we rework it so that all the objects that can be stored in
the store start with an fz_storable structure. This consists of
a reference count, and a function used to free the object when
the reference count reaches zero.
All the keep/drop functions are then reimplemented by calling
fz_keep_sharable/fz_drop_sharable. The 'drop' functions as supplied
by the callers are thus now 'free' functions, only called if
the reference count drops to 0.
The store changes to keep all the items in the store in the linked
list (which becomes a doubly linked one). We still make use of
the hashtable to index into this list quickly, but we now have
the objects in an LRU ordering within the list.
Every object is put into the store, with a size record; this is
an estimate of how much memory would be freed by freeing that
object.
The store is moved into the context and given a maximum size;
when new things are inserted into the store, care is taken to
ensure that we do not expand beyond this size. We evict any
stored items (that are not in use) starting from the least
recently used.
Finding an object in the store now takes a reference to it already.
LOCK and UNLOCK comments are used to indicate where locks need to
be taken and released to ensure thread safety.
|
|
|
|
When adding the exception handling in, I'd mis-indented some code.
This caused all the file to be read.
|
|
|
|
Also: use 'cannot' instead of 'failed to' in error messages.
|
|
|
|
|
|
|
|
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.
|