From cb338ddf0b1ca1967f19e967e58340a7044bbb29 Mon Sep 17 00:00:00 2001 From: Helmut Eller Date: Sat, 21 Mar 2026 20:54:22 +0100 Subject: [PATCH] Require labels for igc_xpalloc_ambig * src/igc.h (igc_xpalloc_ambig): Add label parameter. * src/igc.c (igc_xpalloc_ambig): Add label parameter. (ensure_free_pin): Add label argument. * src/bidi.c (bidi_cache_ensure_space): Add label argument. * src/buffer.c (overlays_in, record_overlay_string): Add label argument. * src/term.c (tty_menu_make_room): Add label argument. --- src/bidi.c | 2 +- src/buffer.c | 6 ++++-- src/igc.c | 12 +++++++----- src/igc.h | 2 +- src/term.c | 3 ++- 5 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/bidi.c b/src/bidi.c index e602d1392bb..7ab0d8f7209 100644 --- a/src/bidi.c +++ b/src/bidi.c @@ -810,7 +810,7 @@ bidi_cache_ensure_space (ptrdiff_t idx) bidi_cache = igc_xpalloc_ambig (bidi_cache, &bidi_cache_size, max (chunk_size, idx - bidi_cache_size + 1), - max_elts, elsz); + max_elts, elsz, "bidi_cache"); #endif eassert (bidi_cache_size > idx); } diff --git a/src/buffer.c b/src/buffer.c index ed5675cd713..8ac8ea2bf11 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -3155,7 +3155,7 @@ overlays_in (ptrdiff_t beg, ptrdiff_t end, bool extend, { #ifdef HAVE_MPS vec = igc_xpalloc_ambig (vec, len_ptr, 1, OVERLAY_COUNT_MAX, - sizeof *vec); + sizeof *vec, "overlays_in"); #else vec = xpalloc (vec, len_ptr, 1, OVERLAY_COUNT_MAX, sizeof *vec); @@ -3444,7 +3444,9 @@ record_overlay_string (struct sortstrlist *ssl, Lisp_Object str, #ifdef HAVE_MPS /* Never freed. */ eassert (ssl == &overlay_heads || ssl == &overlay_tails); - ssl->buf = igc_xpalloc_ambig (ssl->buf, &ssl->size, 5, -1, sizeof *ssl->buf); + ssl->buf = igc_xpalloc_ambig (ssl->buf, &ssl->size, 5, -1, + sizeof *ssl->buf, + "record_overlay_string"); #else ssl->buf = xpalloc (ssl->buf, &ssl->size, 5, -1, sizeof *ssl->buf); #endif diff --git a/src/igc.c b/src/igc.c index 881db21be82..9b6a3f9e7e3 100644 --- a/src/igc.c +++ b/src/igc.c @@ -1016,7 +1016,7 @@ ensure_free_pin (struct igc_pins *p) { const ptrdiff_t used = p->capacity; p->entries = igc_xpalloc_ambig (p->entries, &p->capacity, 1, -1, - sizeof *p->entries); + sizeof *p->entries, "igc_pin[]"); for (ptrdiff_t i = used; i < p->capacity; ++i) { p->entries[i].next_free = p->free; @@ -4025,8 +4025,9 @@ igc_xfree (void *p) } void * -igc_xpalloc_ambig (void *old_pa, ptrdiff_t *nitems, ptrdiff_t nitems_incr_min, - ptrdiff_t nitems_max, ptrdiff_t item_size) +igc_xpalloc_ambig (void *old_pa, ptrdiff_t *nitems, + ptrdiff_t nitems_incr_min, ptrdiff_t nitems_max, + ptrdiff_t item_size, const char *label) { ptrdiff_t old_nitems = old_pa ? *nitems : 0; ptrdiff_t new_nitems = *nitems; @@ -4034,10 +4035,11 @@ igc_xpalloc_ambig (void *old_pa, ptrdiff_t *nitems, ptrdiff_t nitems_incr_min, nitems_max, item_size); void *new_pa = xzalloc (nbytes); char *end = (char *) new_pa + nbytes; - root_create_ambig (global_igc, new_pa, end, "xpalloc-ambig"); + root_create_ambig (global_igc, new_pa, end, label); mps_word_t *old_word = old_pa; mps_word_t *new_word = new_pa; - for (ptrdiff_t i = 0; i < (old_nitems * item_size) / sizeof (mps_word_t); i++) + for (ptrdiff_t i = 0; + i < (old_nitems * item_size) / sizeof (mps_word_t); i++) new_word[i] = old_word[i]; *nitems = new_nitems; igc_xfree (old_pa); diff --git a/src/igc.h b/src/igc.h index a3598d547a6..52bf84421dd 100644 --- a/src/igc.h +++ b/src/igc.h @@ -63,7 +63,7 @@ void * igc_xalloc_raw_exact (size_t n); void *igc_xpalloc_ambig (void *pa, ptrdiff_t *nitems, ptrdiff_t nitems_incr_min, ptrdiff_t nitems_max, - ptrdiff_t item_size); + ptrdiff_t item_size, const char *label); void *igc_xpalloc_raw_exact (void *pa, ptrdiff_t *nitems, ptrdiff_t nitems_incr_min, diff --git a/src/term.c b/src/term.c index 6c2d8ac664b..8f480148c94 100644 --- a/src/term.c +++ b/src/term.c @@ -3094,7 +3094,8 @@ tty_menu_make_room (tty_menu *menu) ptrdiff_t allocated = menu->allocated; #ifdef HAVE_MPS /* The text and help_text can point to Lisp string data. */ - menu->text = igc_xpalloc_ambig (menu->text, &allocated, 1, -1, sizeof *menu->text); + menu->text = igc_xpalloc_ambig (menu->text, &allocated, 1, -1, + sizeof *menu->text, "menu-text"); menu->help_text = igc_realloc_ambig (menu->help_text, allocated * sizeof *menu->help_text); #else