X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Foutput%2Fascii.c;h=1688fd1bf1217c8e0df48109eb64df2f7a45f1d9;hb=48ec61d954cc032c773daf96851cf3b78f27b112;hp=d121987a20c5d389eff0f5572a0b1386302bc2b1;hpb=3c70826f9e59d2008305ed8305554a532851f6d9;p=pspp diff --git a/src/output/ascii.c b/src/output/ascii.c index d121987a20..1688fd1bf1 100644 --- a/src/output/ascii.c +++ b/src/output/ascii.c @@ -202,6 +202,24 @@ static void ascii_draw_cell (void *, const struct table_cell *, int bb[TABLE_N_AXES][2], int clip[TABLE_N_AXES][2]); +static void +reallocate_lines (struct ascii_driver *a) +{ + if (a->length > a->allocated_lines) + { + int i; + a->lines = xnrealloc (a->lines, a->length, sizeof *a->lines); + for (i = a->allocated_lines; i < a->length; i++) + { + struct ascii_line *line = &a->lines[i]; + ds_init_empty (&line->s); + line->width = 0; + } + a->allocated_lines = a->length; + } +} + + static struct ascii_driver * ascii_driver_cast (struct output_driver *driver) { @@ -340,6 +358,8 @@ update_page_size (struct ascii_driver *a, bool issue_error) return false; } + reallocate_lines (a); + return true; } @@ -955,7 +975,6 @@ ascii_layout_cell (struct ascii_driver *a, const struct table_cell *cell, if (length == 0) return; - text = cell->contents; breaks = xmalloc (length + 1); u8_possible_linebreaks (CHAR_CAST (const uint8_t *, text), length, "UTF-8", breaks); @@ -1110,17 +1129,7 @@ ascii_open_page (struct ascii_driver *a) a->page_number++; - if (a->length > a->allocated_lines) - { - a->lines = xnrealloc (a->lines, a->length, sizeof *a->lines); - for (i = a->allocated_lines; i < a->length; i++) - { - struct ascii_line *line = &a->lines[i]; - ds_init_empty (&line->s); - line->width = 0; - } - a->allocated_lines = a->length; - } + reallocate_lines (a); for (i = 0; i < a->length; i++) {