|
fetched from a font dictionary have to be dereferenced into a ref
since pointers change if the dictionary is resized (to add entries);
(ii) The glyph_cache used by gs_font_cid2 fonts needs to be in stable
memory since elements might be added after a 'save' and the list will
still be refereced by the font, so cannot be freed by 'restore';
(iii) The gs_glyph_cache__release was never being called so creating
a memory leak -- font notification (called by gs_font_finalize) is
now used to free the cache list; (iv) The gs_glyph_cache__release
did not work (probably was never tested since it was not being used).
DETAILS:
Using stable_memory means that the objects created need to be freed
properly, that's why the font_notify mechanism was used. This fixes
the problem reported by the bug and doesn't seem to have created
any other problems (regression test passed).
A 'memory' element was added to the gs_glyph_data_s structure so
that the 'bits' can be allocated using the desired memory (stable
memory in the case that we are using the cache). This was deemed
preferable to always using the pfont->memory->stable_memory since
changing to this might cause other problems. This did create a
fair number of changes since every place the get_outline was used,
the glyph_data structure needed to have the 'memory' element set.
We could have used 'NULL' to signal pfont->memory, but this might
have masked uninitialized memory issues that can be tracked with
tools such as valgrind.
The gs_glyph_cache__release was totally broken, and since it was
not previously used, fixing and testing it presents no risk of
other clients relying on broken behaviour.
The implementation of the cache is VERY RUDIMENTARY -- a linked
list of elements with a hard-coded number (32767) limit to the
size of the cache. The size is too small to be useful for Asian
fonts, but making it bigger will result in a lot of time spent
finding a 'miss' condition. At least the current logic has LRU
slot re-use behaviour (which should be retained). Fixing this,
and making the cache limit larger are left for a later change
(post 8.50 release).
EXPECTED DIFFERENCES:
None.
git-svn-id: http://svn.ghostscript.com/ghostscript/trunk@5502 a1074d23-0009-0410-80fe-cf8c14f379e6
|