Make all bucket and overflow addresses unsigned
[unix-history] / usr / src / lib / libc / string / swab.c
index bf1ff94..6f9c243 100644 (file)
@@ -1,20 +1,33 @@
-#ifndef lint
-static char sccsid[] = "@(#)swab.c     5.2 (Berkeley) %G%";
-#endif not lint
-
 /*
 /*
- * Swab bytes
- * Jeffrey Mogul, Stanford
+ * Copyright (c) 1988 Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Jeffrey Mogul.
+ *
+ * %sccs.include.redist.c%
  */
 
  */
 
-swab(from, to, n)
-       register char *from, *to;
-       register int n;
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)swab.c     5.10 (Berkeley) %G%";
+#endif /* LIBC_SCCS and not lint */
+
+#include <string.h>
+
+void
+swab(from, to, len)
+       const void *from;
+       void *to;
+       size_t len;
 {
        register unsigned long temp;
 {
        register unsigned long temp;
-       
-       n >>= 1; n++;
-#define        STEP    temp = *from++,*to++ = *from++,*to++ = temp
+       register int n;
+       register char *fp, *tp;
+
+       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;