memcpy verses memmove

R

Ruslan Abdikeev

What is the difference between memcpy and memmove? Which is more
expensive?

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.
 
G

Gianni Mariani

What is the difference between memcpy and memmove? Which is more
expensive?

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,262
Messages
2,571,056
Members
48,769
Latest member
Clifft

Latest Threads

Top