- It's important not to let the string get below the threshold
- for making big strings and still remain malloc()ed; if that
- were the case, repeated calls to this function on the same
- string could result in memory leakage. */
- set_string_data (s, (Bufbyte *) xrealloc (string_data (s),
- newfullsize));
+ if (pos >= 0)
+ {
+ memcpy (new_data, old_data, pos);
+ memcpy (new_data + pos + delta, old_data + pos,
+ string_length (s) + 1 - pos);
+ }
+ set_string_data (s, new_data);
+ xfree (old_data);
+ }
+ }
+ else /* old string is small */
+ {
+ if (oldfullsize == newfullsize)
+ {
+ /* special case; size change but the necessary
+ allocation size won't change (up or down; code
+ somewhere depends on there not being any unused
+ allocation space, modulo any alignment
+ constraints). */