Blame SOURCES/cups-memory-consumption.patch

3635cf
diff --git a/cups/ppd-cache.c b/cups/ppd-cache.c
3635cf
index 925ab80..e5f89ee 100644
3635cf
--- a/cups/ppd-cache.c
3635cf
+++ b/cups/ppd-cache.c
3635cf
@@ -508,24 +508,20 @@ _ppdCacheCreateWithFile(
3635cf
     else if (!_cups_strcasecmp(line, "Filter"))
3635cf
     {
3635cf
       if (!pc->filters)
3635cf
-        pc->filters = cupsArrayNew3(NULL, NULL, NULL, 0,
3635cf
-	                            (cups_acopy_func_t)_cupsStrAlloc,
3635cf
-				    (cups_afree_func_t)_cupsStrFree);
3635cf
+        pc->filters = cupsArrayNew3(NULL, NULL, NULL, 0, (cups_acopy_func_t)strdup, (cups_afree_func_t)free);
3635cf
 
3635cf
       cupsArrayAdd(pc->filters, value);
3635cf
     }
3635cf
     else if (!_cups_strcasecmp(line, "PreFilter"))
3635cf
     {
3635cf
       if (!pc->prefilters)
3635cf
-        pc->prefilters = cupsArrayNew3(NULL, NULL, NULL, 0,
3635cf
-	                               (cups_acopy_func_t)_cupsStrAlloc,
3635cf
-				       (cups_afree_func_t)_cupsStrFree);
3635cf
+        pc->prefilters = cupsArrayNew3(NULL, NULL, NULL, 0, (cups_acopy_func_t)strdup, (cups_afree_func_t)free);
3635cf
 
3635cf
       cupsArrayAdd(pc->prefilters, value);
3635cf
     }
3635cf
     else if (!_cups_strcasecmp(line, "Product"))
3635cf
     {
3635cf
-      pc->product = _cupsStrAlloc(value);
3635cf
+      pc->product = strdup(value);
3635cf
     }
3635cf
     else if (!_cups_strcasecmp(line, "SingleFile"))
3635cf
     {
3635cf
@@ -625,8 +621,8 @@ _ppdCacheCreateWithFile(
3635cf
       }
3635cf
 
3635cf
       map      = pc->bins + pc->num_bins;
3635cf
-      map->pwg = _cupsStrAlloc(pwg_keyword);
3635cf
-      map->ppd = _cupsStrAlloc(ppd_keyword);
3635cf
+      map->pwg = strdup(pwg_keyword);
3635cf
+      map->ppd = strdup(ppd_keyword);
3635cf
 
3635cf
       pc->num_bins ++;
3635cf
     }
3635cf
@@ -680,8 +676,8 @@ _ppdCacheCreateWithFile(
3635cf
 	goto create_error;
3635cf
       }
3635cf
 
3635cf
-      size->map.pwg = _cupsStrAlloc(pwg_keyword);
3635cf
-      size->map.ppd = _cupsStrAlloc(ppd_keyword);
3635cf
+      size->map.pwg = strdup(pwg_keyword);
3635cf
+      size->map.ppd = strdup(ppd_keyword);
3635cf
 
3635cf
       pc->num_sizes ++;
3635cf
     }
3635cf
@@ -709,15 +705,15 @@ _ppdCacheCreateWithFile(
3635cf
 
3635cf
       pwgFormatSizeName(pwg_keyword, sizeof(pwg_keyword), "custom", "max",
3635cf
 		        pc->custom_max_width, pc->custom_max_length, NULL);
3635cf
-      pc->custom_max_keyword = _cupsStrAlloc(pwg_keyword);
3635cf
+      pc->custom_max_keyword = strdup(pwg_keyword);
3635cf
 
3635cf
       pwgFormatSizeName(pwg_keyword, sizeof(pwg_keyword), "custom", "min",
3635cf
 		        pc->custom_min_width, pc->custom_min_length, NULL);
3635cf
-      pc->custom_min_keyword = _cupsStrAlloc(pwg_keyword);
3635cf
+      pc->custom_min_keyword = strdup(pwg_keyword);
3635cf
     }
3635cf
     else if (!_cups_strcasecmp(line, "SourceOption"))
3635cf
     {
3635cf
-      pc->source_option = _cupsStrAlloc(value);
3635cf
+      pc->source_option = strdup(value);
3635cf
     }
3635cf
     else if (!_cups_strcasecmp(line, "NumSources"))
3635cf
     {
3635cf
@@ -764,8 +760,8 @@ _ppdCacheCreateWithFile(
3635cf
       }
3635cf
 
3635cf
       map      = pc->sources + pc->num_sources;
3635cf
-      map->pwg = _cupsStrAlloc(pwg_keyword);
3635cf
-      map->ppd = _cupsStrAlloc(ppd_keyword);
3635cf
+      map->pwg = strdup(pwg_keyword);
3635cf
+      map->ppd = strdup(ppd_keyword);
3635cf
 
3635cf
       pc->num_sources ++;
3635cf
     }
3635cf
@@ -813,8 +809,8 @@ _ppdCacheCreateWithFile(
3635cf
       }
3635cf
 
3635cf
       map      = pc->types + pc->num_types;
3635cf
-      map->pwg = _cupsStrAlloc(pwg_keyword);
3635cf
-      map->ppd = _cupsStrAlloc(ppd_keyword);
3635cf
+      map->pwg = strdup(pwg_keyword);
3635cf
+      map->ppd = strdup(ppd_keyword);
3635cf
 
3635cf
       pc->num_types ++;
3635cf
     }
3635cf
@@ -844,13 +840,13 @@ _ppdCacheCreateWithFile(
3635cf
 	                   pc->presets[print_color_mode] + print_quality);
3635cf
     }
3635cf
     else if (!_cups_strcasecmp(line, "SidesOption"))
3635cf
-      pc->sides_option = _cupsStrAlloc(value);
3635cf
+      pc->sides_option = strdup(value);
3635cf
     else if (!_cups_strcasecmp(line, "Sides1Sided"))
3635cf
-      pc->sides_1sided = _cupsStrAlloc(value);
3635cf
+      pc->sides_1sided = strdup(value);
3635cf
     else if (!_cups_strcasecmp(line, "Sides2SidedLong"))
3635cf
-      pc->sides_2sided_long = _cupsStrAlloc(value);
3635cf
+      pc->sides_2sided_long = strdup(value);
3635cf
     else if (!_cups_strcasecmp(line, "Sides2SidedShort"))
3635cf
-      pc->sides_2sided_short = _cupsStrAlloc(value);
3635cf
+      pc->sides_2sided_short = strdup(value);
3635cf
     else if (!_cups_strcasecmp(line, "Finishings"))
