[comp.unix.questions] Memcpy definition wanted

netnews@psc90.UUCP (Remote mail paths) (02/01/89)

Hi,
	I am looking for the definition for memcpy. For example, strchr in
BSD is rindex, and strrchr is rrindex. What is the term that BSD uses?
Below is an excerpt from the program that came over comp.sources.unix that
creates the man pages when you type "man ..."

	Thanks,
		--Deryk

UUCP: !uunet!unh!psc90!netnews
      !dartvax!psc90!netnews

BITNET: D_MARIEN@UNHH

------------------------------------
    int pid, status, i;
    char *path, *savepath, *c;
    struct fileinfo *finfo;
    int (*saveintr)();
    static char cmdbuf[LBUFLEN], buf[BUFLEN];
    extern char *getenv(), *strcat(), *strcpy(), *memcpy();

andyb@coat.uucp (Andy Behrens) (02/03/89)

In article <801@psc90.UUCP> netnews@psc90.UUCP writes:
>  I am looking for the definition for memcpy. For example, strchr in
>  BSD is rindex, and strrchr is rrindex. What is the term that BSD uses?

This table shows the correspondences between the SYS V and the Berkeley
byte-string operations.  Note the parameters to bcopy: they're
backwards from what you'd expect!

		SYS V				BSD
	---------------------------	-------------------------
	memcpy(dst,src,length)		bcopy(src,dst,length)

	memset(dst,0,length)		bzero(dst,length)		

	memcmp(str1,str2,length)==0	bcmp(str1,str2,length)==0	

There are a few small differences between the two sets of functions.

- The BSD routines want "length" to be an unsigned int.  
- Memcpy and memset return a pointer to dst, while bcopy and bzero do
	not return a value.  
- Memcmp can be used for "greater than" and "less than" comparisons, 
	while bcmp only tells you if two strings are identical, without 
	telling which is greater.  
- Memset can be used to set bytes to a value other than zero.

See the memory(3C) or bstring(3) man pages for all the details.

--
Live justly, love gently, walk humbly.
					Andy Behrens
					andyb@coat.uucp

internet: andyb%coat@dartmouth.edu
uucp:     {harvard,decvax}!dartvax!coat!andyb
Burlington Coat, PO Box 729, Lebanon, N.H. 03766	(603) 448-5000

guy@auspex.UUCP (Guy Harris) (02/04/89)

>This table shows the correspondences between the SYS V and the Berkeley
>byte-string operations.

Note that 4.3BSD has all the "mem*" routines in "libc" (straightforward
C implementations, alas, not optimized ones).