Adding a reference count to tab_table allows output drivers to retain
a copy of a table even after the main output engine is done. This
will be useful for the GUI output driver.
struct tab_table *t;
t = pool_create_container (struct tab_table, container);
struct tab_table *t;
t = pool_create_container (struct tab_table, container);
t->col_style = TAB_COL_NONE;
t->col_group = 0;
t->title = NULL;
t->col_style = TAB_COL_NONE;
t->col_group = 0;
t->title = NULL;
+/* Increases T's reference count and, if this causes T's
+ reference count to reach 0, destroys T. */
void
tab_destroy (struct tab_table *t)
{
void
tab_destroy (struct tab_table *t)
{
+ assert (t->ref_cnt > 0);
+ if (--t->ref_cnt > 0)
+ return;
if (t->dim_free != NULL)
t->dim_free (t->dim_aux);
free (t->title);
pool_destroy (t->container);
}
if (t->dim_free != NULL)
t->dim_free (t->dim_aux);
free (t->title);
pool_destroy (t->container);
}
+/* Increases T's reference count. */
+void
+tab_ref (struct tab_table *t)
+{
+ assert (t->ref_cnt > 0);
+ t->ref_cnt++;
+}
+
/* Sets the width and height of a table, in columns and rows,
respectively. Use only to reduce the size of a table, since it
does not change the amount of allocated memory. */
/* Sets the width and height of a table, in columns and rows,
respectively. Use only to reduce the size of a table, since it
does not change the amount of allocated memory. */
struct tab_table
{
struct pool *container;
struct tab_table
{
struct pool *container;
+ int ref_cnt; /* Reference count. */
/* Contents. */
int col_style; /* Columns: One of TAB_COL_*. */
/* Contents. */
int col_style; /* Columns: One of TAB_COL_*. */
/* Tables. */
struct tab_table *tab_create (int nc, int nr, int reallocable);
void tab_destroy (struct tab_table *);
/* Tables. */
struct tab_table *tab_create (int nc, int nr, int reallocable);
void tab_destroy (struct tab_table *);
+void tab_ref (struct tab_table *);
void tab_resize (struct tab_table *, int nc, int nr);
void tab_realloc (struct tab_table *, int nc, int nr);
void tab_headers (struct tab_table *, int l, int r, int t, int b);
void tab_resize (struct tab_table *, int nc, int nr);
void tab_realloc (struct tab_table *, int nc, int nr);
void tab_headers (struct tab_table *, int l, int r, int t, int b);