/*
- * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2003 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
*
* @APPLE_LICENSE_HEADER_END@
*/
-/*
- * Copyright (c) 1990, 1993
+/*-
+ * Copyright (c) 1990, 1993, 1994
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* SUCH DAMAGE.
*/
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)hash_bigkey.c 8.3 (Berkeley) 5/31/94";
+#endif /* LIBC_SCCS and not lint */
+#include <sys/cdefs.h>
/*
* PACKAGE: hash
#include "page.h"
#include "extern.h"
-static int collect_key __P((HTAB *, BUFHEAD *, int, DBT *, int));
-static int collect_data __P((HTAB *, BUFHEAD *, int, int));
+static int collect_key(HTAB *, BUFHEAD *, int, DBT *, int);
+static int collect_data(HTAB *, BUFHEAD *, int, int);
/*
* Big_insert
BUFHEAD *bufp;
const DBT *key, *val;
{
- register u_short *p;
+ u_int16_t *p;
int key_size, n, val_size;
- u_short space, move_bytes, off;
+ u_int16_t space, move_bytes, off;
char *cp, *key_data, *val_data;
cp = bufp->page; /* Character pointer of p. */
- p = (u_short *)cp;
+ p = (u_int16_t *)cp;
key_data = (char *)key->data;
key_size = key->size;
if (!bufp)
return (-1);
n = p[0];
- if (!key_size)
+ if (!key_size) {
if (FREESPACE(p)) {
move_bytes = MIN(FREESPACE(p), val_size);
off = OFFSET(p) - move_bytes;
OFFSET(p) = off;
} else
p[n - 2] = FULL_KEY;
- p = (u_short *)bufp->page;
+ }
+ p = (u_int16_t *)bufp->page;
cp = bufp->page;
bufp->flags |= BUF_MOD;
}
if (!bufp)
return (-1);
cp = bufp->page;
- p = (u_short *)cp;
+ p = (u_int16_t *)cp;
} else
p[n] = FULL_KEY_DATA;
bufp->flags |= BUF_MOD;
HTAB *hashp;
BUFHEAD *bufp;
{
- register BUFHEAD *last_bfp, *rbufp;
- u_short *bp, pageno;
+ BUFHEAD *last_bfp, *rbufp;
+ u_int16_t *bp, pageno;
int key_done, n;
rbufp = bufp;
last_bfp = NULL;
- bp = (u_short *)bufp->page;
+ bp = (u_int16_t *)bufp->page;
pageno = 0;
key_done = 0;
last_bfp = rbufp;
if (!rbufp)
return (-1); /* Error. */
- bp = (u_short *)rbufp->page;
+ bp = (u_int16_t *)rbufp->page;
}
/*
pageno = bp[n - 1];
/* Now, bp is the first page of the pair. */
- bp = (u_short *)bufp->page;
+ bp = (u_int16_t *)bufp->page;
if (n > 2) {
/* There is an overflow page. */
bp[1] = pageno;
char *key;
int size;
{
- register u_short *bp;
- register char *p;
+ u_int16_t *bp;
+ char *p;
int ksize;
- u_short bytes;
+ u_int16_t bytes;
char *kkey;
- bp = (u_short *)bufp->page;
+ bp = (u_int16_t *)bufp->page;
p = bufp->page;
ksize = size;
kkey = key;
if (!bufp)
return (-3);
p = bufp->page;
- bp = (u_short *)p;
+ bp = (u_int16_t *)p;
ndx = 1;
}
* of the pair; 0 if there isn't any (i.e. big pair is the last key in the
* bucket)
*/
-extern u_short
+extern u_int16_t
__find_last_page(hashp, bpp)
HTAB *hashp;
BUFHEAD **bpp;
{
BUFHEAD *bufp;
- u_short *bp, pageno;
+ u_int16_t *bp, pageno;
int n;
bufp = *bpp;
- bp = (u_short *)bufp->page;
+ bp = (u_int16_t *)bufp->page;
for (;;) {
n = bp[0];
bufp = __get_buf(hashp, pageno, bufp, 0);
if (!bufp)
return (0); /* Need to indicate an error! */
- bp = (u_short *)bufp->page;
+ bp = (u_int16_t *)bufp->page;
}
*bpp = bufp;
int set_current;
{
BUFHEAD *save_p;
- u_short *bp, len, off, save_addr;
+ u_int16_t *bp, len, off, save_addr;
char *tp;
- bp = (u_short *)bufp->page;
+ bp = (u_int16_t *)bufp->page;
while (bp[ndx + 1] == PARTIAL_KEY) {
bufp = __get_buf(hashp, bp[bp[0] - 1], bufp, 0);
if (!bufp)
return (-1);
- bp = (u_short *)bufp->page;
+ bp = (u_int16_t *)bufp->page;
ndx = 1;
}
bufp = __get_buf(hashp, bp[bp[0] - 1], bufp, 0);
if (!bufp)
return (-1);
- bp = (u_short *)bufp->page;
+ bp = (u_int16_t *)bufp->page;
save_p = bufp;
save_addr = save_p->addr;
off = bp[1];
bufp = __get_buf(hashp, bp[bp[0] - 1], bufp, 0);
if (!bufp)
return (-1);
- bp = (u_short *)bufp->page;
+ bp = (u_int16_t *)bufp->page;
} else {
/* The data is all on one page. */
tp = (char *)bp;
if (!hashp->cpage)
return (-1);
hashp->cndx = 1;
- if (!((u_short *)
+ if (!((u_int16_t *)
hashp->cpage->page)[0]) {
hashp->cbucket++;
hashp->cpage = NULL;
BUFHEAD *bufp;
int len, set;
{
- register u_short *bp;
- register char *p;
+ u_int16_t *bp;
+ char *p;
BUFHEAD *xbp;
- u_short save_addr;
+ u_int16_t save_addr;
int mylen, totlen;
p = bufp->page;
- bp = (u_short *)p;
+ bp = (u_int16_t *)p;
mylen = hashp->BSIZE - bp[1];
save_addr = bufp->addr;
__get_buf(hashp, bp[bp[0] - 1], bufp, 0);
if (!hashp->cpage)
return (-1);
- else if (!((u_short *)hashp->cpage->page)[0]) {
+ else if (!((u_int16_t *)hashp->cpage->page)[0]) {
hashp->cbucket++;
hashp->cpage = NULL;
}
BUFHEAD *xbp;
char *p;
int mylen, totlen;
- u_short *bp, save_addr;
+ u_int16_t *bp, save_addr;
p = bufp->page;
- bp = (u_short *)p;
+ bp = (u_int16_t *)p;
mylen = hashp->BSIZE - bp[1];
save_addr = bufp->addr;
/* Pointer to first page containing the big key/data */
BUFHEAD *big_keyp;
int addr; /* Address of big_keyp */
- u_int obucket;/* Old Bucket */
+ u_int32_t obucket;/* Old Bucket */
SPLIT_RETURN *ret;
{
- register BUFHEAD *tmpp;
- register u_short *tp;
+ BUFHEAD *tmpp;
+ u_int16_t *tp;
BUFHEAD *bp;
DBT key, val;
- u_int change;
- u_short free_space, n, off;
+ u_int32_t change;
+ u_int16_t free_space, n, off;
bp = big_keyp;
return (-1);
change = (__call_hash(hashp, key.data, key.size) != obucket);
- if (ret->next_addr = __find_last_page(hashp, &big_keyp)) {
+ if ( (ret->next_addr = __find_last_page(hashp, &big_keyp)) ) {
if (!(ret->nextp =
__get_buf(hashp, ret->next_addr, big_keyp, 0)))
return (-1);;
(tmpp->ovfl ? tmpp->ovfl->addr : 0), (bp ? bp->addr : 0));
#endif
tmpp->ovfl = bp; /* one of op/np point to big_keyp */
- tp = (u_short *)tmpp->page;
+ tp = (u_int16_t *)tmpp->page;
#ifdef DEBUG
assert(FREESPACE(tp) >= OVFLSIZE);
#endif
n = tp[0];
off = OFFSET(tp);
free_space = FREESPACE(tp);
- tp[++n] = (u_short)addr;
+ tp[++n] = (u_int16_t)addr;
tp[++n] = OVFLPAGE;
tp[0] = n;
OFFSET(tp) = off;
ret->newp = np;
ret->oldp = op;
- tp = (u_short *)big_keyp->page;
+ tp = (u_int16_t *)big_keyp->page;
big_keyp->flags |= BUF_MOD;
if (tp[0] > 2) {
/*