Blame SOURCES/cups-memory-consumption.patch

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