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

Chris Torek chris at mimsy.umd.edu
Sun Feb 18 03:12:26 AEST 1990


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).

Followups directed to comp.lang.c (put them somewhere else if not talking
about the C aspects of overlapping moves, please).
-- 
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



More information about the Comp.unix.questions mailing list