diff options
| author | Paul Eggert <eggert@cs.ucla.edu> | 2026-05-22 12:29:37 -0700 |
|---|---|---|
| committer | Paul Eggert <eggert@cs.ucla.edu> | 2026-05-23 19:18:53 -0700 |
| commit | 19264b6912a111cfe426063ca431d202817f747d (patch) | |
| tree | 86b5700f96e965a8050c5e2857fb8d2ead3329bf | |
| parent | 64eb869b68835e15b46a217a6d955605b78044bc (diff) | |
adjust_glyph_matrix reallocation improvement
* src/dispnew.c (adjust_glyph_matrix):
Use xfree + xcalloc instead of xnrealloc + memset,
as there is no need to preserve the old contents.
| -rw-r--r-- | src/dispnew.c | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/src/dispnew.c b/src/dispnew.c index 7930fa59968..fb313bfd1af 100644 --- a/src/dispnew.c +++ b/src/dispnew.c @@ -500,16 +500,15 @@ adjust_glyph_matrix (struct window *w, struct glyph_matrix *matrix, int x, int y while (row < end) { - /* Only realloc if matrix got wider or taller (bug#77961). */ + /* Realloc if matrix got wider or taller (bug#77961). */ if (dim.width > matrix->matrix_w || new_rows) { - row->glyphs[LEFT_MARGIN_AREA] - = xnrealloc (row->glyphs[LEFT_MARGIN_AREA], - dim.width, sizeof (struct glyph)); + xfree (row->glyphs[LEFT_MARGIN_AREA]); + row->glyphs[LEFT_MARGIN_AREA] = NULL; /* We actually need to clear only the 'frame' member, but it's easier to clear everything. */ - memset (row->glyphs[LEFT_MARGIN_AREA], 0, - dim.width * sizeof (struct glyph)); + row->glyphs[LEFT_MARGIN_AREA] + = xcalloc (dim.width, sizeof (struct glyph)); } if ((row == matrix->rows + dim.height - 1 |
