From 3d3187e5c55a770cd68b1144479a70032b3c3558 Mon Sep 17 00:00:00 2001 From: Helmut Eller Date: Sun, 5 May 2024 09:38:48 +0200 Subject: [PATCH] Glyph matrices don't need to be ambiguous roots We scan them with fix_glyph_matrix as part of fix_windows. So avoid scanning them twice. save_current_matrix and restore_current_matrix create temporary matrices that aren't seen by fix_glyph_matrix; these are still ambiguous roots. * src/dispnew.c (adjust_glyph_matrix, realloc_glyph_pool) (free_glyph_matrix): Use plain malloc instead of igc_xzalloc_ambig. (restore_current_matrix): Use igc_free where needed. --- src/dispnew.c | 22 ++-------------------- 1 file changed, 2 insertions(+), 20 deletions(-) diff --git a/src/dispnew.c b/src/dispnew.c index 7bb78c3b214..4d7586bdc1e 100644 --- a/src/dispnew.c +++ b/src/dispnew.c @@ -304,11 +304,7 @@ free_glyph_matrix (struct glyph_matrix *matrix) /* Free glyph memory if MATRIX owns it. */ if (matrix->pool == NULL) for (i = 0; i < matrix->rows_allocated; ++i) -#ifdef HAVE_MPS - igc_xfree (matrix->rows[i].glyphs[LEFT_MARGIN_AREA]); -#else xfree (matrix->rows[i].glyphs[LEFT_MARGIN_AREA]); -#endif /* Free row structures and the matrix itself. */ xfree (matrix->rows); xfree (matrix); @@ -512,13 +508,8 @@ adjust_glyph_matrix (struct window *w, struct glyph_matrix *matrix, int x, int y while (row < end) { row->glyphs[LEFT_MARGIN_AREA] = -#ifdef HAVE_MPS - igc_xnrealloc_ambig (row->glyphs[LEFT_MARGIN_AREA], - dim.width, sizeof (struct glyph)); -#else xnrealloc (row->glyphs[LEFT_MARGIN_AREA], dim.width, sizeof (struct glyph)); -#endif /* The mode line, if displayed, never has marginal areas. */ if ((row == matrix->rows + dim.height - 1 && !(w && window_wants_mode_line (w))) @@ -1374,11 +1365,7 @@ free_glyph_pool (struct glyph_pool *pool) --glyph_pool_count; eassert (glyph_pool_count >= 0); #endif -#ifdef HAVE_MPS - igc_xfree (pool->glyphs); -#else xfree (pool->glyphs); -#endif xfree (pool); } } @@ -1409,15 +1396,9 @@ realloc_glyph_pool (struct glyph_pool *pool, struct dim matrix_dim) if (needed > pool->nglyphs) { ptrdiff_t old_nglyphs = pool->nglyphs; -#ifdef HAVE_MPS - pool->glyphs - = igc_xpalloc_ambig (pool->glyphs, &pool->nglyphs, needed - old_nglyphs, - -1, sizeof *pool->glyphs); -#else pool->glyphs = xpalloc (pool->glyphs, &pool->nglyphs, needed - old_nglyphs, -1, sizeof *pool->glyphs); -#endif memclear (pool->glyphs + old_nglyphs, (pool->nglyphs - old_nglyphs) * sizeof *pool->glyphs); @@ -2055,8 +2036,9 @@ restore_current_matrix (struct frame *f, struct glyph_matrix *saved) memcpy (to->glyphs[RIGHT_MARGIN_AREA], from->glyphs[RIGHT_MARGIN_AREA], nbytes); to->used[RIGHT_MARGIN_AREA] = from->used[RIGHT_MARGIN_AREA]; + #ifdef HAVE_MPS - xfree (from->glyphs[RIGHT_MARGIN_AREA]); + igc_xfree (from->glyphs[RIGHT_MARGIN_AREA]); #else xfree (from->glyphs[RIGHT_MARGIN_AREA]); #endif -- 2.39.2