summaryrefslogtreecommitdiff
path: root/psi
diff options
context:
space:
mode:
authorIgor Melichev <igor.melichev@artifex.com>2006-10-17 14:03:12 +0000
committerIgor Melichev <igor.melichev@artifex.com>2006-10-17 14:03:12 +0000
commitf7fa709529ddca28d80da814d01237374538afc0 (patch)
tree11493b68c6fbfc59dd1faa9b228874bee3d1e5ae /psi
parent322afee14897d9820ac5d5b2e6fdeb1924c89a3d (diff)
Fix (psi, pl) : Provide a right finalization for the Postscript interpreter.
DETAILS : This patch requires gs revision 7111. 1. The implementation of ps_impl_get_device_memory was entirely wrong. First it casted from gs_dual_memory_t to gs_memory_t, which have no common superclasses. After that it took the 1st field from gs_dual_memory_t thinking that it is a stable memory. Occasionally it occured to be a gs_memory_t object, which actually is an instable local memory. The new code performs a right sequence of dereferensing with no type casts, and chooses the global stable memory. Besides that it adjusts the num_contexts counter for it against a premature releasing when alloc_restore_all is called from gsapi_exit. Please note that the otput device has been moved from local instable memory to global stable memory. It shouldn't be harmful for other interpreters. 2. Call gsapi_exit from ps_impl_deallocate_interp_instance to release resources. 3. Move the dereferencing of stable_memory from pl_top_create_device to ps_impl_get_device_memory so that the name pti->device_memory properly reflects the content. 4. Adjust the gs_id threshold for "Once a year reset the gs_next_id." in pl_main, because 65536 IDs may be insufficient for a single PS document (for example, print entire character set of 2 Unicode fonts). EXPECTED DIFFERENCES : None. git-svn-id: http://svn.ghostscript.com/ghostpcl/trunk/ghostpcl@2641 06663e23-700e-0410-b217-a244a6096597
Diffstat (limited to 'psi')
-rwxr-xr-xpsi/psitop.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/psi/psitop.c b/psi/psitop.c
index 2896848d1..48969b142 100755
--- a/psi/psitop.c
+++ b/psi/psitop.c
@@ -297,7 +297,12 @@ ps_impl_get_device_memory(
gs_memory_t **pmem)
{
ps_interp_instance_t *psi = (ps_interp_instance_t *)instance;
- *pmem = (gs_memory_t*)&psi->minst->i_ctx_p->memory;
+ gs_dual_memory_t *dmem = &psi->minst->i_ctx_p->memory;
+ gs_memory_t *mem = dmem->spaces.memories.named.global;
+
+ *pmem = mem->stable_memory;
+ /* Lock against alloc_restore_all to release the device when called from gsapi_exit : */
+ ((gs_ref_memory_t *)mem)->num_contexts++;
return 0;
}
@@ -519,6 +524,8 @@ ps_impl_deallocate_interp_instance(
/* do total dnit of interp state */
code = gsapi_run_string_end(mem->gs_lib_ctx, 0, &exit_code);
+ gsapi_exit(psi->minst);
+
gs_free_object(mem, psi, "ps_impl_deallocate_interp_instance(ps_interp_instance_t)");
return (code < 0) ? exit_code : 0;