bcmp.c revision 33965
1192886Sedwin/* bcmp
2223629Sedwin   This function is in the public domain.  */
3192886Sedwin
4192886Sedwin/*
558787Sru
619874SwollmanNAME
719874Swollman
8149514Swollman	bcmp -- compare two memory regions
919874Swollman
1019874SwollmanSYNOPSIS
1137998Sdes
1219874Swollman	int bcmp (char *from, char *to, int count)
1319874Swollman
1419874SwollmanDESCRIPTION
1519874Swollman
1619874Swollman	Compare two memory regions and return zero if they are identical,
1719874Swollman	non-zero otherwise.  If count is zero, return zero.
1886222Swollman
1919874SwollmanNOTES
2019874Swollman
2119874Swollman	No guarantee is made about the non-zero returned value.  In
2219874Swollman	particular, the results may be signficantly different than
2319874Swollman	strcmp(), where the return value is guaranteed to be less than,
2419874Swollman	equal to, or greater than zero, according to lexicographical
2519874Swollman	sorting of the compared regions.
2619874Swollman
2719874SwollmanBUGS
2819874Swollman
2919874Swollman*/
3019874Swollman
3119874Swollman
3219874Swollmanint
3319874Swollmanbcmp (from, to, count)
3419874Swollman  char *from, *to;
3519874Swollman  int count;
3619874Swollman{
3719874Swollman  int rtnval = 0;
38114173Swollman
3937998Sdes  while (count-- > 0)
4037998Sdes    {
4143014Swollman      if (*from++ != *to++)
4219874Swollman	{
43213312Sedwin	  rtnval = 1;
44171948Sedwin	  break;
4558787Sru	}
46205475Sedwin    }
47136638Swollman  return (rtnval);
48184406Sedwin}
49184406Sedwin
50136638Swollman