How does memory overlap occur and how is it controlled?

While I read about memmove, I read that it can handle MEMORY OVERLAPS , but I can’t understand how memmory overlap can occur between two lines and how this function can copy a memory block correctly.

+6
c memmove
source share
2 answers

“Overlapping memory” does not occur by itself. You can provide a memmove function with areas of memory that overlap. Take two pointers into the same array, and you can easily get overlapping memory areas.

Of course, you can also easily create overlapping objects through joins.

It is not clear what you mean by the second part of the question ("how can this function copy the memory block correctly"). Where do you see the problem here?

+5
source share
  memmove(p+1, p, 42); 

This requires moving bytes from the end. Memcpy () makes a mess.

+3
source share

All Articles