BSD 4_4 release
[unix-history] / usr / src / lib / libc / db / hash / hash_bigkey.c
index a3ac110..f24fcec 100644 (file)
@@ -1,15 +1,41 @@
 /*-
 /*-
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
+ * Copyright (c) 1990, 1993
+ *     The Regents of the University of California.  All rights reserved.
  *
  * This code is derived from software contributed to Berkeley by
  * Margo Seltzer.
  *
  *
  * This code is derived from software contributed to Berkeley by
  * Margo Seltzer.
  *
- * %sccs.include.redist.c%
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed by the University of
+ *     California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
  */
 
 #if defined(LIBC_SCCS) && !defined(lint)
  */
 
 #if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)hash_bigkey.c      5.8 (Berkeley) %G%";
+static char sccsid[] = "@(#)hash_bigkey.c      8.1 (Berkeley) 6/4/93";
 #endif /* LIBC_SCCS and not lint */
 
 /*
 #endif /* LIBC_SCCS and not lint */
 
 /*
@@ -32,7 +58,6 @@ static char sccsid[] = "@(#)hash_bigkey.c     5.8 (Berkeley) %G%";
 
 #include <sys/param.h>
 
 
 #include <sys/param.h>
 
-#include <db.h>
 #include <errno.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <errno.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -42,6 +67,7 @@ static char sccsid[] = "@(#)hash_bigkey.c     5.8 (Berkeley) %G%";
 #include <assert.h>
 #endif
 
 #include <assert.h>
 #endif
 
+#include <db.h>
 #include "hash.h"
 #include "page.h"
 #include "extern.h"
 #include "hash.h"
 #include "page.h"
 #include "extern.h"
@@ -82,7 +108,7 @@ __big_insert(hashp, bufp, key, val)
            space = FREESPACE(p) - BIGOVERHEAD) {
                move_bytes = MIN(space, key_size);
                off = OFFSET(p) - move_bytes;
            space = FREESPACE(p) - BIGOVERHEAD) {
                move_bytes = MIN(space, key_size);
                off = OFFSET(p) - move_bytes;
-               bcopy(key_data, cp + off, move_bytes);
+               memmove(cp + off, key_data, move_bytes);
                key_size -= move_bytes;
                key_data += move_bytes;
                n = p[0];
                key_size -= move_bytes;
                key_data += move_bytes;
                n = p[0];
@@ -100,7 +126,7 @@ __big_insert(hashp, bufp, key, val)
                                move_bytes = MIN(FREESPACE(p), val_size);
                                off = OFFSET(p) - move_bytes;
                                p[n] = off;
                                move_bytes = MIN(FREESPACE(p), val_size);
                                off = OFFSET(p) - move_bytes;
                                p[n] = off;
-                               bcopy(val_data, cp + off, move_bytes);
+                               memmove(cp + off, val_data, move_bytes);
                                val_data += move_bytes;
                                val_size -= move_bytes;
                                p[n - 2] = FULL_KEY_DATA;
                                val_data += move_bytes;
                                val_size -= move_bytes;
                                p[n - 2] = FULL_KEY_DATA;
@@ -124,7 +150,7 @@ __big_insert(hashp, bufp, key, val)
                if (space == val_size && val_size == val->size)
                        move_bytes--;
                off = OFFSET(p) - move_bytes;
                if (space == val_size && val_size == val->size)
                        move_bytes--;
                off = OFFSET(p) - move_bytes;
-               bcopy(val_data, cp + off, move_bytes);
+               memmove(cp + off, val_data, move_bytes);
                val_size -= move_bytes;
                val_data += move_bytes;
                n = p[0];
                val_size -= move_bytes;
                val_data += move_bytes;
                n = p[0];
@@ -258,7 +284,7 @@ __find_bigpair(hashp, bufp, ndx, key, size)
        for (bytes = hashp->BSIZE - bp[ndx];
            bytes <= size && bp[ndx + 1] == PARTIAL_KEY;
            bytes = hashp->BSIZE - bp[ndx]) {
        for (bytes = hashp->BSIZE - bp[ndx];
            bytes <= size && bp[ndx + 1] == PARTIAL_KEY;
            bytes = hashp->BSIZE - bp[ndx]) {
-               if (bcmp(p + bp[ndx], kkey, bytes))
+               if (memcmp(p + bp[ndx], kkey, bytes))
                        return (-2);
                kkey += bytes;
                ksize -= bytes;
                        return (-2);
                kkey += bytes;
                ksize -= bytes;
@@ -270,7 +296,7 @@ __find_bigpair(hashp, bufp, ndx, key, size)
                ndx = 1;
        }
 
                ndx = 1;
        }
 
-       if (bytes != ksize || bcmp(p + bp[ndx], kkey, bytes)) {
+       if (bytes != ksize || memcmp(p + bp[ndx], kkey, bytes)) {
 #ifdef HASH_STATISTICS
                ++hash_collisions;
 #endif
 #ifdef HASH_STATISTICS
                ++hash_collisions;
 #endif
@@ -412,7 +438,7 @@ __big_return(hashp, bufp, ndx, val, set_current)
                errno = EINVAL;                 /* OUT OF BUFFERS */
                return (-1);
        }
                errno = EINVAL;                 /* OUT OF BUFFERS */
                return (-1);
        }
-       bcopy((save_p->page) + off, hashp->tmp_buf, len);
+       memmove(hashp->tmp_buf, (save_p->page) + off, len);
        val->data = (u_char *)hashp->tmp_buf;
        return (0);
 }
        val->data = (u_char *)hashp->tmp_buf;
        return (0);
 }
@@ -470,7 +496,7 @@ collect_data(hashp, bufp, len, set)
                errno = EINVAL;                 /* Out of buffers. */
                return (-1);
        }
                errno = EINVAL;                 /* Out of buffers. */
                return (-1);
        }
-       bcopy((bufp->page) + bp[1], &hashp->tmp_buf[len], mylen);
+       memmove(&hashp->tmp_buf[len], (bufp->page) + bp[1], mylen);
        return (totlen);
 }
 
        return (totlen);
 }
 
@@ -532,7 +558,7 @@ collect_key(hashp, bufp, len, val, set)
                errno = EINVAL;         /* MIS -- OUT OF BUFFERS */
                return (-1);
        }
                errno = EINVAL;         /* MIS -- OUT OF BUFFERS */
                return (-1);
        }
-       bcopy((bufp->page) + bp[1], &hashp->tmp_key[len], mylen);
+       memmove(&hashp->tmp_key[len], (bufp->page) + bp[1], mylen);
        return (totlen);
 }
 
        return (totlen);
 }