This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: patch to clean out savestring, copystr, mybzero and mybcopy
- To: "Kaveh R. Ghazi" <ghazi at caip dot rutgers dot edu>
- Subject: Re: patch to clean out savestring, copystr, mybzero and mybcopy
- From: Richard Henderson <rth at cygnus dot com>
- Date: Tue, 12 Jan 1999 22:33:48 -0800
- Cc: egcs-patches at cygnus dot com
- References: <199901121542.KAA25589@caip.rutgers.edu>
- Reply-To: Richard Henderson <rth at cygnus dot com>
On Tue, Jan 12, 1999 at 10:42:19AM -0500, Kaveh R. Ghazi wrote:
> Here is a new copy of the patch. Okay to install?
Yes. One comment though --
> +xstrdup (input)
> + const char *input;
> {
> + register char *output = xmalloc (strlen (input) + 1);
> strcpy (output, input);
> return output;
> }
This is better implemented
size_t len = strlen (input) + 1;
char *output = xmalloc (len);
return memcpy (output, input, len);
In this way we only search for the null terminator once.
r~