home *** CD-ROM | disk | FTP | other *** search
/ PC Extra Super CD 1998 January / PCPLUS131.iso / DJGPP / V2 / DJLSR201.ZIP / src / libc / compat / bsd / bcmp.c next >
Encoding:
C/C++ Source or Header  |  1995-08-23  |  396 b   |  24 lines

  1. /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
  2. #include <string.h>
  3.  
  4. #undef bcmp
  5.  
  6. int
  7. bcmp(const void *ptr1, const void *ptr2, int length)
  8. {
  9.   if (ptr1 == ptr2)
  10.     return 0;
  11.  
  12.   if (ptr1 == 0 || ptr2 == 0)
  13.     return -1;
  14.  
  15.   while (length)
  16.   {
  17.     if (*((const char *)ptr1)++ != *((const char *)ptr2)++)
  18.       return length;
  19.     length--;
  20.   }
  21.  
  22.   return 0;
  23. }
  24.