render: Simplify 'pages' array in struct render_pager.
authorBen Pfaff <blp@cs.stanford.edu>
Fri, 1 Jan 2021 06:00:50 +0000 (22:00 -0800)
committerBen Pfaff <blp@cs.stanford.edu>
Sat, 2 Jan 2021 03:23:40 +0000 (19:23 -0800)
src/output/render.c

index 680beb38f86d69b18d8ddeb6812c8cf4d862bac4..ae67b6351e0cea70bd630a84049ede8714c8909a 100644 (file)
@@ -1483,12 +1483,11 @@ struct render_pager
     const struct render_params *params;
     double scale;
 
-    /* An array of "render_page"s to be rendered, in order, vertically.  From
-       the user's perspective, there's only one table per render_pager, but the
-       implementation treats the title, table body, caption, footnotes,
-       etc. each as a table, and that's why we have an array here. */
-    struct render_page **pages;
-    size_t n_pages, allocated_pages;
+    /* An array of "render_page"s to be rendered, in order, vertically.  There
+       may be up to 5 pages, for the pivot table's title, layers, body,
+       captions, and footnotes. */
+    struct render_page *pages[5];
+    size_t n_pages;
 
     size_t cur_page;
     struct render_break x_break;
@@ -1499,9 +1498,6 @@ static const struct render_page *
 render_pager_add_table (struct render_pager *p, struct table *table,
                         int min_width)
 {
-  if (p->n_pages >= p->allocated_pages)
-    p->pages = x2nrealloc (p->pages, &p->allocated_pages, sizeof *p->pages);
-
   struct render_page *page = render_page_create (p->params, table, min_width);
   p->pages[p->n_pages++] = page;
   return page;
@@ -1645,7 +1641,6 @@ render_pager_destroy (struct render_pager *p)
       render_break_destroy (&p->y_break);
       for (size_t i = 0; i < p->n_pages; i++)
         render_page_unref (p->pages[i]);
-      free (p->pages);
       free (p);
     }
 }