Re: str_repeat() patch
| From: | Michael Walter | Date: | Sun, 13 Jun 2004 12:55:31 +0000 |
| Subject: | Re: str_repeat() patch | ||
| References: | 1 2 3 4 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-10418@lists.php.net to get a copy of this message | ||
Well, surely memmove() needs an additional branch to check for overlapping, though (the OP was wrong in that memmove() would need a temporary buffer, though - it doesn't, it usually copies from high addres to low in the overlapping case).
Cheers,
Michael
George Schlossnagle wrote:
On Jun 12, 2004, at 10:27 AM, Alexander Valyalkin wrote:On Fri, 11 Jun 2004 17:00:03 +0200 (CEST), Derick Rethans <derick@php.net> wrote:That's not what my glibc sources look like. GeorgeOn Fri, 11 Jun 2004, Alexander Valyalkin wrote:Mybe I'm mistaken, but I think, that memmove() looks like that (without any error checks):Read it: void *memmove(void *s1, const void *s2, size_t n); If s1 and s2 overlap, all bytes are copied in a preserving manner (unlike memcpy()) And anwer the question: are s1 and s2 overlap in the str_repeat() ? Why don't use memcpy() instead of memmove() ?Because it's slower and we're copying to newly allocated memory anyway so things CAN not overlap. Also, your patch is the wrong way around.