3635cf
     {
3635cf
       if (!pc->finishings)
3635cf
@@ -871,13 +867,13 @@ _ppdCacheCreateWithFile(
3635cf
     else if (!_cups_strcasecmp(line, "MaxCopies"))
3635cf
       pc->max_copies = atoi(value);
3635cf
     else if (!_cups_strcasecmp(line, "ChargeInfoURI"))
3635cf
-      pc->charge_info_uri = _cupsStrAlloc(value);
3635cf
+      pc->charge_info_uri = strdup(value);
3635cf
     else if (!_cups_strcasecmp(line, "JobAccountId"))
3635cf
       pc->account_id = !_cups_strcasecmp(value, "true");
3635cf
     else if (!_cups_strcasecmp(line, "JobAccountingUserId"))
3635cf
       pc->accounting_user_id = !_cups_strcasecmp(value, "true");
3635cf
     else if (!_cups_strcasecmp(line, "JobPassword"))
3635cf
-      pc->password = _cupsStrAlloc(value);
3635cf
+      pc->password = strdup(value);
3635cf
     else if (!_cups_strcasecmp(line, "Mandatory"))
3635cf
     {
3635cf
       if (pc->mandatory)
3635cf
@@ -888,9 +884,7 @@ _ppdCacheCreateWithFile(
3635cf
     else if (!_cups_strcasecmp(line, "SupportFile"))
3635cf
     {
3635cf
       if (!pc->support_files)
3635cf
-        pc->support_files = cupsArrayNew3(NULL, NULL, NULL, 0,
3635cf
-                                          (cups_acopy_func_t)_cupsStrAlloc,
3635cf
-                                          (cups_afree_func_t)_cupsStrFree);
3635cf
+        pc->support_files = cupsArrayNew3(NULL, NULL, NULL, 0, (cups_acopy_func_t)strdup, (cups_afree_func_t)free);
3635cf
 
3635cf
       cupsArrayAdd(pc->support_files, value);
3635cf
     }
3635cf
@@ -1130,8 +1124,8 @@ _ppdCacheCreateWithPPD(ppd_file_t *ppd)	/* I - PPD file */
3635cf
 	  */
3635cf
 
3635cf
 	  new_size = old_size;
3635cf
-	  _cupsStrFree(old_size->map.ppd);
3635cf
-	  _cupsStrFree(old_size->map.pwg);
3635cf
+	  free(old_size->map.ppd);
3635cf
+	  free(old_size->map.pwg);
3635cf
 	}
3635cf
       }
3635cf
 
3635cf
@@ -1152,8 +1146,8 @@ _ppdCacheCreateWithPPD(ppd_file_t *ppd)	/* I - PPD file */
3635cf
 	* Save this size...
3635cf
 	*/
3635cf
 
3635cf
-	new_size->map.ppd = _cupsStrAlloc(ppd_size->name);
3635cf
-	new_size->map.pwg = _cupsStrAlloc(pwg_name);
3635cf
+	new_size->map.ppd = strdup(ppd_size->name);
3635cf
+	new_size->map.pwg = strdup(pwg_name);
3635cf
 	new_size->width   = new_width;
3635cf
 	new_size->length  = new_length;
3635cf
 	new_size->left    = new_left;
3635cf
@@ -1173,14 +1167,14 @@ _ppdCacheCreateWithPPD(ppd_file_t *ppd)	/* I - PPD file */
3635cf
     pwgFormatSizeName(pwg_keyword, sizeof(pwg_keyword), "custom", "max",
3635cf
 		      PWG_FROM_POINTS(ppd->custom_max[0]),
3635cf
 		      PWG_FROM_POINTS(ppd->custom_max[1]), NULL);
3635cf
-    pc->custom_max_keyword = _cupsStrAlloc(pwg_keyword);
3635cf
+    pc->custom_max_keyword = strdup(pwg_keyword);
3635cf
     pc->custom_max_width   = PWG_FROM_POINTS(ppd->custom_max[0]);
3635cf
     pc->custom_max_length  = PWG_FROM_POINTS(ppd->custom_max[1]);
3635cf
 
3635cf
     pwgFormatSizeName(pwg_keyword, sizeof(pwg_keyword), "custom", "min",
3635cf
 		      PWG_FROM_POINTS(ppd->custom_min[0]),
3635cf
 		      PWG_FROM_POINTS(ppd->custom_min[1]), NULL);
3635cf
-    pc->custom_min_keyword = _cupsStrAlloc(pwg_keyword);
3635cf
+    pc->custom_min_keyword = strdup(pwg_keyword);
3635cf
     pc->custom_min_width   = PWG_FROM_POINTS(ppd->custom_min[0]);
3635cf
     pc->custom_min_length  = PWG_FROM_POINTS(ppd->custom_min[1]);
3635cf
 
3635cf
@@ -1199,7 +1193,7 @@ _ppdCacheCreateWithPPD(ppd_file_t *ppd)	/* I - PPD file */
3635cf
 
3635cf
   if (input_slot)
3635cf
   {
3635cf
-    pc->source_option = _cupsStrAlloc(input_slot->keyword);
3635cf
+    pc->source_option = strdup(input_slot->keyword);
3635cf
 
3635cf
     if ((pc->sources = calloc((size_t)input_slot->num_choices, sizeof(pwg_map_t))) == NULL)
3635cf
     {
3635cf
@@ -1251,8 +1245,8 @@ _ppdCacheCreateWithPPD(ppd_file_t *ppd)	/* I - PPD file */
3635cf
 	                  "_");
3635cf
       }
3635cf
 
3635cf
-      map->pwg = _cupsStrAlloc(pwg_name);
3635cf
-      map->ppd = _cupsStrAlloc(choice->choice);
3635cf
+      map->pwg = strdup(pwg_name);
3635cf
+      map->ppd = strdup(choice->choice);
3635cf
     }
3635cf
   }
3635cf
 
3635cf
@@ -1315,8 +1309,8 @@ _ppdCacheCreateWithPPD(ppd_file_t *ppd)	/* I - PPD file */
3635cf
 	                  "_");
3635cf
       }
3635cf
 
3635cf
-      map->pwg = _cupsStrAlloc(pwg_name);
3635cf
-      map->ppd = _cupsStrAlloc(choice->choice);
3635cf
+      map->pwg = strdup(pwg_name);
3635cf
+      map->ppd = strdup(choice->choice);
3635cf
     }
3635cf
   }
3635cf
 
3635cf
@@ -1342,8 +1336,8 @@ _ppdCacheCreateWithPPD(ppd_file_t *ppd)	/* I - PPD file */
3635cf
     {
3635cf
       pwg_unppdize_name(choice->choice, pwg_keyword, sizeof(pwg_keyword), "_");
3635cf
 
3635cf
-      map->pwg = _cupsStrAlloc(pwg_keyword);
3635cf
-      map->ppd = _cupsStrAlloc(choice->choice);
3635cf
+      map->pwg = strdup(pwg_keyword);
3635cf
+      map->ppd = strdup(choice->choice);
3635cf
     }
3635cf
   }
3635cf
 
3635cf
@@ -1558,7 +1552,7 @@ _ppdCacheCreateWithPPD(ppd_file_t *ppd)	/* I - PPD file */
3635cf
 
3635cf
   if (duplex)
