table: Add pool parameter to area_style_copy(), font_style_copy().
authorBen Pfaff <blp@cs.stanford.edu>
Thu, 26 Dec 2019 00:41:22 +0000 (00:41 +0000)
committerBen Pfaff <blp@cs.stanford.edu>
Sun, 29 Dec 2019 05:28:10 +0000 (05:28 +0000)
This was inconsistent since the clone functions took them but the
copy functions didn't.

src/output/pivot-table.c
src/output/table.c
src/output/table.h

index ff45226e6475928b97365d163e719a7162b1ea9e..cce72ef1defabaafad9bf2af6b60c25b3b9830bc 100644 (file)
@@ -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);
index 10b9f55663e3d0672c5da7ef05792d1524f6892b..00759a00162a1d2c809303f152aaf655d201103f 100644 (file)
@@ -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;
 }
 
index 5075fa9e40fc85b122e75da580944d69ac858767..d7f36197164a03cf15385b3ddad95d3a1256a411 100644 (file)
@@ -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 *);