diff --git a/src/dispnew.c b/src/dispnew.c index b37c8a825ac..15d3c2a599a 100644 --- a/src/dispnew.c +++ b/src/dispnew.c @@ -257,7 +257,8 @@ static struct glyph_matrix * new_glyph_matrix (struct glyph_pool *pool) { #ifdef HAVE_MPS - struct glyph_matrix *result = igc_alloc_glyph_matrix (); + struct glyph_matrix *result + = pool ? xzalloc (sizeof *result) : igc_alloc_glyph_matrix (); #else struct glyph_matrix *result = xzalloc (sizeof *result); #endif @@ -306,7 +307,10 @@ free_glyph_matrix (struct glyph_matrix *matrix) /* Free row structures and the matrix itself. */ xfree (matrix->rows); #ifdef HAVE_MPS - igc_xfree (matrix); + if (matrix->pool == NULL) + igc_xfree (matrix); + else + xfree (matrix); #else xfree (matrix); #endif @@ -1357,7 +1361,11 @@ row_equal_p (struct glyph_row *a, struct glyph_row *b, bool mouse_face_p) static struct glyph_pool * ATTRIBUTE_MALLOC new_glyph_pool (void) { +#ifdef HAVE_MPS + struct glyph_pool *result = igc_alloc_glyph_pool (); +#else struct glyph_pool *result = xzalloc (sizeof *result); +#endif #if defined GLYPH_DEBUG && defined ENABLE_CHECKING /* For memory leak and double deletion checking. */ @@ -1386,7 +1394,11 @@ free_glyph_pool (struct glyph_pool *pool) eassert (glyph_pool_count >= 0); #endif xfree (pool->glyphs); +#ifdef HAVE_MPS + igc_xfree (pool); +#else xfree (pool); +#endif } } diff --git a/src/igc.c b/src/igc.c index ecd9c325d7b..ab0fe1d4c71 100644 --- a/src/igc.c +++ b/src/igc.c @@ -2832,6 +2832,7 @@ fix_glyph_array (mps_ss_t ss, size_t len, struct glyph array[len]) static mps_res_t fix_glyph_matrix (mps_ss_t ss, struct glyph_matrix *matrix) { + igc_assert (matrix->pool == NULL); MPS_SCAN_BEGIN (ss) { struct glyph_row *row = matrix->rows; @@ -2898,10 +2899,12 @@ fix_frame (mps_ss_t ss, struct frame *f) IGC_FIX12_OBJ (ss, &f->conversion.field); #endif +#if 0 if (f->current_pool) IGC_FIX_CALL (ss, fix_glyph_pool (ss, f->current_pool)); if (f->desired_pool) IGC_FIX_CALL (ss, fix_glyph_pool (ss, f->desired_pool)); +#endif } MPS_SCAN_END (ss); return MPS_RES_OK; @@ -4320,6 +4323,22 @@ igc_alloc_glyph_matrix (void) return m; } +static mps_res_t +scan_glyph_pool (mps_ss_t ss, void *start, void *end, void *closure) +{ + struct glyph_pool *p = start; + return fix_glyph_pool (ss, p); +} + +struct glyph_pool * +igc_alloc_glyph_pool (void) +{ + struct glyph_pool *p = xzalloc (sizeof *p); + root_create_exact (global_igc, p, p + 1, scan_glyph_pool, + "glyph_pool"); + return p; +} + static void finalize_font (struct font *font) { diff --git a/src/igc.h b/src/igc.h index a8eb0080fb8..487e4d5f984 100644 --- a/src/igc.h +++ b/src/igc.h @@ -82,6 +82,7 @@ Lisp_Object *igc_xnrealloc_lisp_objs_exact (ptrdiff_t nitems_old, struct kboard *igc_alloc_kboard (void); struct hash_table_user_test *igc_alloc_hash_table_user_test (void); struct glyph_matrix *igc_alloc_glyph_matrix (void); +struct glyph_pool *igc_alloc_glyph_pool (void); struct Lisp_Vector *igc_alloc_pseudovector (size_t nwords_mem, size_t nwords_lisp,