Mail Archives: djgpp-workers/1998/03/17/08:06:42
See original message (Nearly same subject). bcmp is only a modified
memcmp. I haven't benchmarked it -- it shouldn't be significantly
different. I have, of course, tested it.
- Burton Radons, loth AT gec DOT net
Vancouver Island, British Columbia, Canada
*** src/new/bcmp.c Tue Mar 17 04:42:48 1998
--- src/libc/compat/bsd/bcmp.c Wed Aug 23 00:56:02 1995
***************
*** 1,4 ****
! /* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */
#include <string.h>
#undef bcmp
--- 1,4 ----
! /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
#include <string.h>
#undef bcmp
***************
*** 12,45 ****
if (ptr1 == 0 || ptr2 == 0)
return -1;
! if (length != 0)
{
! const unsigned char *p1 = ptr1;
! const unsigned char *p2 = ptr2;
!
! while (length > 4) {
! if (*((int *) p1) != *((int *) p2)) {
! if (*((short *) p1) != *((short *) p2)) {
! if (*p1 != *p2)
! return length;
!
! return length - 1;
! }
!
! if (p1[2] != p2[2])
! return length - 2;
!
! return length - 3;
! }
!
! p1 += 4;
! p2 += 4;
! length -= 4;
! }
!
! for (; length; length --)
! if (*p1++ != *p2++)
! return length;
}
return 0;
--- 12,22 ----
if (ptr1 == 0 || ptr2 == 0)
return -1;
! while (length)
{
! if (*((const char *)ptr1)++ != *((const char *)ptr2)++)
! return length;
! length--;
}
return 0;
- Raw text -