[gs-cvs] rev 8760 - trunk/gs/src

ray at ghostscript.com ray at ghostscript.com
Tue May 20 23:46:41 PDT 2008


Author: ray
Date: 2008-05-20 23:46:41 -0700 (Tue, 20 May 2008)
New Revision: 8760

Modified:
   trunk/gs/src/gsmchunk.c
Log:
Ensure that the chunk wrapper is used on the non_gc allocator since doing GC
on chunks will be disastrous. This is protection only and causes no difference
since the only current client of the chunk wrapper is the multi-threaded clist
rendering which wraps non_gc_memory.


Modified: trunk/gs/src/gsmchunk.c
===================================================================
--- trunk/gs/src/gsmchunk.c	2008-05-21 06:40:14 UTC (rev 8759)
+++ trunk/gs/src/gsmchunk.c	2008-05-21 06:46:41 UTC (rev 8760)
@@ -11,7 +11,7 @@
    San Rafael, CA  94903, U.S.A., +1(415)492-9861, for further information.
 */
 
-/* $Id:$ */
+/* $Id$ */
 /* chunk consolidating wrapper on a base memory allocator */
 
 #include "memory_.h"
@@ -114,17 +114,21 @@
 gs_memory_chunk_wrap( gs_memory_t **wrapped,	/* chunk allocator init */
 		      gs_memory_t * target )	/* base allocator */
 {
-    gs_memory_chunk_t *cmem = (gs_memory_chunk_t *)
-        gs_alloc_bytes_immovable(target, sizeof(gs_memory_chunk_t),
-                                 "gs_malloc_wrap(chunk)");
+    /* Use the non-GC allocator of the target. The chunk allocator is NOT GC safe */
+    gs_memory_t *non_gc_target = target->non_gc_memory;
+    gs_memory_chunk_t *cmem = NULL;
+
     *wrapped = NULL;		/* don't leave garbage in case we fail */
+    if (non_gc_target) 
+	    cmem = (gs_memory_chunk_t *) gs_alloc_bytes_immovable(non_gc_target,
+			sizeof(gs_memory_chunk_t), "gs_malloc_wrap(chunk)");
     if (cmem == 0)
         return_error(gs_error_VMerror);
     cmem->stable_memory = (gs_memory_t *)cmem;	/* we are stable */
     cmem->procs = chunk_procs;
-    cmem->gs_lib_ctx = target->gs_lib_ctx;
+    cmem->gs_lib_ctx = non_gc_target->gs_lib_ctx;
     cmem->non_gc_memory = (gs_memory_t *)cmem;	/* and are not subject to GC */
-    cmem->target = target;
+    cmem->target = non_gc_target;
     cmem->head_chunk = NULL;
 #ifdef DEBUG
     cmem->sequence_counter = 0;



More information about the gs-cvs mailing list