memcpy != bcopy (Was Re: bcopy() bzero())

Kannan Konath konath at sj.ate.slb.com
Sat Feb 24 09:53:58 AEST 1990


In article <22599 at mimsy.umd.edu> chris at mimsy.umd.edu (Chris Torek) writes:
>In article <497 at thirdi.UUCP> peter at thirdi.UUCP (Peter Rowell) 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.
>
>Beware: some versions of bcopy() do, some do not.  (4.2BSD VAX bcopy()
>handled overlap when copying 65535 bytes or less or when forward block
>moves were correct.  4.3BSD VAX bcopy() always handles overlap.)
>
>For absolute safety, use memmove() (a feature of ANSI X3.159 C).

In the VAX-VMS-C manual,  it states that memmove() has exactly the same
functionality as  memcpy().  Does that mean memmove() does not handle
overlapped moves or does that mean memcpy() handles overlapped moves.
This problem arose when bcopy() was used in a program that was being
ported to the VMS environemnt.  I am not involved in the porting
directly but when going through the semantics of the different block
copy and block move instructions in the Harbison-Steele manual and the
VMS-C manual I noticed this was not stated explicitly in the latter.  


>In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163)
>Domain:	chris at cs.umd.edu	Path:	uunet!mimsy!chris


kannan
konath at sj.ate.slb.com



More information about the Comp.lang.c mailing list