memcpy != bcopy (Was Re: bcopy() bzero())
Chris Cleeland
cleeland at rex.cs.tulane.edu
Mon Feb 12 15:55:55 AEST 1990
In article <497 at thirdi.UUCP> peter at thirdi.UUCP (Peter Rowell) writes:
>echarne at orion.oac.uci.edu (Eli B. Charne) writes:
>
>WARNING! memcpy is NOT the same as bcopy!!!!
>This is the source of an *amazing* array of hard-to-find bugs!
>bcopy correctly handles overlapping memory moves; memcpy does not.
>
>If you code does not expect/require (either deliberately or accidentally)
>that overlapping moves be done correctly, then it is "safe" to claim
>the two are equivalent.
>
>PS. the first two arguments to bcopy are reversed in memcpy.
What he said.
Also, though, memmove() *does* properly handle overlapping areas (at
least according to K&R2 -- my system has bcopy). Parameters are the
same as memcopy()
--
--------------------------------------+--------------------------------------
Chris Cleeland | BELL: (504) 866-8186
INET: cleeland at rex.cs.tulane.edu | USnail: 1320 Lowerline, Apt. E
UUCP: cleeland at rex.UUCP | New Orleans, LA 70118
Disclaimer: "I'm a student -- I can't afford one!"
More information about the Comp.unix.questions
mailing list