summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKen Sharp <ken.sharp@artifex.com>2012-03-09 10:41:29 +0000
committerChris Liddell <chris.liddell@artifex.com>2012-03-15 11:54:24 +0000
commit14ef9817250b0e13bb863fe935af65b45c4e1751 (patch)
treeb83ab654864b9c89424f8f3aa51add021f036e5d
parent67efaad03594d7f4434a58aa3ae8c4370af63809 (diff)
colour handling - ensure ink names are maintained in the name table while in use
Bug #692884 "Empty Spotcolor Name in generated PDF" The ink name wasn't being marked as 'in use' by the colour space structure and so was being freed by a garbage collection, resulting in an empty name. Robin Watts supplied this patch which allows us to *much* more easily mark names as in use, and also kindly updated the colour handling as well. No differences expected.
-rw-r--r--gs/base/gscdevn.c9
-rw-r--r--gs/base/gscsepr.c1
-rw-r--r--gs/base/gslib.c2
-rw-r--r--gs/base/gsstruct.h8
-rw-r--r--gs/psi/igc.c20
-rw-r--r--pl/plplatf.c1
6 files changed, 39 insertions, 2 deletions
diff --git a/gs/base/gscdevn.c b/gs/base/gscdevn.c
index 35f0f5f81..69a5ee1db 100644
--- a/gs/base/gscdevn.c
+++ b/gs/base/gscdevn.c
@@ -74,7 +74,14 @@ const gs_color_space_type gs_color_space_type_DeviceN = {
/* GC procedures */
static
-ENUM_PTRS_BEGIN(cs_DeviceN_enum_ptrs) return 0;
+ENUM_PTRS_BEGIN(cs_DeviceN_enum_ptrs)
+{
+ gs_device_n_params *params = &((gs_color_space *)vptr)->params.device_n;
+ if (index-3 < params->num_components)
+ return ENUM_NAME_INDEX(params->names[index-3]);
+ else
+ return 0;
+}
ENUM_PTR(0, gs_color_space, params.device_n.names);
ENUM_PTR(1, gs_color_space, params.device_n.map);
ENUM_PTR(2, gs_color_space, params.device_n.colorants);
diff --git a/gs/base/gscsepr.c b/gs/base/gscsepr.c
index e521ea017..f377b225a 100644
--- a/gs/base/gscsepr.c
+++ b/gs/base/gscsepr.c
@@ -66,6 +66,7 @@ const gs_color_space_type gs_color_space_type_Separation = {
static
ENUM_PTRS_BEGIN(cs_Separation_enum_ptrs) return 0;
ENUM_PTR(0, gs_color_space, params.separation.map);
+ case 1 : return ENUM_NAME_INDEX_ELT(gs_color_space, params.separation.sep_name);
ENUM_PTRS_END
static RELOC_PTRS_BEGIN(cs_Separation_reloc_ptrs)
{
diff --git a/gs/base/gslib.c b/gs/base/gslib.c
index 5f2106b65..4a76692a4 100644
--- a/gs/base/gslib.c
+++ b/gs/base/gslib.c
@@ -265,6 +265,8 @@ void
gs_reloc_const_string(gs_const_string * sptr, gc_state_t * gcst)
{
}
+const gs_ptr_procs_t ptr_name_index_procs =
+{NULL, NULL, NULL};
/* Other stubs */
static void
diff --git a/gs/base/gsstruct.h b/gs/base/gsstruct.h
index bdfc3ff64..aa3f57da4 100644
--- a/gs/base/gsstruct.h
+++ b/gs/base/gsstruct.h
@@ -126,6 +126,10 @@ extern const gs_ptr_procs_t ptr_string_procs;
extern const gs_ptr_procs_t ptr_const_string_procs;
#define ptr_const_string_type (&ptr_const_string_procs)
+/* Define the pointer type for name indexes. */
+extern const gs_ptr_procs_t ptr_name_index_procs;
+#define ptr_name_index_type (&ptr_name_index_procs)
+
/*
* Define the type for a GC root.
*/
@@ -357,6 +361,8 @@ struct_proc_reloc_ptrs(basic_reloc_ptrs);
(pep->ptr = sdata, pep->size = ssize, ptr_const_string_type)
#define ENUM_CONST_STRING(sptr) /* pointer to gs_const_string */\
ENUM_CONST_STRING2((sptr)->data, (sptr)->size)
+#define ENUM_NAME_INDEX(name) /* name (as a long index) */\
+ (pep->size = (uint)name, ptr_name_index_type)
extern gs_ptr_type_t
enum_bytestring(enum_ptr_t *pep, const gs_bytestring *pbs);
#define ENUM_BYTESTRING(ptr) /* pointer to gs_bytestring */\
@@ -374,6 +380,8 @@ extern gs_ptr_type_t
(((const typ *)vptr)->elt.persistent ? 0 : ENUM_STRING(&((const typ *)vptr)->elt))
#define ENUM_CONST_STRING_ELT(typ, elt)\
ENUM_CONST_STRING(&((const typ *)vptr)->elt)
+#define ENUM_NAME_INDEX_ELT(typ, elt) /* name (as a long index) */\
+ (pep->size = (uint)(((const typ *)vptr)->elt), ptr_name_index_type)
#define ENUM_PTR(i, typ, elt)\
case i: return ENUM_OBJ_ELT(typ, elt)
diff --git a/gs/psi/igc.c b/gs/psi/igc.c
index 7a2c5c36d..00957d52c 100644
--- a/gs/psi/igc.c
+++ b/gs/psi/igc.c
@@ -82,6 +82,8 @@ static ptr_proc_unmark(ptr_struct_unmark);
static ptr_proc_mark(ptr_struct_mark);
static ptr_proc_unmark(ptr_string_unmark);
static ptr_proc_mark(ptr_string_mark);
+static ptr_proc_unmark(ptr_name_index_unmark);
+static ptr_proc_mark(ptr_name_index_mark);
/*ptr_proc_unmark(ptr_ref_unmark); *//* in igc.h */
/*ptr_proc_mark(ptr_ref_mark); *//* in igc.h */
static ptr_proc_reloc(igc_reloc_struct_ptr, void);
@@ -98,7 +100,7 @@ static const gc_procs_with_refs_t igc_procs = {
/* Pointer type descriptors. */
/* Note that the trace/mark routine has special knowledge of ptr_ref_type */
/* and ptr_struct_type -- it assumes that no other types have embedded */
-/* pointers. Note also that the reloc procedures for string and ref */
+/* pointers. Note also that the reloc procedures for string, ref and name */
/* pointers are never called. */
typedef ptr_proc_reloc((*ptr_proc_reloc_t), void);
const gs_ptr_procs_t ptr_struct_procs =
@@ -109,6 +111,8 @@ const gs_ptr_procs_t ptr_const_string_procs =
{ptr_string_unmark, ptr_string_mark, NULL};
const gs_ptr_procs_t ptr_ref_procs =
{ptr_ref_unmark, ptr_ref_mark, NULL};
+const gs_ptr_procs_t ptr_name_index_procs =
+{ptr_name_index_unmark, ptr_name_index_mark, NULL};
/* ------ Main program ------ */
@@ -584,6 +588,13 @@ ptr_string_unmark(enum_ptr_t *pep, gc_state_t * gcst)
discard(gc_string_mark(pep->ptr, pep->size, false, gcst));
}
+/* Unmark a single name. */
+static void
+ptr_name_index_unmark(enum_ptr_t *pep, gc_state_t * gcst)
+{
+ /* Do nothing */
+}
+
/* Unmark the objects in a chunk. */
static void
gc_objects_clear_marks(const gs_memory_t *mem, chunk_t * cp)
@@ -1081,6 +1092,13 @@ ptr_string_mark(enum_ptr_t *pep, gc_state_t * gcst)
return gc_string_mark(pep->ptr, pep->size, true, gcst);
}
+/* Mark a name. Return true if new mark. */
+static bool
+ptr_name_index_mark(enum_ptr_t *pep, gc_state_t * gcst)
+{
+ return names_mark_index(gcst->heap->gs_lib_ctx->gs_name_table, pep->size);
+}
+
/* Finish tracing by marking names. */
static bool
gc_trace_finish(gc_state_t * pstate)
diff --git a/pl/plplatf.c b/pl/plplatf.c
index 7fb8732be..1ba9dc2f5 100644
--- a/pl/plplatf.c
+++ b/pl/plplatf.c
@@ -60,6 +60,7 @@ void
gs_reloc_const_string(gs_const_string *sptr, gc_state_t *gcst)
{
}
+const gs_ptr_procs_t ptr_name_index_procs = { NULL, NULL, NULL };
/* Stub for abnormal termination */
void