Make all bucket and overflow addresses unsigned
[unix-history] / usr / src / lib / libc / string / swab.c
index dc0b9cb..6f9c243 100644 (file)
@@ -9,23 +9,25 @@
  */
 
 #if defined(LIBC_SCCS) && !defined(lint)
  */
 
 #if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)swab.c     5.7 (Berkeley) %G%";
+static char sccsid[] = "@(#)swab.c     5.10 (Berkeley) %G%";
 #endif /* LIBC_SCCS and not lint */
 
 #include <string.h>
 
 void
 #endif /* LIBC_SCCS and not lint */
 
 #include <string.h>
 
 void
-swab(from, to, n)
-       register char *from, *to;
-       register size_t n;
+swab(from, to, len)
+       const void *from;
+       void *to;
+       size_t len;
 {
        register unsigned long temp;
 {
        register unsigned long temp;
+       register int n;
+       register char *fp, *tp;
 
 
-       if (!n)
-               return;
-
-       n >>= 1; n++;
-#define        STEP    temp = *from++,*to++ = *from++,*to++ = temp
+       n = (len >> 1) + 1;
+       fp = (char *)from;
+       tp = (char *)to;
+#define        STEP    temp = *fp++,*tp++ = *fp++,*tp++ = temp
        /* round to multiple of 8 */
        while ((--n) & 07)
                STEP;
        /* round to multiple of 8 */
        while ((--n) & 07)
                STEP;