Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cs.utexas.edu!samsung!rex!cleeland From: cleeland@rex.cs.tulane.edu (Chris Cleeland) Newsgroups: comp.unix.questions Subject: Re: memcpy != bcopy (Was Re: bcopy() bzero()) Message-ID: <2177@rex.cs.tulane.edu> Date: 12 Feb 90 04:55:55 GMT References: <11387@attctc.Dallas.TX.US> <4601@orion.cf.uci.edu> <497@thirdi.UUCP> Reply-To: cleeland@rex.UUCP (Chris Cleeland) Distribution: usa Organization: Computer Science Dept., Tulane Univ., New Orleans, LA Lines: 24 Summary: Expires: Sender: Followup-To: Keywords: In article <497@thirdi.UUCP> peter@thirdi.UUCP (Peter Rowell) writes: >echarne@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@rex.cs.tulane.edu | USnail: 1320 Lowerline, Apt. E UUCP: cleeland@rex.UUCP | New Orleans, LA 70118 Disclaimer: "I'm a student -- I can't afford one!"