memcpy != bcopy (Was Re: bcopy() bzero())
Peter Rowell
peter at thirdi.UUCP
Mon Feb 12 11:43:15 AEST 1990
echarne at orion.oac.uci.edu (Eli B. Charne) writes:
>larryd1 at attctc.Dallas.TX.US (Larry Clark) writes:
>> I'm porting sources from the bsd world into a Sys V environment
>> and need an explanation of bcopy() and bzero().
>> ....
> ...
> bcopy() Copies length bytes from the "string" b1, and copies them into
> string b2. I was under the impression this was exactly what memcpy()
> does, but perhaps the order of arguments is changed.
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.
More information about the Comp.unix.questions
mailing list