diff --git a/src/shared/format-table.c b/src/shared/format-table.c index ae56cd3d678..6bbc8bd509e 100644 --- a/src/shared/format-table.c +++ b/src/shared/format-table.c @@ -1078,17 +1078,21 @@ int table_set_empty_string(Table *t, const char *empty) { 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; diff --git a/src/shared/format-table.h b/src/shared/format-table.h index d1935456f0a..57f167f7f11 100644 --- a/src/shared/format-table.h +++ b/src/shared/format-table.h @@ -100,7 +100,6 @@ void table_set_header(Table *table, bool b); 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, ...);