/* * b l k c m p . c */ /*)LIBRARY */ #ifdef DOCUMENTATION title blkcmp Compare Two Blocks of Memory index Compare two blocks of memory synopsis blkcmp(a,b,nbytes) char *a; char *b; unsigned nbytes; description blkcmp compares two blocks of memory, each nbytes long. Like strcmp, it returns: -1 a < b 0 a == b +1 a > b where the comparison is lexicographical (as for strcmp). Zero bytes have no special meaning to blkcmp() and are compared along with everything else. bugs author Jerry Leichter #endif /* )EDITLEVEL=05 * Edit history * 0.0 18-Jun-81 JSL Invention * 0.1 23-Jun-81 JSL nbytes should be unsigned */ blkcmp(a,b,nbytes) register char *a; register char *b; unsigned nbytes; { register int comp; while (nbytes-- > 0) { if ((comp = *a++ - *b++) > 0) return(1); else if (comp < 0) return(-1); } return(0); }