/* An abstract string datatype.
- Copyright (C) 1998, 1999, 2000, 2002, 2004 Free Software Foundation, Inc.
+ Copyright (C) 1998-2024 Free Software Foundation, Inc.
Contributed by Mark Mitchell (mark@markmitchell.com).
This file is part of GNU CC.
if (ds_struct_ptr->s == NULL)
return 0;
#else
- ds_struct_ptr->s = (char *) xmalloc (space);
+ ds_struct_ptr->s = XNEWVEC (char, space);
#endif
ds_struct_ptr->allocated = space;
ds_struct_ptr->length = 0;
return NULL;
}
#else
- result = (dyn_string_t) xmalloc (sizeof (struct dyn_string));
+ result = XNEW (struct dyn_string);
dyn_string_init (result, space);
#endif
return result;
return NULL;
}
#else
- ds->s = (char *) xrealloc (ds->s, ds->allocated);
+ ds->s = XRESIZEVEC (char, ds->s, ds->allocated);
#endif
}
for (i = dest->length; i >= pos; --i)
dest->s[i + length] = dest->s[i];
/* Splice in the new stuff. */
- strncpy (dest->s + pos, src, length);
+ memcpy (dest->s + pos, src, length);
/* Compute the new length. */
dest->length += length;
return 1;
return 1;
}
-/* Appends C to the end of DEST. Returns 1 on success. On failiure,
+/* Appends C to the end of DEST. Returns 1 on success. On failure,
if RETURN_ON_ALLOCATION_FAILURE, deletes DEST and returns 0. */
int