On Mon, Jan 13, 2014 at 04:44:22PM -0600, Lawrence K. Chen, P.Eng. wrote:
> Hmmm, from what I vaguely recall from my software engineering days, was
> that memcpy() didn't ever handle overlapped memory buffers and that you
> should consider memmove() in such cases.

Yes, that's correct, and in fact we're replacing all uses of memcpy()
with memmove() in upcoming releases.

Oddly enough, I benchmarked both routines in the newest version of
glibc on amd64, and found that memmove() consistently runs about 35%
faster than memcpy().  So it's both safer *and* faster.

On most platforms, memcpy() does work safely with overlapping buffers,
but the POSIX standard doesn't require it to do so, and you're not
supposed to rely on it.  We had a coding error that caused such a
copy, but there were no bad effects, so we missed it --  until glibc
changed their memcpy() and revealed our mistake.

(And we would've gotten away with it, too, if it wasn't for those
meddling kids.)

-- 
Evan Hunt -- e...@isc.org
Internet Systems Consortium, Inc.
_______________________________________________
Please visit https://lists.isc.org/mailman/listinfo/bind-users to unsubscribe 
from this list

bind-users mailing list
bind-users@lists.isc.org
https://lists.isc.org/mailman/listinfo/bind-users

Reply via email to