creallocmemmove

If destination and source are the same, what does memmove do?


If destination and source are the same, does memmove still "move" the data (or does it return directly)? What about realloc; what if the new size is the same as the old size?


Solution

  • That's really going to be implementation-specific. It would be good practice to do so, sure, but it really depends which implementation you mean.

    It's going to work either way, but presumably a suitably clever implementation would check for overlapping segments (and particularly for the case where source == dest) and deal with it appropriately.