summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/libc/db/hash/hash_page.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/lib/libc/db/hash/hash_page.c b/lib/libc/db/hash/hash_page.c
index 1e9a66c9f0a..7a01277657e 100644
--- a/lib/libc/db/hash/hash_page.c
+++ b/lib/libc/db/hash/hash_page.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: hash_page.c,v 1.9 2002/02/01 18:17:36 millert Exp $ */
+/* $OpenBSD: hash_page.c,v 1.10 2002/02/01 18:18:08 millert Exp $ */
/*-
* Copyright (c) 1990, 1993, 1994
@@ -40,7 +40,7 @@
#if 0
static char sccsid[] = "@(#)hash_page.c 8.7 (Berkeley) 8/16/94";
#else
-static char rcsid[] = "$OpenBSD: hash_page.c,v 1.9 2002/02/01 18:17:36 millert Exp $";
+static char rcsid[] = "$OpenBSD: hash_page.c,v 1.10 2002/02/01 18:18:08 millert Exp $";
#endif
#endif /* LIBC_SCCS and not lint */
@@ -423,17 +423,22 @@ __addel(hashp, bufp, key, val)
if (!bufp)
return (-1);
bp = (u_int16_t *)bufp->page;
- } else
+ } else if (bp[bp[0]] != OVFLPAGE) {
+ /* Short key/data pairs, no more pages */
+ break;
+ } else {
/* Try to squeeze key on this page */
- if (FREESPACE(bp) > PAIRSIZE(key, val)) {
+ if (bp[2] >= REAL_KEY &&
+ FREESPACE(bp) >= PAIRSIZE(key, val)) {
squeeze_key(bp, key, val);
- return (0);
+ goto stats;
} else {
bufp = __get_buf(hashp, bp[bp[0] - 1], bufp, 0);
if (!bufp)
return (-1);
bp = (u_int16_t *)bufp->page;
}
+ }
if (PAIRFITS(bp, key, val))
putpair(bufp->page, key, val);
@@ -450,6 +455,7 @@ __addel(hashp, bufp, key, val)
if (__big_insert(hashp, bufp, key, val))
return (-1);
}
+stats:
bufp->flags |= BUF_MOD;
/*
* If the average number of keys per bucket exceeds the fill factor,