return free_and_strdup(&t->empty_string, empty);
}
-int table_set_display_all(Table *t) {
+static int table_set_display_all(Table *t) {
+ size_t *d;
+
assert(t);
- size_t allocated = t->n_display_map;
+ /* Initialize the display map to the identity */
- if (!GREEDY_REALLOC(t->display_map, allocated, MAX(t->n_columns, allocated)))
+ d = reallocarray(t->display_map, t->n_columns, sizeof(size_t));
+ if (!d)
return -ENOMEM;
for (size_t i = 0; i < t->n_columns; i++)
- t->display_map[i] = i;
+ d[i] = i;
+ t->display_map = d;
t->n_display_map = t->n_columns;
return 0;
void table_set_width(Table *t, size_t width);
void table_set_cell_height_max(Table *t, size_t height);
int table_set_empty_string(Table *t, const char *empty);
-int table_set_display_all(Table *t);
int table_set_display_internal(Table *t, size_t first_column, ...);
#define table_set_display(...) table_set_display_internal(__VA_ARGS__, SIZE_MAX)
int table_set_sort_internal(Table *t, size_t first_column, ...);