Memmove not moving

memmove doesn't really move memory, does it? It simply copies memory from one region to another and allows these two regions to intersect. I ask this question because I just want to know why this fnc is called a very misleading way.
For I understand that when something moves from one place to another, the “thing” after this operation happens in another place, and not in the first. And with memmove this does not work. I'm right?

+3
source share
7 answers

You are right, he copies it. However, there is a difference between memmoveand memcpy, because it memmovecan correctly handle the case when the buffers overlap, so it is recommended to use them in these cases.

However, due to additional checks performed memmovewhen the buffers are small and, of course, do not overlap, memcpybetter.

+9
source

memcpy() memmove() , memmove() , . memmove() , . memcpy() . , , , . , , memcpy() , , , memmove(). memcpy() memmove().

, src dst , memcpy(). , , memmove().

+6

, , , do, , , . . memmove, memcpy, , , . : , .

+5
+4

, memmove memcpy . , , ( ), , , "" ( ) - , .

+3

, memmove - . "" , , . .

, , , :

  • memcpy;
  • , , , , ( ).
+3

memmove() name: , (, ).

, memcpy() , memmove(), memcpy() , , memmove().

, , , , , - memmove() memcpy() , , . memcpy() ( , , ), memcpy() Linux C memcpy():

In the kernel, the optimized x86 memcpy that we use is actually memmove (), because although performance is really important, it is repeatability and avoiding surprises (strictly speaking, we have two versions: “rep movs” for the case where this is should be fast and open source. The version of "rep movs" has only transitions and does not handle overlapping areas).

0
source

Source: https://habr.com/ru/post/1781064/


All Articles