From 55b7a620513dd67f3a08604f580fcfe8936e01cd Mon Sep 17 00:00:00 2001 From: Pip Cet Date: Thu, 12 Mar 2026 20:58:43 +0000 Subject: [PATCH] Don't use remote references in image cache (bug#80601) Using ambiguous references is suboptimal here, but there isn't currently a suitable type to use for arrays of raw pointers. * src/image.c (make_image_cache) [MPS]: Use 'igc_xzalloc_ambig'. (free_image_cache) [MPS]: Use 'igc_xfree'. (cache_image) [MPS]: Use 'igc_xpalloc_amig'. * src/igc.c (fix_image_cache): Removed. (dflt_scan_obj): Call to 'fix_image_cache' removed. --- src/igc.c | 23 ++--------------------- src/image.c | 17 +++++++++++++++++ 2 files changed, 19 insertions(+), 21 deletions(-) diff --git a/src/igc.c b/src/igc.c index f4e1c5e5f1d..2f73ba81c85 100644 --- a/src/igc.c +++ b/src/igc.c @@ -2011,26 +2011,6 @@ fix_image (mps_ss_t ss, struct image *i) return MPS_RES_OK; } -static mps_res_t -fix_image_cache (mps_ss_t ss, struct image_cache *c) -{ - MPS_SCAN_BEGIN (ss) - { -#ifdef HAVE_WINDOW_SYSTEM - if (c->images) - for (ptrdiff_t i = 0; i < c->used; ++i) - IGC_FIX12_RAW (ss, &c->images[i]); - - if (c->buckets) - for (ptrdiff_t i = 0; i < IMAGE_CACHE_BUCKETS_SIZE; ++i) - if (c->buckets[i]) - IGC_FIX12_RAW (ss, &c->buckets[i]); -#endif - } - MPS_SCAN_END (ss); - return MPS_RES_OK; -} - static mps_res_t fix_face (mps_ss_t ss, struct face *f) { @@ -2556,7 +2536,8 @@ dflt_scan_obj (mps_ss_t ss, mps_addr_t start) break; case IGC_OBJ_IMAGE_CACHE: - IGC_FIX_CALL_FN (ss, struct image_cache, addr, fix_image_cache); + /* FIXME/igc: image caches temporarily changed to use ambiguous + references. Going back to exact refs would be best. */ break; case IGC_OBJ_FACE: diff --git a/src/image.c b/src/image.c index e1bcb8b7703..d477d04034d 100644 --- a/src/image.c +++ b/src/image.c @@ -2215,8 +2215,13 @@ make_image_cache (void) c->size = 50; c->used = c->refcount = 0; +#ifndef HAVE_MPS c->images = xmalloc (c->size * sizeof *c->images); c->buckets = xzalloc (IMAGE_CACHE_BUCKETS_SIZE * sizeof *c->buckets); +#else + c->images = igc_xzalloc_ambig (c->size * sizeof *c->images); + c->buckets = igc_xzalloc_ambig (IMAGE_CACHE_BUCKETS_SIZE * sizeof *c->buckets); +#endif /* This value should never be encountered. */ c->scaling_col_width = -1; return c; @@ -2338,9 +2343,17 @@ free_image_cache (struct frame *f) for (i = 0; i < c->used; ++i) free_image (f, c->images[i]); +#ifdef HAVE_MPS + igc_xfree (c->images); +#else xfree (c->images); +#endif c->images = NULL; +#ifdef HAVE_MPS + igc_xfree (c->buckets); +#else xfree (c->buckets); +#endif c->buckets = NULL; #ifndef HAVE_MPS xfree (c); @@ -3687,7 +3700,11 @@ cache_image (struct frame *f, struct image *img) /* If no free slot found, maybe enlarge c->images. */ if (i == c->used && c->used == c->size) { +#ifndef HAVE_MPS c->images = xpalloc (c->images, &c->size, 1, -1, sizeof *c->images); +#else + c->images = igc_xpalloc_ambig (c->images, &c->size, 1, -1, sizeof *c->images); +#endif } /* Add IMG to c->images, and assign IMG an id. */