*BSD News Article 38859


Return to BSD News archive

Xref: sserve comp.unix.bsd:15428 comp.lang.c:86884 comp.unix.sys5.r3:2297
Newsgroups: comp.unix.bsd,comp.lang.c,comp.unix.sys5.r3
Path: sserve!newshost.anu.edu.au!harbinger.cc.monash.edu.au!bunyip.cc.uq.oz.au!munnari.oz.au!spool.mu.edu!howland.reston.ans.net!gatech!udel!news.mathworks.com!news.alpha.net!mvb.saic.com!eskimo!scs
From: scs@eskimo.com (Steve Summit)
Subject: Re: how to completely get rid of bcopy, bzero, bcmp?
Message-ID: <D07294.5MJ@eskimo.com>
Organization: only when absolutely necessary
References: <3bksus$fg4@spruce.cic.net> <3bmo74$oan@detroit.freenet.org>
Date: Fri, 2 Dec 1994 17:36:34 GMT
Lines: 32

In article <3bmo74$oan@detroit.freenet.org>, Karl Brose
(brose@detroit.freenet.org) writes:
> Paul Southworth (pauls@locust.cic.net) wrote:
>> Is there a "right" way to implement bcopy() etc on this system so I could
>> generate my own compatibility library and not bother with altering the
>> code every time?
> 
> #define bcopy(a,b,n)	memcpy((b),(a),(n))

Safer would be

	#define bcopy(a,b,n) memmove((b),(a),(n))

, since later versions of BSD bcopy() allowed overlap, and many
programs are likely to rely on it.

(I would probably write the macro as 

	#define bcopy(src, dest, n) memmove(dest, src, n)

to make the deliberate argument swap self-documenting.)

As an aside to the original poster: I don't know what code you're
having to "alter every time," but I would strongly recommend
changing the source code once and for all to use the ANSI
Standard mem* routines directly.  Most environments should
support them by now; on those few that don't, you could use a
header file or auxiliary library to implement them (perhaps in
terms of bcopy et al).

					Steve Summit
					scs@eskimo.com