[gs-cvs] gs/src

Dan Coby dan at ghostscript.com
Fri Jul 8 15:04:33 PDT 2005


Update of /cvs/ghostscript/gs/src
In directory casper2:/tmp/cvs-serv18256/src

Modified Files:
	gsequivc.c gdevtsep.c gdevpsd.c gdevdevn.h gdevdevn.c devs.mak 
Log Message:
Fix for 688192 Resolution dependant problems with tiffsep.  Note:  The
actual problem is related to garbage collection.

DETAILS:

The names of the separations are being lost when the garbage collection
logic is attempting to relocate the names.

The fix consists of storing the names in a byte array instead of using a
gs_param_string.


Index: gsequivc.c
===================================================================
RCS file: /cvs/ghostscript/gs/src/gsequivc.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- gsequivc.c	4 Aug 2004 19:36:12 -0000	1.5
+++ gsequivc.c	8 Jul 2005 22:04:31 -0000	1.6
@@ -128,8 +128,8 @@
      */
     for (i = 0; i < pdevn_params->separations.num_separations; i++) {
 	if (pparams->color[i].color_info_valid == false) {
-	    const gs_param_string * dev_sep_name =
-			    pdevn_params->separations.names[i];
+	    const devn_separation_name * dev_sep_name =
+			    &(pdevn_params->separations.names[i]);
 	    unsigned int cs_sep_name_size;
 	    unsigned char * pcs_sep_name;
 
@@ -189,8 +189,8 @@
      */
     for (i = 0; i < pdevn_params->separations.num_separations; i++) {
 	if (pparams->color[i].color_info_valid == false) {
-	    const gs_param_string * dev_sep_name =
-			    pdevn_params->separations.names[i];
+	    const devn_separation_name * dev_sep_name =
+			    &(pdevn_params->separations.names[i]);
 
 	    for (j = 0; j < pcs->params.device_n.num_components; j++) {
 	        pcs->params.device_n.get_colorname_string

Index: gdevtsep.c
===================================================================
RCS file: /cvs/ghostscript/gs/src/gdevtsep.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- gdevtsep.c	20 Jun 2005 08:59:23 -0000	1.6
+++ gdevtsep.c	8 Jul 2005 22:04:31 -0000	1.7
@@ -260,7 +260,7 @@
 ENUM_PTRS_WITH(tiffsep_device_enum_ptrs, tiffsep_device *pdev)
 {
     if (index < pdev->devn_params.separations.num_separations)
-	ENUM_RETURN(pdev->devn_params.separations.names[index]);
+	ENUM_RETURN(pdev->devn_params.separations.names[index].data);
     ENUM_PREFIX(st_device_printer,
 		    pdev->devn_params.separations.num_separations);
 }
@@ -273,7 +273,7 @@
 	int i;
 
 	for (i = 0; i < pdev->devn_params.separations.num_separations; ++i) {
-	    RELOC_PTR(tiffsep_device, devn_params.separations.names[i]);
+	    RELOC_PTR(tiffsep_device, devn_params.separations.names[i].data);
 	}
     }
 }
@@ -571,12 +571,12 @@
 copy_separation_name(tiffsep_device * pdev,
 		char * buffer, int max_size, int sep_num)
 {
-    int sep_size = pdev->devn_params.separations.names[sep_num]->size;
+    int sep_size = pdev->devn_params.separations.names[sep_num].size;
 
     /* If name is too long then clip it. */
     if (sep_size > max_size - 1)
         sep_size = max_size - 1;
-    memcpy(buffer, pdev->devn_params.separations.names[sep_num]->data,
+    memcpy(buffer, pdev->devn_params.separations.names[sep_num].data,
 		sep_size);
     buffer[sep_size] = 0;	/* Terminate string */
 }
@@ -695,7 +695,7 @@
     tiffsep_device * const pdevn = (tiffsep_device *) pdev;
     int num_dev_comp = pdevn->color_info.num_components;
     int num_std_colorants = pdevn->devn_params.num_std_colorant_names;
-    int num_order = pdevn->devn_params.separation_order.num_names;
+    int num_order = pdevn->devn_params.num_separation_order_names;
     int num_spot = pdevn->devn_params.separations.num_separations;
     char name[MAX_FILE_NAME_SIZE];
     int code = gdev_prn_close(pdev);
@@ -828,7 +828,7 @@
 {
     tiffsep_device * const tfdev = (tiffsep_device *)pdev;
     int num_std_colorants = tfdev->devn_params.num_std_colorant_names;
-    int num_order = tfdev->devn_params.separation_order.num_names;
+    int num_order = tfdev->devn_params.num_separation_order_names;
     int num_spot = tfdev->devn_params.separations.num_separations;
     int num_comp, comp_num, sep_num, code = 0;
     short map_comp_to_sep[GX_DEVICE_COLOR_MAX_COMPONENTS];

Index: gdevpsd.c
===================================================================
RCS file: /cvs/ghostscript/gs/src/gdevpsd.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- gdevpsd.c	20 Jun 2005 08:59:23 -0000	1.19
+++ gdevpsd.c	8 Jul 2005 22:04:31 -0000	1.20
@@ -92,7 +92,7 @@
 ENUM_PTRS_WITH(psd_device_enum_ptrs, psd_device *pdev)
 {
     if (index < pdev->devn_params.separations.num_separations)
-	ENUM_RETURN(pdev->devn_params.separations.names[index]);
+	ENUM_RETURN(pdev->devn_params.separations.names[index].data);
     ENUM_PREFIX(st_device_printer,
 		    pdev->devn_params.separations.num_separations);
 }
@@ -105,7 +105,7 @@
 	int i;
 
 	for (i = 0; i < pdev->devn_params.separations.num_separations; ++i) {
-	    RELOC_PTR(psd_device, devn_params.separations.names[i]);
+	    RELOC_PTR(psd_device, devn_params.separations.names[i].data);
 	}
     }
 }
@@ -860,7 +860,7 @@
     int chan_idx;
     int chan_names_len = 0;
     int sep_num;
-    const gs_param_string *separation_name;
+    const devn_separation_name *separation_name;
 
     psd_write(xc, (const byte *)"8BPS", 4); /* Signature */
     psd_write_16(xc, 1); /* Version - Always equal to 1*/
@@ -881,7 +881,7 @@
     /* Channel Names */
     for (chan_idx = NUM_CMYK_COMPONENTS; chan_idx < xc->num_channels; chan_idx++) {
 	sep_num = xc->chnl_to_orig_sep[chan_idx] - NUM_CMYK_COMPONENTS;
-	separation_name = pdev->devn_params.separations.names[sep_num];
+	separation_name = &(pdev->devn_params.separations.names[sep_num]);
 	chan_names_len += (separation_name->size + 1);
     }    
     psd_write_32(xc, 12 + (chan_names_len + (chan_names_len % 2))
@@ -893,7 +893,7 @@
     psd_write_32(xc, chan_names_len + (chan_names_len % 2));
     for (chan_idx = NUM_CMYK_COMPONENTS; chan_idx < xc->num_channels; chan_idx++) {
 	sep_num = xc->chnl_to_orig_sep[chan_idx] - NUM_CMYK_COMPONENTS;
-	separation_name = pdev->devn_params.separations.names[sep_num];
+	separation_name = &(pdev->devn_params.separations.names[sep_num]);
 	psd_write_8(xc, (byte) separation_name->size);
 	psd_write(xc, separation_name->data, separation_name->size);
     }    

Index: gdevdevn.h
===================================================================
RCS file: /cvs/ghostscript/gs/src/gdevdevn.h,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- gdevdevn.h	1 Jul 2004 04:41:38 -0000	1.10
+++ gdevdevn.h	8 Jul 2005 22:04:31 -0000	1.11
@@ -43,19 +43,18 @@
 /*
  * Structure for holding SeparationNames elements.
  */
-typedef struct gs_separations_s {
-    int num_separations;
-    const gs_param_string * names[GX_DEVICE_MAX_SEPARATIONS];
-} gs_separations;
+typedef struct devn_separation_name_s {
+    int size;
+    byte * data;
+} devn_separation_name;
 
 /*
- * Structure for holding SeparationOrder elements.
+ * Structure for holding SeparationNames elements.
  */
-typedef struct gs_separation_order_s {
-    int num_names;
-    const gs_param_string  *
-	    names[GX_DEVICE_MAX_SEPARATIONS + MAX_DEVICE_PROCESS_COLORS];
-} gs_separation_order;
+typedef struct gs_separations_s {
+    int num_separations;
+    devn_separation_name names[GX_DEVICE_MAX_SEPARATIONS];
+} gs_separations;
 
 /*
  * Type for holding a separation order map
@@ -87,7 +86,7 @@
     /*
      * Separation Order (if specified).
      */
-    gs_separation_order separation_order;
+    int num_separation_order_names;
     /*
      * The SeparationOrder parameter may change the logical order of
      * components.

Index: gdevdevn.c
===================================================================
RCS file: /cvs/ghostscript/gs/src/gdevdevn.c,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -d -r1.23 -r1.24
--- gdevdevn.c	21 Sep 2004 22:30:35 -0000	1.23
+++ gdevdevn.c	8 Jul 2005 22:04:31 -0000	1.24
@@ -30,26 +30,6 @@
 #include "gdevdevn.h"
 #include "gsequivc.h"
 
-private
-ENUM_PTRS_WITH(param_string_enum_ptrs, gs_param_string *pstr) return 0;
-case 0: return ENUM_CONST_STRING(pstr);
-ENUM_PTRS_END
-
-private
-RELOC_PTRS_WITH(param_string_reloc_ptrs, gs_param_string *pstr)
-{
-    gs_const_string str;
-
-    str.data = pstr->data, str.size = pstr->size;
-    RELOC_CONST_STRING_VAR(str);
-    pstr->data = str.data;
-}
-RELOC_PTRS_END
-
-/* Define a GC descriptor for gs_param_string. */
-/* This structure descriptor is only for non persistent gs_param_strings. */
-private_st_gs_param_string();
-
 /*
  * Utility routines for common DeviceN related parameters:
  *   SeparationColorNames, SeparationOrder, and MaxSeparations
@@ -199,8 +179,8 @@
 	int num_spot = separations->num_separations;
 
 	for (i=0; i<num_spot; i++) {
-	    if (compare_color_names((const char *)separations->names[i]->data,
-		  separations->names[i]->size, pname, name_size)) {
+	    if (compare_color_names((const char *)separations->names[i].data,
+		  separations->names[i].size, pname, name_size)) {
 		return color_component_number;
 	    }
 	    color_component_number++;
@@ -236,7 +216,7 @@
 		    const char * pname, int name_size, int component_type,
 		    int auto_spot_colors)
 {
-    int num_order = pdevn_params->separation_order.num_names;
+    int num_order = pdevn_params->num_separation_order_names;
     int color_component_number = 0;
     int max_spot_colors = GX_DEVICE_MAX_SEPARATIONS;
 
@@ -274,7 +254,7 @@
      */
     if (component_type != SEPARATION_NAME ||
 	    auto_spot_colors == NO_AUTO_SPOT_COLORS ||
-	    pdevn_params->separation_order.num_names != 0)
+	    pdevn_params->num_separation_order_names != 0)
 	return -1;	/* Do not add --> indicate colorant unknown. */
     /*
      * Check if we have room for another spot colorant.
@@ -283,21 +263,16 @@
 	max_spot_colors = dev->color_info.num_components -
 	    pdevn_params->num_std_colorant_names;
     if (pdevn_params->separations.num_separations < max_spot_colors) {
-	gs_param_string * pstr_param;
-	byte * pseparation;
+	byte * sep_name;
 	gs_separations * separations = &pdevn_params->separations;
 	int sep_num = separations->num_separations++;
 
 	/* We have a new spot colorant */
-	pstr_param = gs_alloc_struct(dev->memory, gs_param_string,
-			&st_gs_param_string, "devn_get_color_comp_index");
-	pseparation = gs_alloc_string(dev->memory,
+	sep_name = gs_alloc_bytes(dev->memory,
 			name_size, "devn_get_color_comp_index");
-	memcpy(pseparation, pname, name_size);
-	pstr_param->data = pseparation;
-	pstr_param->size = name_size;
-	pstr_param->persistent = false;
-	separations->names[sep_num] = pstr_param;
+	memcpy(sep_name, pname, name_size);
+	separations->names[sep_num].size = name_size;
+	separations->names[sep_num].data = sep_name;
 	color_component_number = sep_num + pdevn_params->num_std_colorant_names;
 	pdevn_params->separation_order_map[color_component_number] =
 					       color_component_number;
@@ -372,7 +347,7 @@
     gs_param_name param_name;
     int npcmcolors = pdevn_params->num_std_colorant_names;
     int num_spot = pdevn_params->separations.num_separations;
-    int num_order = pdevn_params->separation_order.num_names;
+    int num_order = pdevn_params->num_separation_order_names;
     int max_sep = pdev->color_info.num_components;
     gs_param_string_array scna;		/* SeparationColorNames array */
     gs_param_string_array sona;		/* SeparationOrder names array */
@@ -410,21 +385,15 @@
 	    for (i = num_spot = 0; i < num_names; i++) {
 		/* Verify that the name is not one of our process colorants */
 	        if (!check_process_color_names(pcomp_names, &scna.data[i])) {
-		    gs_param_string * pstr_param;
-		    byte * pseparation;
+		    byte * sep_name;
 		    int name_size = scna.data[i].size;
 
 		    /* We have a new separation */
-		    pstr_param = (gs_param_string *)
-			gs_alloc_bytes(pdev->memory, sizeof(gs_param_string),
-			"devicen_put_params_no_sep_order");
-		    pseparation = (byte *)gs_alloc_bytes(pdev->memory,
+		    sep_name = (byte *)gs_alloc_bytes(pdev->memory,
 			name_size, "devicen_put_params_no_sep_order");
-		    memcpy(pseparation, scna.data[i].data, name_size);
-		    pstr_param->data = pseparation;
-		    pstr_param->size = name_size;
-		    pstr_param->persistent = false;
-	            pdevn_params->separations.names[num_spot] = pstr_param;
+		    memcpy(sep_name, scna.data[i].data, name_size);
+	            pdevn_params->separations.names[num_spot].size = name_size;
+	            pdevn_params->separations.names[num_spot].data = sep_name;
 		    if (pequiv_colors != NULL) {
 			/* Indicate that we need to find equivalent CMYK color. */
 			pequiv_colors->color[num_spot].color_info_valid = false;
@@ -443,11 +412,10 @@
         if (sona.data != 0) {
 	    int i, comp_num;
 
-	    pdevn_params->separation_order.num_names = num_order = sona.size;
+	    pdevn_params->num_separation_order_names = num_order = sona.size;
 	    for (i = 0; i < num_spot + npcmcolors; i++)
 		pdevn_params->separation_order_map[i] = GX_DEVICE_COLOR_MAX_COMPONENTS;
 	    for (i = 0; i < num_order; i++) {
-	        pdevn_params->separation_order.names[i] = &sona.data[i];
 	        /*
 	         * Check if names match either the process color model or
 	         * SeparationColorNames.  If not then error.
@@ -595,7 +563,7 @@
 ENUM_PTRS_WITH(spotcmyk_device_enum_ptrs, spotcmyk_device *pdev)
 {
     if (index < pdev->devn_params.separations.num_separations)
-	ENUM_RETURN(pdev->devn_params.separations.names[index]);
+	ENUM_RETURN(pdev->devn_params.separations.names[index].data);
     ENUM_PREFIX(st_device_printer,
 		    pdev->devn_params.separations.num_separations);
 }
@@ -608,7 +576,7 @@
 	int i;
 
 	for (i = 0; i < pdev->devn_params.separations.num_separations; ++i) {
-	    RELOC_PTR(spotcmyk_device, devn_params.separations.names[i]);
+	    RELOC_PTR(spotcmyk_device, devn_params.separations.names[i].data);
 	}
     }
 }

Index: devs.mak
===================================================================
RCS file: /cvs/ghostscript/gs/src/devs.mak,v
retrieving revision 1.131
retrieving revision 1.132
diff -u -d -r1.131 -r1.132
--- devs.mak	7 Jun 2005 18:33:56 -0000	1.131
+++ devs.mak	8 Jul 2005 22:04:31 -0000	1.132
@@ -392,7 +392,7 @@
 
 $(GLOBJ)gdevdsp.$(OBJ) : $(GLSRC)gdevdsp.c $(string__h)\
  $(gp_h) $(gpcheck_h) $(gdevpccm_h) $(gsparam_h) $(gsdevice_h)\
- $(GDEVH) $(gxdevmem_h) $(gdevdsp_h) $(gdevdsp2_h)
+ $(GDEVH) $(gxdevmem_h) $(gdevdevn_h) $(gsequivc_h) $(gdevdsp_h) $(gdevdsp2_h)
 	$(GLCC) $(GLO_)gdevdsp.$(OBJ) $(C_) $(GLSRC)gdevdsp.c
 
 



More information about the gs-cvs mailing list