3635cf
   {
3635cf
-    pc->sides_option = _cupsStrAlloc(duplex->keyword);
3635cf
+    pc->sides_option = strdup(duplex->keyword);
3635cf
 
3635cf
     for (i = duplex->num_choices, choice = duplex->choices;
3635cf
          i > 0;
3635cf
@@ -1566,16 +1560,16 @@ _ppdCacheCreateWithPPD(ppd_file_t *ppd)	/* I - PPD file */
3635cf
     {
3635cf
       if ((!_cups_strcasecmp(choice->choice, "None") ||
3635cf
 	   !_cups_strcasecmp(choice->choice, "False")) && !pc->sides_1sided)
3635cf
-        pc->sides_1sided = _cupsStrAlloc(choice->choice);
3635cf
+        pc->sides_1sided = strdup(choice->choice);
3635cf
       else if ((!_cups_strcasecmp(choice->choice, "DuplexNoTumble") ||
3635cf
 	        !_cups_strcasecmp(choice->choice, "LongEdge") ||
3635cf
 	        !_cups_strcasecmp(choice->choice, "Top")) && !pc->sides_2sided_long)
3635cf
-        pc->sides_2sided_long = _cupsStrAlloc(choice->choice);
3635cf
+        pc->sides_2sided_long = strdup(choice->choice);
3635cf
       else if ((!_cups_strcasecmp(choice->choice, "DuplexTumble") ||
3635cf
 	        !_cups_strcasecmp(choice->choice, "ShortEdge") ||
3635cf
 	        !_cups_strcasecmp(choice->choice, "Bottom")) &&
3635cf
 	       !pc->sides_2sided_short)
3635cf
-        pc->sides_2sided_short = _cupsStrAlloc(choice->choice);
3635cf
+        pc->sides_2sided_short = strdup(choice->choice);
3635cf
     }
3635cf
   }
3635cf
 
3635cf
@@ -1583,9 +1577,7 @@ _ppdCacheCreateWithPPD(ppd_file_t *ppd)	/* I - PPD file */
3635cf
   * Copy filters and pre-filters...
3635cf
   */
3635cf
 
3635cf
-  pc->filters = cupsArrayNew3(NULL, NULL, NULL, 0,
3635cf
-			      (cups_acopy_func_t)_cupsStrAlloc,
3635cf
-			      (cups_afree_func_t)_cupsStrFree);
3635cf
+  pc->filters = cupsArrayNew3(NULL, NULL, NULL, 0, (cups_acopy_func_t)strdup, (cups_afree_func_t)free);
3635cf
 
3635cf
   cupsArrayAdd(pc->filters,
3635cf
                "application/vnd.cups-raw application/octet-stream 0 -");
3635cf
@@ -1642,9 +1634,7 @@ _ppdCacheCreateWithPPD(ppd_file_t *ppd)	/* I - PPD file */
3635cf
 
3635cf
   if ((ppd_attr = ppdFindAttr(ppd, "cupsPreFilter", NULL)) != NULL)
3635cf
   {
3635cf
-    pc->prefilters = cupsArrayNew3(NULL, NULL, NULL, 0,
3635cf
-				   (cups_acopy_func_t)_cupsStrAlloc,
3635cf
-				   (cups_afree_func_t)_cupsStrFree);
3635cf
+    pc->prefilters = cupsArrayNew3(NULL, NULL, NULL, 0, (cups_acopy_func_t)strdup, (cups_afree_func_t)free);
3635cf
 
3635cf
     do
3635cf
     {
3635cf
@@ -1661,7 +1651,7 @@ _ppdCacheCreateWithPPD(ppd_file_t *ppd)	/* I - PPD file */
3635cf
   */
3635cf
 
3635cf
   if (ppd->product)
3635cf
-    pc->product = _cupsStrAlloc(ppd->product);
3635cf
+    pc->product = strdup(ppd->product);
3635cf
 
3635cf
  /*
3635cf
   * Copy finishings mapping data...
3635cf
@@ -1818,7 +1808,7 @@ _ppdCacheCreateWithPPD(ppd_file_t *ppd)	/* I - PPD file */
3635cf
   */
3635cf
 
3635cf
   if ((ppd_attr = ppdFindAttr(ppd, "cupsChargeInfoURI", NULL)) != NULL)
3635cf
-    pc->charge_info_uri = _cupsStrAlloc(ppd_attr->value);
3635cf
+    pc->charge_info_uri = strdup(ppd_attr->value);
3635cf
 
3635cf
   if ((ppd_attr = ppdFindAttr(ppd, "cupsJobAccountId", NULL)) != NULL)
3635cf
     pc->account_id = !_cups_strcasecmp(ppd_attr->value, "true");
3635cf
@@ -1827,7 +1817,7 @@ _ppdCacheCreateWithPPD(ppd_file_t *ppd)	/* I - PPD file */
3635cf
     pc->accounting_user_id = !_cups_strcasecmp(ppd_attr->value, "true");
3635cf
 
3635cf
   if ((ppd_attr = ppdFindAttr(ppd, "cupsJobPassword", NULL)) != NULL)
3635cf
-    pc->password = _cupsStrAlloc(ppd_attr->value);
3635cf
+    pc->password = strdup(ppd_attr->value);
3635cf
 
3635cf
   if ((ppd_attr = ppdFindAttr(ppd, "cupsMandatory", NULL)) != NULL)
3635cf
     pc->mandatory = _cupsArrayNewStrings(ppd_attr->value, ' ');
3635cf
@@ -1836,9 +1826,7 @@ _ppdCacheCreateWithPPD(ppd_file_t *ppd)	/* I - PPD file */
3635cf
   * Support files...
3635cf
   */
3635cf
 
3635cf
-  pc->support_files = cupsArrayNew3(NULL, NULL, NULL, 0,
3635cf
-				    (cups_acopy_func_t)_cupsStrAlloc,
3635cf
-				    (cups_afree_func_t)_cupsStrFree);
3635cf
+  pc->support_files = cupsArrayNew3(NULL, NULL, NULL, 0, (cups_acopy_func_t)strdup, (cups_afree_func_t)free);
3635cf
 
3635cf
   for (ppd_attr = ppdFindAttr(ppd, "cupsICCProfile", NULL);
3635cf
        ppd_attr;
3635cf
@@ -1894,8 +1882,8 @@ _ppdCacheDestroy(_ppd_cache_t *pc)	/* I - PPD cache and mapping data */
3635cf
   {
3635cf
     for (i = pc->num_bins, map = pc->bins; i > 0; i --, map ++)
3635cf
     {
3635cf
-      _cupsStrFree(map->pwg);
3635cf
-      _cupsStrFree(map->ppd);
3635cf
+      free(map->pwg);
3635cf
+      free(map->ppd);
3635cf
     }
3635cf
 
3635cf
     free(pc->bins);
3635cf
@@ -1905,15 +1893,14 @@ _ppdCacheDestroy(_ppd_cache_t *pc)	/* I - PPD cache and mapping data */
3635cf
   {
3635cf
     for (i = pc->num_sizes, size = pc->sizes; i > 0; i --, size ++)
3635cf
     {
3635cf
-      _cupsStrFree(size->map.pwg);
3635cf
-      _cupsStrFree(size->map.ppd);
3635cf
+      free(size->map.pwg);
3635cf
+      free(size->map.ppd);
3635cf
     }
3635cf
 
3635cf
     free(pc->sizes);
3635cf
   }
3635cf
 
3635cf
-  if (pc->source_option)
3635cf
-    _cupsStrFree(pc->source_option);
3635cf
+  free(pc->source_option);
3635cf
 
3635cf
   if (pc->sources)
3635cf
   {
3635cf
@@ -1930,26 +1917,23 @@ _ppdCacheDestroy(_ppd_cache_t *pc)	/* I - PPD cache and mapping data */
3635cf
   {
3635cf
     for (i = pc->num_types, map = pc->types; i > 0; i --, map ++)
3635cf
     {
3635cf
-      _cupsStrFree(map->pwg);
3635cf
-      _cupsStrFree(map->ppd);
3635cf
+      free(map->pwg);
3635cf
+      free(map->ppd);
3635cf
     }
3635cf
 
3635cf
     free(pc->types);
3635cf
   }
3635cf
 
3635cf
-  if (pc->custom_max_keyword)
3635cf
-    _cupsStrFree(pc->custom_max_keyword);
3635cf
-
3635cf
-  if (pc->custom_min_keyword)
3635cf
-    _cupsStrFree(pc->custom_min_keyword);
3635cf
+  free(pc->custom_max_keyword);
3635cf
+  free(pc->custom_min_keyword);
3635cf
 
3635cf
-  _cupsStrFree(pc->product);
3635cf
+  free(pc->product);
3635cf
   cupsArrayDelete(pc->filters);
3635cf
   cupsArrayDelete(pc->prefilters);
3635cf
   cupsArrayDelete(pc->finishings);
3635cf
 
3635cf
-  _cupsStrFree(pc->charge_info_uri);
3635cf
-  _cupsStrFree(pc->password);
3635cf
+  free(pc->charge_info_uri);
3635cf
+  free(pc->password);
3635cf
 
3635cf
   cupsArrayDelete(pc->mandatory);
3635cf
 
3635cf
diff --git a/cups/ppd-mark.c b/cups/ppd-mark.c
3635cf
index 464c09a..cb67468 100644
3635cf
--- a/cups/ppd-mark.c
3635cf
+++ b/cups/ppd-mark.c
3635cf
@@ -890,9 +890,9 @@ ppd_mark_option(ppd_file_t *ppd,	/* I - PPD file */
3635cf
 	  case PPD_CUSTOM_PASSWORD :
3635cf
 	  case PPD_CUSTOM_STRING :
3635cf
 	      if (cparam->current.custom_string)
3635cf
-	        _cupsStrFree(cparam->current.custom_string);
3635cf
+	        free(cparam->current.custom_string);
3635cf
 
3635cf
-	      cparam->current.custom_string = _cupsStrAlloc(choice + 7);
3635cf
+	      cparam->current.custom_string = strdup(choice + 7);
3635cf
 	      break;
3635cf
 	}
3635cf
       }
3635cf
@@ -967,9 +967,9 @@ ppd_mark_option(ppd_file_t *ppd,	/* I - PPD file */
3635cf
 	  case PPD_CUSTOM_PASSWORD :
3635cf
 	  case PPD_CUSTOM_STRING :
3635cf
 	      if (cparam->current.custom_string)
3635cf
-		_cupsStrFree(cparam->current.custom_string);
3635cf
+		free(cparam->current.custom_string);
3635cf
 
3635cf
-	      cparam->current.custom_string = _cupsStrRetain(val->value);
3635cf
+	      cparam->current.custom_string = strdup(val->value);
3635cf
 	      break;
3635cf
 	}
3635cf
       }
3635cf
diff --git a/cups/ppd.c b/cups/ppd.c
3635cf
index 8276988..db849ac 100644
3635cf
--- a/cups/ppd.c
3635cf
+++ b/cups/ppd.c
3635cf
@@ -34,8 +34,6 @@
3635cf
  * Definitions...
3635cf
  */
3635cf
 
3635cf
-#define ppd_free(p)	if (p) free(p)	/* Safe free macro */
3635cf
-
3635cf
 #define PPD_KEYWORD	1		/* Line contained a keyword */
3635cf
 #define PPD_OPTION	2		/* Line contained an option name */
3635cf
 #define PPD_TEXT	4		/* Line contained human-readable text */
3635cf
@@ -117,7 +115,6 @@ void
3635cf
 ppdClose(ppd_file_t *ppd)		/* I - PPD file record */
3635cf
 {
3635cf
   int			i;		/* Looping var */
3635cf
-  ppd_emul_t		*emul;		/* Current emulation */
3635cf
   ppd_group_t		*group;		/* Current group */
3635cf
   char			**font;		/* Current font */
3635cf
   ppd_attr_t		**attr;		/* Current attribute */
3635cf
@@ -136,28 +133,12 @@ ppdClose(ppd_file_t *ppd)		/* I - PPD file record */
3635cf
   * Free all strings at the top level...
3635cf
   */
3635cf
 
3635cf
-  _cupsStrFree(ppd->lang_encoding);
3635cf
-  _cupsStrFree(ppd->nickname);
3635cf
-  if (ppd->patches)
3635cf
-    free(ppd->patches);
3635cf
-  _cupsStrFree(ppd->jcl_begin);
3635cf
-  _cupsStrFree(ppd->jcl_end);
3635cf
-  _cupsStrFree(ppd->jcl_ps);
3635cf
-
3635cf
- /*
3635cf
-  * Free any emulations...
3635cf
-  */
3635cf
-
3635cf
-  if (ppd->num_emulations > 0)
3635cf
-  {
3635cf
-    for (i = ppd->num_emulations, emul = ppd->emulations; i > 0; i --, emul ++)
3635cf
-    {
3635cf
-      _cupsStrFree(emul->start);
3635cf
-      _cupsStrFree(emul->stop);
3635cf
-    }
3635cf
-
3635cf
-    ppd_free(ppd->emulations);
3635cf
-  }
3635cf
+  free(ppd->lang_encoding);
3635cf
+  free(ppd->nickname);
3635cf
+  free(ppd->patches);
3635cf
+  free(ppd->jcl_begin);
3635cf
+  free(ppd->jcl_end);
3635cf
+  free(ppd->jcl_ps);
3635cf
 
3635cf
  /*
3635cf
   * Free any UI groups, subgroups, and options...
3635cf
@@ -168,7 +149,7 @@ ppdClose(ppd_file_t *ppd)		/* I - PPD file record */
3635cf
     for (i = ppd->num_groups, group = ppd->groups; i > 0; i --, group ++)
3635cf
       ppd_free_group(group);
3635cf
 
3635cf
-    ppd_free(ppd->groups);
3635cf
+    free(ppd->groups);
3635cf
   }
3635cf
 
3635cf
   cupsArrayDelete(ppd->options);
3635cf
@@ -179,14 +160,14 @@ ppdClose(ppd_file_t *ppd)		/* I - PPD file record */
3635cf
   */
3635cf
 
3635cf
   if (ppd->num_sizes > 0)
3635cf
-    ppd_free(ppd->sizes);
3635cf
+    free(ppd->sizes);
3635cf
 
3635cf
  /*
3635cf
   * Free any constraints...
3635cf
   */
3635cf
 
3635cf
   if (ppd->num_consts > 0)
3635cf
-    ppd_free(ppd->consts);
3635cf
+    free(ppd->consts);
3635cf
 
3635cf
  /*
3635cf
   * Free any filters...
3635cf
@@ -201,9 +182,9 @@ ppdClose(ppd_file_t *ppd)		/* I - PPD file record */
3635cf
   if (ppd->num_fonts > 0)
3635cf
   {
3635cf
     for (i = ppd->num_fonts, font = ppd->fonts; i > 0; i --, font ++)
3635cf
-      _cupsStrFree(*font);
3635cf
+      free(*font);
3635cf
 
3635cf
-    ppd_free(ppd->fonts);
3635cf
+    free(ppd->fonts);
3635cf
   }
3635cf
 
3635cf
  /*
3635cf
@@ -211,7 +192,7 @@ ppdClose(ppd_file_t *ppd)		/* I - PPD file record */
3635cf
   */
3635cf
 
3635cf
   if (ppd->num_profiles > 0)
3635cf
-    ppd_free(ppd->profiles);
3635cf
+    free(ppd->profiles);
3635cf
 
3635cf
  /*
3635cf
   * Free any attributes...
3635cf
@@ -221,11 +202,11 @@ ppdClose(ppd_file_t *ppd)		/* I - PPD file record */
3635cf
   {
3635cf
     for (i = ppd->num_attrs, attr = ppd->attrs; i > 0; i --, attr ++)
3635cf
     {
3635cf
-      _cupsStrFree((*attr)->value);
3635cf
-      ppd_free(*attr);
3635cf
+      free((*attr)->value);
3635cf
+      free(*attr);
3635cf
     }
3635cf
 
3635cf
-    ppd_free(ppd->attrs);
3635cf
+    free(ppd->attrs);
3635cf
   }
3635cf
 
3635cf
   cupsArrayDelete(ppd->sorted_attrs);
3635cf
@@ -247,7 +228,7 @@ ppdClose(ppd_file_t *ppd)		/* I - PPD file record */
3635cf
         case PPD_CUSTOM_PASSCODE :
3635cf
         case PPD_CUSTOM_PASSWORD :
3635cf
         case PPD_CUSTOM_STRING :
3635cf
-            _cupsStrFree(cparam->current.custom_string);
3635cf
+            free(cparam->current.custom_string);
3635cf
 	    break;
3635cf
 
3635cf
 	default :
3635cf
@@ -295,7 +276,7 @@ ppdClose(ppd_file_t *ppd)		/* I - PPD file record */
3635cf
   * Free the whole record...
3635cf
   */
3635cf
 
3635cf
-  ppd_free(ppd);
3635cf
+  free(ppd);
3635cf
 }
3635cf
 
3635cf
 
3635cf
@@ -441,7 +422,6 @@ _ppdOpen(
3635cf
     _ppd_localization_t	localization)	/* I - Localization to load */
3635cf
 {
3635cf
   int			i, j, k;	/* Looping vars */
3635cf
-  int			count;		/* Temporary count */
3635cf
   _ppd_line_t		line;		/* Line buffer */
3635cf
   ppd_file_t		*ppd;		/* PPD file record */
3635cf
   ppd_group_t		*group,		/* Current group */
3635cf
@@ -459,7 +439,6 @@ _ppdOpen(
3635cf
 					/* Human-readable text from file */
3635cf
 			*string,	/* Code/text from file */
3635cf
 			*sptr,		/* Pointer into string */
3635cf
-			*nameptr,	/* Pointer into name */
3635cf
 			*temp,		/* Temporary string pointer */
3635cf
 			**tempfonts;	/* Temporary fonts pointer */
3635cf
   float			order;		/* Order dependency number */
3635cf
@@ -633,16 +612,14 @@ _ppdOpen(
3635cf
     if (pg->ppd_status == PPD_OK)
3635cf
       pg->ppd_status = PPD_MISSING_PPDADOBE4;
3635cf
 
3635cf
-    _cupsStrFree(string);
3635cf
-    ppd_free(line.buffer);
3635cf
+    free(string);
3635cf
+    free(line.buffer);
3635cf
 
3635cf
     return (NULL);
3635cf
   }
3635cf
 
3635cf
   DEBUG_printf(("2_ppdOpen: keyword=%s, string=%p", keyword, string));
3635cf
 
3635cf
-  _cupsStrFree(string);
3635cf
-
3635cf
  /*
3635cf
   * Allocate memory for the PPD file record...
3635cf
   */
3635cf
@@ -651,8 +628,8 @@ _ppdOpen(
3635cf
   {
3635cf
     pg->ppd_status = PPD_ALLOC_ERROR;
3635cf
 
3635cf
-    _cupsStrFree(string);
3635cf
-    ppd_free(line.buffer);
3635cf
+    free(string);
3635cf
+    free(line.buffer);
3635cf
 
3635cf
     return (NULL);
3635cf
   }
3635cf
@@ -735,6 +712,8 @@ _ppdOpen(
3635cf
 	   strncmp(ll, keyword, ll_len)))
3635cf
       {
3635cf
 	DEBUG_printf(("2_ppdOpen: Ignoring localization: \"%s\"\n", keyword));
3635cf
+	free(string);
3635cf
+	string = NULL;
3635cf
 	continue;
3635cf
       }
3635cf
       else if (localization == _PPD_LOCALIZATION_ICC_PROFILES)
3635cf
@@ -754,6 +733,8 @@ _ppdOpen(
3635cf
 	if (i >= (int)(sizeof(color_keywords) / sizeof(color_keywords[0])))
3635cf
 	{
3635cf
 	  DEBUG_printf(("2_ppdOpen: Ignoring localization: \"%s\"\n", keyword));
3635cf
+	  free(string);
3635cf
+	  string = NULL;
3635cf
 	  continue;
3635cf
 	}
3635cf
       }
3635cf
@@ -849,7 +830,7 @@ _ppdOpen(
3635cf
       * Say all PPD files are UTF-8, since we convert to UTF-8...
3635cf
       */
3635cf
 
3635cf
-      ppd->lang_encoding = _cupsStrAlloc("UTF-8");
3635cf
+      ppd->lang_encoding = strdup("UTF-8");
3635cf
       encoding           = _ppdGetEncoding(string);
3635cf
     }
3635cf
     else if (!strcmp(keyword, "LanguageVersion"))
3635cf
@@ -870,10 +851,10 @@ _ppdOpen(
3635cf
 
3635cf
 
3635cf
         cupsCharsetToUTF8(utf8, string, sizeof(utf8), encoding);
3635cf
-	ppd->nickname = _cupsStrAlloc((char *)utf8);
3635cf
+	ppd->nickname = strdup((char *)utf8);
3635cf
       }
3635cf
       else
3635cf
-        ppd->nickname = _cupsStrAlloc(string);
3635cf
+        ppd->nickname = strdup(string);
3635cf
     }
3635cf
     else if (!strcmp(keyword, "Product"))
3635cf
       ppd->product = string;
3635cf
@@ -883,17 +864,17 @@ _ppdOpen(
3635cf
       ppd->ttrasterizer = string;
3635cf
     else if (!strcmp(keyword, "JCLBegin"))
3635cf
     {
3635cf
-      ppd->jcl_begin = _cupsStrAlloc(string);
3635cf
+      ppd->jcl_begin = strdup(string);
3635cf
       ppd_decode(ppd->jcl_begin);	/* Decode quoted string */
3635cf
     }
3635cf
     else if (!strcmp(keyword, "JCLEnd"))
3635cf
     {
3635cf
-      ppd->jcl_end = _cupsStrAlloc(string);
3635cf
+      ppd->jcl_end = strdup(string);
3635cf
       ppd_decode(ppd->jcl_end);		/* Decode quoted string */
3635cf
     }
3635cf
     else if (!strcmp(keyword, "JCLToPSInterpreter"))
3635cf
     {
3635cf
-      ppd->jcl_ps = _cupsStrAlloc(string);
3635cf
+      ppd->jcl_ps = strdup(string);
3635cf
       ppd_decode(ppd->jcl_ps);		/* Decode quoted string */
3635cf
     }
3635cf
     else if (!strcmp(keyword, "AccurateScreensSupport"))
3635cf
@@ -961,10 +942,10 @@ _ppdOpen(
3635cf
       ppd->num_filters ++;
3635cf
 
3635cf
      /*
3635cf
-      * Retain a copy of the filter string...
3635cf
+      * Make a copy of the filter string...
3635cf
       */
3635cf
 
3635cf
-      *filter = _cupsStrRetain(string);
3635cf
+      *filter = strdup(string);
3635cf
     }
3635cf
     else if (!strcmp(keyword, "Throughput"))
3635cf
       ppd->throughput = atoi(string);
3635cf
@@ -987,7 +968,7 @@ _ppdOpen(
3635cf
       }
3635cf
 
3635cf
       ppd->fonts                 = tempfonts;
3635cf
-      ppd->fonts[ppd->num_fonts] = _cupsStrAlloc(name);
3635cf
+      ppd->fonts[ppd->num_fonts] = strdup(name);
3635cf
       ppd->num_fonts ++;
3635cf
     }
3635cf
     else if (!strncmp(keyword, "ParamCustom", 11))
3635cf
@@ -1152,7 +1133,7 @@ _ppdOpen(
3635cf
 	strlcpy(choice->text, text[0] ? text : _("Custom"),
3635cf
 		sizeof(choice->text));
3635cf
 
3635cf
-	choice->code = _cupsStrAlloc(string);
3635cf
+	choice->code = strdup(string);
3635cf
 
3635cf
 	if (custom_option->section == PPD_ORDER_JCL)
3635cf
 	  ppd_decode(choice->code);
3635cf
@@ -1201,59 +1182,23 @@ _ppdOpen(
3635cf
       else if (!strcmp(string, "Plus90"))
3635cf
         ppd->landscape = 90;
3635cf
     }
3635cf
-    else if (!strcmp(keyword, "Emulators") && string)
3635cf
+    else if (!strcmp(keyword, "Emulators") && string && ppd->num_emulations == 0)
3635cf
     {
3635cf
-      for (count = 1, sptr = string; sptr != NULL;)
3635cf
-        if ((sptr = strchr(sptr, ' ')) != NULL)
3635cf
-	{
3635cf
-	  count ++;
3635cf
-	  while (*sptr == ' ')
3635cf
-	    sptr ++;
3635cf
-	}
3635cf
-
3635cf
-      ppd->num_emulations = count;
3635cf
-      if ((ppd->emulations = calloc((size_t)count, sizeof(ppd_emul_t))) == NULL)
3635cf
-      {
3635cf
-        pg->ppd_status = PPD_ALLOC_ERROR;
3635cf
-
3635cf
-	goto error;
3635cf
-      }
3635cf
-
3635cf
-      for (i = 0, sptr = string; i < count; i ++)
3635cf
-      {
3635cf
-        for (nameptr = ppd->emulations[i].name;
3635cf
-	     *sptr != '\0' && *sptr != ' ';
3635cf
-	     sptr ++)
3635cf
-	  if (nameptr < (ppd->emulations[i].name + sizeof(ppd->emulations[i].name) - 1))
3635cf
-	    *nameptr++ = *sptr;
3635cf
-
3635cf
-	*nameptr = '\0';
3635cf
-
3635cf
-	while (*sptr == ' ')
3635cf
-	  sptr ++;
3635cf
-      }
3635cf
-    }
3635cf
-    else if (!strncmp(keyword, "StartEmulator_", 14))
3635cf
-    {
3635cf
-      ppd_decode(string);
3635cf
+     /*
3635cf
+      * Issue #5562: Samsung printer drivers incorrectly use Emulators keyword
3635cf
+      *              to configure themselves
3635cf
+      *
3635cf
+      * The Emulators keyword was loaded but never used by anything in CUPS,
3635cf
+      * and has no valid purpose in CUPS.  The old code was removed due to a
3635cf
+      * memory leak (Issue #5475), so the following (new) code supports a single
3635cf
+      * name for the Emulators keyword, allowing these drivers to work until we
3635cf
+      * remove PPD and driver support entirely in a future version of CUPS.
3635cf
+      */
3635cf
 
3635cf
-      for (i = 0; i < ppd->num_emulations; i ++)
3635cf
-        if (!strcmp(keyword + 14, ppd->emulations[i].name))
3635cf
-	{
3635cf
-	  ppd->emulations[i].start = string;
3635cf
-	  string = NULL;
3635cf
-	}
3635cf
-    }
3635cf
-    else if (!strncmp(keyword, "StopEmulator_", 13))
3635cf
-    {
3635cf
-      ppd_decode(string);
3635cf
+      ppd->num_emulations = 1;
3635cf
+      ppd->emulations     = calloc(1, sizeof(ppd_emul_t));
3635cf
 
3635cf
-      for (i = 0; i < ppd->num_emulations; i ++)
3635cf
-        if (!strcmp(keyword + 13, ppd->emulations[i].name))
3635cf
-	{
3635cf
-	  ppd->emulations[i].stop = string;
3635cf
-	  string = NULL;
3635cf
-	}
3635cf
+      strlcpy(ppd->emulations[0].name, string, sizeof(ppd->emulations[0].name));
3635cf
     }
3635cf
     else if (!strcmp(keyword, "JobPatchFile"))
3635cf
     {
3635cf
@@ -1408,7 +1353,7 @@ _ppdOpen(
3635cf
 
3635cf
       option->section = PPD_ORDER_ANY;
3635cf
 
3635cf
-      _cupsStrFree(string);
3635cf
+      free(string);
3635cf
       string = NULL;
3635cf
 
3635cf
      /*
3635cf
@@ -1436,7 +1381,7 @@ _ppdOpen(
3635cf
 	strlcpy(choice->text,
3635cf
 	        custom_attr->text[0] ? custom_attr->text : _("Custom"),
3635cf
 		sizeof(choice->text));
3635cf
-        choice->code = _cupsStrRetain(custom_attr->value);
3635cf
+        choice->code = strdup(custom_attr->value);
3635cf
       }
3635cf
     }
3635cf
     else if (!strcmp(keyword, "JCLOpenUI"))
3635cf
@@ -1515,7 +1460,7 @@ _ppdOpen(
3635cf
       option->section = PPD_ORDER_JCL;
3635cf
       group = NULL;
3635cf
 
3635cf
-      _cupsStrFree(string);
3635cf
+      free(string);
3635cf
       string = NULL;
3635cf
 
3635cf
      /*
3635cf
@@ -1539,14 +1484,14 @@ _ppdOpen(
3635cf
 	strlcpy(choice->text,
3635cf
 	        custom_attr->text[0] ? custom_attr->text : _("Custom"),
3635cf
 		sizeof(choice->text));
3635cf
-        choice->code = _cupsStrRetain(custom_attr->value);
3635cf
+        choice->code = strdup(custom_attr->value);
3635cf
       }
3635cf
     }
3635cf
     else if (!strcmp(keyword, "CloseUI") || !strcmp(keyword, "JCLCloseUI"))
3635cf
     {
3635cf
       option = NULL;
3635cf
 
3635cf
-      _cupsStrFree(string);
3635cf
+      free(string);
3635cf
       string = NULL;
3635cf
     }
3635cf
     else if (!strcmp(keyword, "OpenGroup"))
3635cf
@@ -1593,14 +1538,14 @@ _ppdOpen(
3635cf
       if (group == NULL)
3635cf
 	goto error;
3635cf
 
3635cf
-      _cupsStrFree(string);
3635cf
+      free(string);
3635cf
       string = NULL;
3635cf
     }
3635cf
     else if (!strcmp(keyword, "CloseGroup"))
3635cf
     {
3635cf
       group = NULL;
3635cf
 
3635cf
-      _cupsStrFree(string);
3635cf
+      free(string);
3635cf
       string = NULL;
3635cf
     }
3635cf
     else if (!strcmp(keyword, "OrderDependency"))
3635cf
@@ -1658,7 +1603,7 @@ _ppdOpen(
3635cf
 	option->order   = order;
3635cf
       }
3635cf
 
3635cf
-      _cupsStrFree(string);
3635cf
+      free(string);
3635cf
       string = NULL;
3635cf
     }
3635cf
     else if (!strncmp(keyword, "Default", 7))
3635cf
@@ -1901,7 +1846,7 @@ _ppdOpen(
3635cf
       * Don't add this one as an attribute...
3635cf
       */
3635cf
 
3635cf
-      _cupsStrFree(string);
3635cf
+      free(string);
3635cf
       string = NULL;
3635cf
     }
3635cf
     else if (!strcmp(keyword, "PaperDimension"))
3635cf
@@ -1923,7 +1868,7 @@ _ppdOpen(
3635cf
       size->width  = (float)_cupsStrScand(string, &sptr, loc);
3635cf
       size->length = (float)_cupsStrScand(sptr, NULL, loc);
3635cf
 
3635cf
-      _cupsStrFree(string);
3635cf
+      free(string);
3635cf
       string = NULL;
3635cf
     }
3635cf
     else if (!strcmp(keyword, "ImageableArea"))
3635cf
@@ -1947,7 +1892,7 @@ _ppdOpen(
3635cf
       size->right  = (float)_cupsStrScand(sptr, &sptr, loc);
3635cf
       size->top    = (float)_cupsStrScand(sptr, NULL, loc);
3635cf
 
3635cf
-      _cupsStrFree(string);
3635cf
+      free(string);
3635cf
       string = NULL;
3635cf
     }
3635cf
     else if (option != NULL &&
3635cf
@@ -2003,7 +1948,7 @@ _ppdOpen(
3635cf
         (mask & (PPD_KEYWORD | PPD_STRING)) == (PPD_KEYWORD | PPD_STRING))
3635cf
       ppd_add_attr(ppd, keyword, name, text, string);
3635cf
     else
3635cf
-      _cupsStrFree(string);
3635cf
+      free(string);
3635cf
   }
3635cf
 
3635cf
  /*
3635cf
@@ -2016,7 +1961,8 @@ _ppdOpen(
3635cf
     goto error;
3635cf
   }
3635cf
 
3635cf
-  ppd_free(line.buffer);
3635cf
+  free(string);
3635cf
+  free(line.buffer);
3635cf
 
3635cf
  /*
3635cf
   * Reset language preferences...
3635cf
@@ -2098,8 +2044,8 @@ _ppdOpen(
3635cf
 
3635cf
   error:
3635cf
 
3635cf
-  _cupsStrFree(string);
3635cf
-  ppd_free(line.buffer);
3635cf
+  free(string);
3635cf
+  free(line.buffer);
3635cf
 
3635cf
   ppdClose(ppd);
3635cf
 
3635cf
@@ -2537,9 +2483,9 @@ ppd_free_filters(ppd_file_t *ppd)	/* I - PPD file */
3635cf
   if (ppd->num_filters > 0)
3635cf
   {
3635cf
     for (i = ppd->num_filters, filter = ppd->filters; i > 0; i --, filter ++)
3635cf
-      _cupsStrFree(*filter);
3635cf
+      free(*filter);
3635cf
 
3635cf
-    ppd_free(ppd->filters);
3635cf
+    free(ppd->filters);
3635cf
 
3635cf
     ppd->num_filters = 0;
3635cf
     ppd->filters     = NULL;
3635cf
@@ -2566,7 +2512,7 @@ ppd_free_group(ppd_group_t *group)	/* I - Group to free */
3635cf
 	 i --, option ++)
3635cf
       ppd_free_option(option);
3635cf
 
3635cf
-    ppd_free(group->options);
3635cf
+    free(group->options);
3635cf
   }
3635cf
 
3635cf
   if (group->num_subgroups > 0)
3635cf
@@ -2576,7 +2522,7 @@ ppd_free_group(ppd_group_t *group)	/* I - Group to free */
3635cf
 	 i --, subgroup ++)
3635cf
       ppd_free_group(subgroup);
3635cf
 
3635cf
-    ppd_free(group->subgroups);
3635cf
+    free(group->subgroups);
3635cf
   }
3635cf
 }
3635cf
 
3635cf
@@ -2598,10 +2544,10 @@ ppd_free_option(ppd_option_t *option)	/* I - Option to free */
3635cf
          i > 0;
3635cf
          i --, choice ++)
3635cf
     {
3635cf
-      _cupsStrFree(choice->code);
3635cf
+      free(choice->code);
3635cf
     }
3635cf
 
3635cf
-    ppd_free(option->choices);
3635cf
+    free(option->choices);
3635cf
   }
