cmemmove

What's the difference between memmove and bcopy?


I understand the difference between memcpy and memmove: memmove handles the overlapping of src and dst. I checked the man page for bcopy and it seems to also handle overlapping. So I'm wondering if there is any difference between memmove and bcopy?


Solution

  • bcopy and memmove do exactly the same thing. However, they take arguments in a different order: bcopy(src, dest, n) vs memmove(dest, src, n). So they can't be two names for the same function.

    Historically, bcopy is the older of the two; it was present in 3BSD if memory serves. memmove was invented by the C committee in 1988 or so.

    New code should use memmove, as it is required by the C standard and therefore more portable than bcopy.