/* Extra room for expansion due to replacing ‘\[]’ with ‘M-x ’. */
enum { EXTRA_ROOM = sizeof "M-x " - sizeof "\\[]" };
+ ptrdiff_t count = SPECPDL_INDEX ();
+
if (bsize <= sizeof sbuf - EXTRA_ROOM)
{
abuf = NULL;
bsize = sizeof sbuf;
}
else
- buf = abuf = xpalloc (NULL, &bsize, EXTRA_ROOM, STRING_BYTES_BOUND, 1);
+ {
+ buf = abuf = xpalloc (NULL, &bsize, EXTRA_ROOM, STRING_BYTES_BOUND, 1);
+ record_unwind_protect_ptr (xfree, abuf);
+ }
bufp = buf;
strp = SDATA (str);
abuf = xpalloc (abuf, &bsize, need - avail,
STRING_BYTES_BOUND, 1);
if (buf == sbuf)
- memcpy (abuf, sbuf, offset);
+ {
+ record_unwind_protect_ptr (xfree, abuf);
+ memcpy (abuf, sbuf, offset);
+ }
+ else
+ set_unwind_protect_ptr (count, xfree, abuf);
buf = abuf;
bufp = buf + offset;
}
}
else
tem = string;
- xfree (abuf);
- return tem;
+ return unbind_to (count, tem);
}
\f
void