Connecting Tech Pros Worldwide Help | Site Map

memcpy verses memmove

rinku24@yahoo.com
Guest
 
Posts: n/a
#1: Jul 23 '05
What is the difference between memcpy and memmove? Which is more
expensive?

Gianni Mariani
Guest
 
Posts: n/a
#2: Jul 23 '05

re: memcpy verses memmove


rinku24@yahoo.com wrote:[color=blue]
> What is the difference between memcpy and memmove? Which is more
> expensive?
>[/color]

memmove is ever so slightly more expensive because it does a check of
wether it needs to do a copy forward or copy backward.

On some systems, memcpy is the same routine as memmove.
Ruslan Abdikeev
Guest
 
Posts: n/a
#3: Jul 23 '05

re: memcpy verses memmove


<rinku24@yahoo.com> wrote in message
news:1108348259.203256.55320@o13g2000cwo.googlegro ups.com...[color=blue]
> What is the difference between memcpy and memmove? Which is more
> expensive?[/color]

memcpy expects that source and destination areas do not overlap.
It is undefined behaviour to give memcpy overlapping areas (and in C99,
memcpy has "restrict" qualifiers on both sides).
memmove behaves correctly in case of overlapping areas, but it is
potentially more expensive.

Hope it helps,
Ruslan Abdikeev.


Closed Thread


Similar C / C++ bytes