* Initialise a table contents struct. * Must be called before any other printTable method is used. * * The title is not duplicated; the caller must ensure that the buffer * is available for the lifetime of the printTableContent struct. * * If you call this, you must call printTableCleanup once you're done with the * table. */
| 3055 | * table. |
| 3056 | */ |
| 3057 | void |
| 3058 | printTableInit(printTableContent *const content, const printTableOpt *opt, |
| 3059 | const char *title, const int ncolumns, const int nrows) |
| 3060 | { |
| 3061 | long total_cells; |
| 3062 | |
| 3063 | content->opt = opt; |
| 3064 | content->title = title; |
| 3065 | content->ncolumns = ncolumns; |
| 3066 | content->nrows = nrows; |
| 3067 | |
| 3068 | content->headers = pg_malloc0((ncolumns + 1) * sizeof(*content->headers)); |
| 3069 | |
| 3070 | total_cells = (long)ncolumns * (long)nrows; |
| 3071 | content->cells = pg_malloc0((total_cells + 1) * sizeof(*content->cells)); |
| 3072 | |
| 3073 | content->cellmustfree = NULL; |
| 3074 | content->footers = NULL; |
| 3075 | |
| 3076 | content->aligns = pg_malloc0((ncolumns + 1) * sizeof(*content->align)); |
| 3077 | |
| 3078 | content->header = content->headers; |
| 3079 | content->cell = content->cells; |
| 3080 | content->footer = content->footers; |
| 3081 | content->align = content->aligns; |
| 3082 | content->cellsadded = 0; |
| 3083 | } |
| 3084 | |
| 3085 | /* |
| 3086 | * Add a header to the table. |
no test coverage detected