3635cf
 }
3635cf
 
3635cf
@@ -3338,7 +3284,7 @@ ppd_read(cups_file_t    *fp,		/* I - File to read from */
3635cf
 	lineptr ++;
3635cf
       }
3635cf
 
3635cf
-      *string = _cupsStrAlloc(lineptr);
3635cf
+      *string = strdup(lineptr);
3635cf
 
3635cf
       mask |= PPD_STRING;
3635cf
     }
3635cf
@@ -3460,7 +3406,7 @@ ppd_update_filters(ppd_file_t     *ppd,	/* I - PPD file */
3635cf
     filter           += ppd->num_filters;
3635cf
     ppd->num_filters ++;
3635cf
 
3635cf
-    *filter = _cupsStrAlloc(buffer);
3635cf
+    *filter = strdup(buffer);
3635cf
   }
3635cf
   while ((attr = ppdFindNextAttr(ppd, "cupsFilter2", NULL)) != NULL);
3635cf
 
3635cf
diff --git a/cups/ppd.h b/cups/ppd.h
3635cf
index fb33c08..1c852c7 100644
3635cf
--- a/cups/ppd.h
3635cf
+++ b/cups/ppd.h
3635cf
@@ -302,8 +302,8 @@ typedef struct ppd_file_s		/**** PPD File ****/
3635cf
   int		throughput;		/* Pages per minute */
