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.
This commit is contained in:
Helmut Eller 2026-03-21 20:54:22 +01:00
parent 9da485befc
commit cb338ddf0b
5 changed files with 15 additions and 10 deletions

View file

@ -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);
}

View file

@ -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

View file

@ -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);

View file

@ -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,

View file

@ -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