summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKen Sharp <ken.sharp@artifex.com>2012-05-11 11:38:32 +0100
committerKen Sharp <ken.sharp@artifex.com>2012-05-11 11:38:32 +0100
commit08d715446bb97015d16e085aa8f8c4bd8f73c2cc (patch)
tree473510e147b7d20062d5bbf71e1f59cf451f803f
parent54ecaf86c6fa0c4a31fb17e0c21361cb134ec376 (diff)
pdfrite - memory cleanup, free Annotations
Annotations weren't being freed along with their enclosing Page structure Add some comments about what is stored where, and when it is released, in a few places
-rw-r--r--gs/base/gdevpdf.c13
-rw-r--r--gs/base/gdevpdtt.c3
2 files changed, 16 insertions, 0 deletions
diff --git a/gs/base/gdevpdf.c b/gs/base/gdevpdf.c
index aa5b2e0d8..0e45e8c99 100644
--- a/gs/base/gdevpdf.c
+++ b/gs/base/gdevpdf.c
@@ -1481,6 +1481,7 @@ pdf_close(gx_device * dev)
stream_puts(s, ">>\n");
pprintld1(s, "startxref\n%ld\n%%%%EOF\n", xref);
}
+
/* Require special handling for Fonts, ColorSpace and Pattern resources
* These are tracked in pdev->last_resource, and are complex structures which may
* contain other memory allocations. All other resource types can be simply dicarded
@@ -1697,21 +1698,30 @@ pdf_close(gx_device * dev)
cos_dict_objects_delete(pdev->local_named_objects);
COS_FREE(pdev->local_named_objects, "pdf_close(local_named_objects)");
pdev->local_named_objects = 0;
+
+ /* global resources include the Catalog object and apparently the Info dict */
cos_dict_objects_delete(pdev->global_named_objects);
COS_FREE(pdev->global_named_objects, "pdf_close(global_named_objects)");
pdev->global_named_objects = 0;
/* Wrap up. */
+ pdev->font_cache = 0;
+
{
int i;
for (i=0;i < pdev->next_page;i++) {
cos_release((cos_object_t *)pdev->pages[i].Page, "Free page dict");
+ if (pdev->pages[i].Annots) {
+ cos_release((cos_object_t *)pdev->pages[i].Annots, "Release Annots dict");
+ gs_free_object(mem, pdev->pages[i].Annots, "Free Annots dict");
+ }
gs_free_object(mem, pdev->pages[i].Page, "Free Page object");
}
}
gs_free_object(mem, pdev->pages, "pages");
pdev->pages = 0;
+
pdev->num_pages = 0;
gs_free_object(mem, pdev->sbstack, "Free sbstack");
@@ -1732,6 +1742,9 @@ pdf_close(gx_device * dev)
gs_free_object(mem, pdev->Namespace_stack, "Free Name space stack");
pdev->Namespace_stack = 0;
+ pdev->Catalog = 0;
+ pdev->Info = 0;
+
{
/* pdf_open_dcument could set up filters for entire document.
Removing them now. */
diff --git a/gs/base/gdevpdtt.c b/gs/base/gdevpdtt.c
index 93d04a889..517c95749 100644
--- a/gs/base/gdevpdtt.c
+++ b/gs/base/gdevpdtt.c
@@ -786,6 +786,9 @@ int
pdf_free_font_cache(gx_device_pdf *pdev)
{
/* fixme : release elements. */
+ /* Should not need to be fixed. The elements are released when the
+ * font is finalized by the garbage collector
+ */
pdev->font_cache = NULL;
return 0;
}