3635cf
   ppd_cs_t	colorspace;		/* Default colorspace */
3635cf
   char		*patches;		/* Patch commands to be sent to printer */
3635cf
-  int		num_emulations;		/* Number of emulations supported */
3635cf
-  ppd_emul_t	*emulations;		/* Emulations and the code to invoke them */
3635cf
+  int		num_emulations;		/* Number of emulations supported (no longer supported) @private@ */
3635cf
+  ppd_emul_t	*emulations;		/* Emulations and the code to invoke them (no longer supported) @private@ */
3635cf
   char		*jcl_begin;		/* Start JCL commands */
3635cf
   char		*jcl_ps;		/* Enter PostScript interpreter */
3635cf
   char		*jcl_end;		/* End JCL commands */
3635cf
diff --git a/cups/string.c b/cups/string.c
3635cf
index 0d4ed0f..8f37caf 100644
3635cf
--- a/cups/string.c
3635cf
+++ b/cups/string.c
3635cf
@@ -316,6 +316,13 @@ _cupsStrFree(const char *s)		/* I - String to free */
3635cf
 
3635cf
   key = (_cups_sp_item_t *)(s - offsetof(_cups_sp_item_t, str));
3635cf
 
3635cf
+  if ((item = (_cups_sp_item_t *)cupsArrayFind(stringpool, key)) != NULL &&
3635cf
+      item == key)
3635cf
+  {
3635cf
+   /*
3635cf
+    * Found it, dereference...
3635cf
+    */
3635cf
+
3635cf
 #ifdef DEBUG_GUARDS
3635cf
   if (key->guard != _CUPS_STR_GUARD)
3635cf
   {
3635cf
@@ -325,13 +332,6 @@ _cupsStrFree(const char *s)		/* I - String to free */
3635cf
   }
3635cf
 #endif /* DEBUG_GUARDS */
3635cf
 
3635cf
-  if ((item = (_cups_sp_item_t *)cupsArrayFind(stringpool, key)) != NULL &&
3635cf
-      item == key)
3635cf
-  {
3635cf
-   /*
3635cf
-    * Found it, dereference...
3635cf
-    */
3635cf
-
3635cf
     item->ref_count --;
3635cf
 
3635cf
     if (!item->ref_count)
3635cf
diff --git a/scheduler/ipp.c b/scheduler/ipp.c
3635cf
index 298b684..e0dbc4a 100644
3635cf
--- a/scheduler/ipp.c
3635cf
+++ b/scheduler/ipp.c
3635cf
@@ -2918,8 +2918,7 @@ add_printer(cupsd_client_t  *con,	/* I - Client connection */
3635cf
       if (!strcmp(attr->values[i].string.text, "none"))
3635cf
         continue;
3635cf
 
3635cf
-      printer->reasons[printer->num_reasons] =
3635cf
-          _cupsStrRetain(attr->values[i].string.text);
3635cf
+      printer->reasons[printer->num_reasons] = _cupsStrAlloc(attr->values[i].string.text);
3635cf
       printer->num_reasons ++;
3635cf
 
3635cf
       if (!strcmp(attr->values[i].string.text, "paused") &&
3635cf
@@ -5437,8 +5436,7 @@ copy_printer_attrs(
3635cf
 
3635cf
         if ((p2_uri = ippFindAttribute(p2->attrs, "printer-uri-supported",
3635cf
 	                               IPP_TAG_URI)) != NULL)
3635cf
-          member_uris->values[i].string.text =
3635cf
-	      _cupsStrRetain(p2_uri->values[0].string.text);
3635cf
+          member_uris->values[i].string.text = _cupsStrAlloc(p2_uri->values[0].string.text);
3635cf
         else
3635cf
 	{
3635cf
 	  httpAssembleURIf(HTTP_URI_CODING_ALL, printer_uri,
3635cf
diff --git a/scheduler/printers.c b/scheduler/printers.c
3635cf
index 3ec16cf..f16552e 100644
3635cf
--- a/scheduler/printers.c
3635cf
+++ b/scheduler/printers.c
3635cf
@@ -54,8 +54,7 @@ static int	compare_printers(void *first, void *second, void *data);
3635cf
 static void	delete_printer_filters(cupsd_printer_t *p);
3635cf
 static void	dirty_printer(cupsd_printer_t *p);
3635cf
 static void	load_ppd(cupsd_printer_t *p);
3635cf
-static ipp_t	*new_media_col(pwg_size_t *size, const char *source,
3635cf
-		               const char *type);
3635cf
+static ipp_t	*new_media_col(pwg_size_t *size);
3635cf
 static void	write_xml_string(cups_file_t *fp, const char *s);
3635cf
 
3635cf
 
3635cf
@@ -3873,21 +3872,19 @@ dirty_printer(cupsd_printer_t *p)	/* I - Printer */
3635cf
 static void
3635cf
 load_ppd(cupsd_printer_t *p)		/* I - Printer */
3635cf
 {
3635cf
-  int		i, j, k;		/* Looping vars */
3635cf
+  int		i, j;			/* Looping vars */
3635cf
   char		cache_name[1024];	/* Cache filename */
3635cf
   struct stat	cache_info;		/* Cache file info */
3635cf
   ppd_file_t	*ppd;			/* PPD file */
3635cf
   char		ppd_name[1024];		/* PPD filename */
3635cf
   struct stat	ppd_info;		/* PPD file info */
3635cf
-  int		num_media;		/* Number of media options */
3635cf
+  int		num_media;		/* Number of media values */
3635cf
   ppd_size_t	*size;			/* Current PPD size */
3635cf
   ppd_option_t	*duplex,		/* Duplex option */
3635cf
 		*output_bin,		/* OutputBin option */
3635cf
 		*output_mode,		/* OutputMode option */
3635cf
 		*resolution;		/* (Set|JCL|)Resolution option */
3635cf
-  ppd_choice_t	*choice,		/* Current PPD choice */
3635cf
-		*input_slot,		/* Current input slot */
3635cf
-		*media_type;		/* Current media type */
3635cf
+  ppd_choice_t	*choice;		/* Current PPD choice */
3635cf
   ppd_attr_t	*ppd_attr;		/* PPD attribute */
3635cf
   int		xdpi,			/* Horizontal resolution */
3635cf
 		ydpi;			/* Vertical resolution */
3635cf
@@ -4147,18 +4144,7 @@ load_ppd(cupsd_printer_t *p)		/* I - Printer */
3635cf
       {
3635cf
         ipp_t	*col;			/* Collection value */
3635cf
 
3635cf
-	input_slot = ppdFindMarkedChoice(ppd, "InputSlot");
3635cf
-	media_type = ppdFindMarkedChoice(ppd, "MediaType");
3635cf
-	col        = new_media_col(pwgsize,
3635cf
-			           input_slot ?
3635cf
-				       _ppdCacheGetSource(p->pc,
3635cf
-				                          input_slot->choice) :
3635cf
-				       NULL,
3635cf
-				   media_type ?
3635cf
-				       _ppdCacheGetType(p->pc,
3635cf
-				                        media_type->choice) :
3635cf
-				       NULL);
3635cf
-
3635cf
+	col = new_media_col(pwgsize);
3635cf
 	ippAddCollection(p->ppd_attrs, IPP_TAG_PRINTER, "media-col-default",
3635cf
 	                 col);
3635cf
         ippDelete(col);
3635cf
@@ -4354,89 +4340,19 @@ load_ppd(cupsd_printer_t *p)		/* I - Printer */
3635cf
       * media-col-database
3635cf
       */
3635cf
 
3635cf
-      num_media = p->pc->num_sizes;
3635cf
-      if (p->pc->num_sources)
3635cf
+      if ((attr = ippAddCollections(p->ppd_attrs, IPP_TAG_PRINTER, "media-col-database", p->pc->num_sizes, NULL)) != NULL)
3635cf
       {
3635cf
-        if (p->pc->num_types > 0)
3635cf
-	  num_media += p->pc->num_sizes * p->pc->num_sources *
3635cf
-	               p->pc->num_types;
3635cf
-	else
3635cf
-          num_media += p->pc->num_sizes * p->pc->num_sources;
3635cf
-      }
3635cf
-      else if (p->pc->num_types)
3635cf
-        num_media += p->pc->num_sizes * p->pc->num_types;
3635cf
+       /*
3635cf
+	* Add each page size without source or type...
3635cf
+	*/
3635cf
 
3635cf
-      if ((attr = ippAddCollections(p->ppd_attrs, IPP_TAG_PRINTER,
3635cf
-                                    "media-col-database", num_media,
3635cf
-				    NULL)) != NULL)
3635cf
-      {
3635cf
-        for (i = p->pc->num_sizes, pwgsize = p->pc->sizes, val = attr->values;
3635cf
-	     i > 0;
3635cf
-	     i --, pwgsize ++)
3635cf
+        for (i = 0, pwgsize = p->pc->sizes; i < p->pc->num_sizes; i ++, pwgsize ++)
3635cf
 	{
3635cf
-	 /*
3635cf
-	  * Start by adding the page size without source or type...
3635cf
-	  */
3635cf
+	  ipp_t *col = new_media_col(pwgsize);
3635cf
 
3635cf
-	  ppdMarkOption(ppd, "PageSize", pwgsize->map.ppd);
3635cf
-
3635cf
-          val->collection = new_media_col(pwgsize, NULL, NULL);
3635cf
-	  val ++;
3635cf
-
3635cf
-         /*
3635cf
-	  * Then add the specific, supported combinations of size, source, and
3635cf
-	  * type...
3635cf
-	  */
3635cf
-
3635cf
-	  if (p->pc->num_sources > 0)
3635cf
-	  {
3635cf
-	    for (j = p->pc->num_sources, pwgsource = p->pc->sources;
3635cf
-	         j > 0;
3635cf
-		 j --, pwgsource ++)
3635cf
-	    {
3635cf
-	      ppdMarkOption(ppd, "InputSlot", pwgsource->ppd);
3635cf
-
3635cf
-	      if (p->pc->num_types > 0)
3635cf
-	      {
3635cf
-	        for (k = p->pc->num_types, pwgtype = p->pc->types;
3635cf
-		     k > 0;
3635cf
-		     k --, pwgtype ++)
3635cf
-		{
3635cf
-		  if (!ppdMarkOption(ppd, "MediaType", pwgtype->ppd))
3635cf
-		  {
3635cf
-		    val->collection = new_media_col(pwgsize, pwgsource->pwg,
3635cf
-		                                    pwgtype->pwg);
3635cf
-		    val ++;
3635cf
-		  }
3635cf
-		}
3635cf
-	      }
3635cf
-	      else if (!ppdConflicts(ppd))
3635cf
-	      {
3635cf
-	        val->collection = new_media_col(pwgsize, pwgsource->pwg, NULL);
3635cf
-		val ++;
3635cf
-	      }
3635cf
-	    }
3635cf
-	  }
3635cf
-	  else if (p->pc->num_types > 0)
3635cf
-	  {
3635cf
-	    for (j = p->pc->num_types, pwgtype = p->pc->types;
3635cf
-	         j > 0;
3635cf
-		 j --, pwgtype ++)
3635cf
-	    {
3635cf
-	      if (!ppdMarkOption(ppd, "MediaType", pwgtype->ppd))
3635cf
-	      {
3635cf
-	        val->collection = new_media_col(pwgsize, NULL, pwgtype->pwg);
3635cf
-		val ++;
3635cf
-	      }
3635cf
-	    }
3635cf
-	  }
3635cf
+	  ippSetCollection(p->ppd_attrs, &attr, i, col);
3635cf
+	  ippDelete(col);
3635cf
 	}
3635cf
-
3635cf
-       /*
3635cf
-        * Update the number of media-col-database values...
3635cf
-	*/
3635cf
-
3635cf
-	attr->num_values = val - attr->values;
3635cf
       }
3635cf
     }
3635cf
 
3635cf
@@ -5134,9 +5050,7 @@ load_ppd(cupsd_printer_t *p)		/* I - Printer */
3635cf
  */
3635cf
 
3635cf
 static ipp_t *				/* O - Collection value */
3635cf
-new_media_col(pwg_size_t *size,	/* I - media-size/margin values */
3635cf
-              const char  *source,	/* I - media-source value */
3635cf
-              const char  *type)	/* I - media-type value */
3635cf
+new_media_col(pwg_size_t *size)		/* I - media-size/margin values */
3635cf
 {
3635cf
   ipp_t	*media_col,			/* Collection value */
3635cf
 	*media_size;			/* media-size value */
3635cf
@@ -5145,29 +5059,15 @@ new_media_col(pwg_size_t *size,	/* I - media-size/margin values */
3635cf
   media_col = ippNew();
3635cf
 
3635cf
   media_size = ippNew();
3635cf
-  ippAddInteger(media_size, IPP_TAG_PRINTER, IPP_TAG_INTEGER,
3635cf
-		"x-dimension", size->width);
3635cf
-  ippAddInteger(media_size, IPP_TAG_PRINTER, IPP_TAG_INTEGER,
3635cf
-		"y-dimension", size->length);
3635cf
+  ippAddInteger(media_size, IPP_TAG_PRINTER, IPP_TAG_INTEGER, "x-dimension", size->width);
3635cf
+  ippAddInteger(media_size, IPP_TAG_PRINTER, IPP_TAG_INTEGER, "y-dimension", size->length);
3635cf
   ippAddCollection(media_col, IPP_TAG_PRINTER, "media-size", media_size);
3635cf
   ippDelete(media_size);
3635cf
 
3635cf
-  ippAddInteger(media_col, IPP_TAG_PRINTER, IPP_TAG_INTEGER,
3635cf
-		"media-bottom-margin", size->bottom);
3635cf
-  ippAddInteger(media_col, IPP_TAG_PRINTER, IPP_TAG_INTEGER,
3635cf
-		"media-left-margin", size->left);
3635cf
-  ippAddInteger(media_col, IPP_TAG_PRINTER, IPP_TAG_INTEGER,
3635cf
-		"media-right-margin", size->right);
3635cf
-  ippAddInteger(media_col, IPP_TAG_PRINTER, IPP_TAG_INTEGER,
3635cf
-		"media-top-margin", size->top);
3635cf
-
3635cf
-  if (source)
3635cf
-    ippAddString(media_col, IPP_TAG_PRINTER, IPP_TAG_KEYWORD, "media-source",
3635cf
-		 NULL, source);
3635cf
-
3635cf
-  if (type)
3635cf
-    ippAddString(media_col, IPP_TAG_PRINTER, IPP_TAG_KEYWORD, "media-type",
3635cf
-		 NULL, type);
3635cf
+  ippAddInteger(media_col, IPP_TAG_PRINTER, IPP_TAG_INTEGER, "media-bottom-margin", size->bottom);
3635cf
+  ippAddInteger(media_col, IPP_TAG_PRINTER, IPP_TAG_INTEGER, "media-left-margin", size->left);
3635cf
+  ippAddInteger(media_col, IPP_TAG_PRINTER, IPP_TAG_INTEGER, "media-right-margin", size->right);
3635cf
+  ippAddInteger(media_col, IPP_TAG_PRINTER, IPP_TAG_INTEGER, "media-top-margin", size->top);
3635cf
 
3635cf
   return (media_col);
3635cf
 }