summaryrefslogtreecommitdiff
path: root/base/gsmchunk.h
diff options
context:
space:
mode:
authorRobin Watts <robin.watts@artifex.com>2017-05-15 14:34:17 +0100
committerRobin Watts <robin.watts@artifex.com>2017-05-18 17:26:16 +0100
commit5501c28dbb1814aa869cb5132e52d5bcf090ec6e (patch)
tree686cb18b7b91729b4e0631f54ce568dd6564bfc1 /base/gsmchunk.h
parentb69d68995d065d61b2defe919c038cf9cf60b598 (diff)
downloadghostpdl-5501c28dbb1814aa869cb5132e52d5bcf090ec6e.tar.gz
New chunk memory manager.
Based off the original chunk heap managers code, this uses splay trees for free blocks to speed searching. (Dual, top-down, semi-splaying trees, one ordered on size, and another on location). Adding this memory manager runs into a problem with pdfwrite. Because pdfwrite is not entirely behaved with memory freeing, it can free the same blocks more than once. This primarily happens in pdf_close. The existing chunk memory manager seems to get away with this by luck, whereas this revised version sees SEGVs in some {pcl,xps} -> pdfwrite tests. Accordingly, we add a special fudge; if we call gs_defer_frees(1) then the memory manager defers freeing blocks by putting them onto a linked list (but only once). When we then call gs_defer_frees(0), the manager finalizes all the blocks on the list (which may in turn add new blocks to the list!). Once all the blocks have been finalized, they are then freed. "All" the pdfwrite double frees come from inside pdf_close (or all the ones I have seen at least). Accordingly we bracket pdf_close with gs_defer_frees(1) and gs_defer_frees(0).
Diffstat (limited to 'base/gsmchunk.h')
-rw-r--r--base/gsmchunk.h2
1 files changed, 0 insertions, 2 deletions
diff --git a/base/gsmchunk.h b/base/gsmchunk.h
index 3464b2e9a..5a9649df9 100644
--- a/base/gsmchunk.h
+++ b/base/gsmchunk.h
@@ -45,8 +45,6 @@ gs_memory_t *gs_memory_chunk_target(const gs_memory_t *cmem);
#ifdef DEBUG
void gs_memory_chunk_dump_memory(const gs_memory_t *mem);
-
- int chunk_allocator_unit_test(gs_memory_t *mem);
#endif /* DEBUG */
#endif /* gsmchunk_INCLUDED */