From: Ben Pfaff <blp@cs.stanford.edu>
Date: Thu, 26 Dec 2019 00:41:22 +0000 (+0000)
Subject: table: Add pool parameter to area_style_copy(), font_style_copy().
X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=086c00aa4c7e11ef10cdb20a3afc2ba9caa464ec;p=pspp

table: Add pool parameter to area_style_copy(), font_style_copy().

This was inconsistent since the clone functions took them but the
copy functions didn't.
---

diff --git a/src/output/pivot-table.c b/src/output/pivot-table.c
index ff45226e64..cce72ef1de 100644
--- a/src/output/pivot-table.c
+++ b/src/output/pivot-table.c
@@ -1978,9 +1978,9 @@ pivot_value_get_style (struct pivot_value *value,
                        const struct area_style *default_style,
                        struct area_style *area)
 {
-  font_style_copy (&area->font_style, (value->font_style
-                                       ? value->font_style
-                                       : &default_style->font_style));
+  font_style_copy (NULL, &area->font_style, (value->font_style
+                                             ? value->font_style
+                                             : &default_style->font_style));
   area->cell_style = (value->cell_style
                       ? *value->cell_style
                       : default_style->cell_style);
@@ -1995,7 +1995,7 @@ pivot_value_set_style (struct pivot_value *value,
     font_style_uninit (value->font_style);
   else
     value->font_style = xmalloc (sizeof *value->font_style);
-  font_style_copy (value->font_style, &area->font_style);
+  font_style_copy (NULL, value->font_style, &area->font_style);
 
   if (!value->cell_style)
     value->cell_style = xmalloc (sizeof *value->cell_style);
diff --git a/src/output/table.c b/src/output/table.c
index 10b9f55663..00759a0016 100644
--- a/src/output/table.c
+++ b/src/output/table.c
@@ -228,11 +228,12 @@ table_halign_interpret (enum table_halign halign, bool numeric)
 }
 
 void
-font_style_copy (struct font_style *dst, const struct font_style *src)
+font_style_copy (struct pool *container,
+                 struct font_style *dst, const struct font_style *src)
 {
   *dst = *src;
   if (dst->typeface)
-    dst->typeface = xstrdup (dst->typeface);
+    dst->typeface = pool_strdup (container, dst->typeface);
 }
 
 void
@@ -243,9 +244,10 @@ font_style_uninit (struct font_style *font)
 }
 
 void
-area_style_copy (struct area_style *dst, const struct area_style *src)
+area_style_copy (struct pool *container,
+                 struct area_style *dst, const struct area_style *src)
 {
-  font_style_copy (&dst->font_style, &src->font_style);
+  font_style_copy (container, &dst->font_style, &src->font_style);
   dst->cell_style = src->cell_style;
 }
 
diff --git a/src/output/table.h b/src/output/table.h
index 5075fa9e40..d7f3619716 100644
--- a/src/output/table.h
+++ b/src/output/table.h
@@ -143,7 +143,8 @@ struct font_style
         .fg = { [0] = CELL_COLOR_BLACK, [1] = CELL_COLOR_BLACK},        \
         .bg = { [0] = CELL_COLOR_WHITE, [1] = CELL_COLOR_WHITE},
 
-void font_style_copy (struct font_style *, const struct font_style *);
+void font_style_copy (struct pool *,
+                      struct font_style *, const struct font_style *);
 void font_style_uninit (struct font_style *);
 void font_style_dump (const struct font_style *);
 
@@ -159,7 +160,8 @@ struct area_style
        .font_style = FONT_STYLE_INITIALIZER
 
 struct area_style *area_style_clone (struct pool *, const struct area_style *);
-void area_style_copy (struct area_style *, const struct area_style *);
+void area_style_copy (struct pool *,
+                      struct area_style *, const struct area_style *);
 void area_style_uninit (struct area_style *);
 void area_style_free (struct area_style *);