Connecting Tech Pros Worldwide Help | Site Map

memcpy verses memmove

  #1  
Old July 23rd, 2005, 01:51 AM
rinku24@yahoo.com
Guest
 
Posts: n/a
What is the difference between memcpy and memmove? Which is more
expensive?

  #2  
Old July 23rd, 2005, 01:51 AM
Gianni Mariani
Guest
 
Posts: n/a

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.
  #3  
Old July 23rd, 2005, 01:51 AM
Ruslan Abdikeev
Guest
 
Posts: n/a

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 Threads
Thread Thread Starter Forum Replies Last Post
difference for array in c and c++? anto frank answers 45 September 28th, 2007 09:25 PM