[PATCH] Use memcpy() rather than strcpy() in strdup()

Erik Andersen andersen at codepoet.org
Wed Oct 18 10:16:28 PDT 2006


On Wed Oct 18, 2006 at 11:15:18AM +0200, Peter Kjellerstedt wrote:
> Does anyone have any objections to me applying the attached patch?
> It makes strdup() use memcpy() rather than strcpy() to duplicate
> the string.  The rationale is that we already have the length of
> the string to duplicate (from doing the malloc()), and I believe
> memcpy() should then always be faster than strcpy() (or at least
> as fast).

Seems reasonable and more efficient.  Plus memcpy is more
likely to have an arch optimized implementation.

 -Erik

--
Erik B. Andersen             http://codepoet-consulting.com/
--This message was written using 73% post-consumer electrons--


More information about the uClibc mailing list