37#if defined(LIBC_SCCS) && !defined(lint)
38static char sccsid[] =
"@(#)hash_bigkey.c 8.3 (Berkeley) 5/31/94";
70#include "../include/db.h"
94 int key_size, n, val_size;
96 char *cp, *key_data, *val_data;
101 key_data = (
char *)key->
data;
102 key_size = key->
size;
103 val_data = (
char *)
val->data;
104 val_size =
val->size;
109 move_bytes =
MIN(space, key_size);
110 off =
OFFSET(p) - move_bytes;
111 memmove(cp + off, key_data, move_bytes);
112 key_size -= move_bytes;
113 key_data += move_bytes;
127 off =
OFFSET(p) - move_bytes;
129 memmove(cp + off, val_data, move_bytes);
130 val_data += move_bytes;
131 val_size -= move_bytes;
146 move_bytes =
MIN(space, val_size);
151 if ((
int) space == val_size && (
size_t) val_size ==
val->size)
153 off =
OFFSET(p) - move_bytes;
154 memmove(cp + off, val_data, move_bytes);
155 val_size -= move_bytes;
156 val_data += move_bytes;
192 register BUFHEAD *last_bfp, *rbufp;
213 pageno = bp[bp[0] - 1];
215 rbufp =
__get_buf(hashp, pageno, rbufp, 0);
248 OFFSET(bp) = hashp->BSIZE - 1;
253 if (last_bfp && last_bfp != rbufp)
285 for (bytes = hashp->BSIZE - bp[ndx];
287 bytes = hashp->BSIZE - bp[ndx]) {
288 if (memcmp(p + bp[ndx], kkey, bytes))
292 bufp =
__get_buf(hashp, bp[ndx + 2], bufp, 0);
300 if (bytes != ksize || memcmp(p + bp[ndx], kkey, bytes)) {
301#ifdef HASH_STATISTICS
342 bufp =
__get_buf(hashp, pageno, bufp, 0);
373 bufp =
__get_buf(hashp, bp[bp[0] - 1], bufp, 0);
381 bufp =
__get_buf(hashp, bp[bp[0] - 1], bufp, 0);
386 save_addr = save_p->
addr;
401 save_addr = bufp->
addr;
402 bufp =
__get_buf(hashp, bp[bp[0] - 1], bufp, 0);
410 val->data = (u_char *)tp + off;
411 val->size = bp[1] - off;
420 bp[bp[0] - 1], bufp, 0);
435 if (
val->size == (
size_t) -1)
437 if (save_p->
addr != save_addr) {
464 mylen = hashp->BSIZE - bp[1];
465 save_addr = bufp->
addr;
468 totlen =
len + mylen;
480 __get_buf(hashp, bp[bp[0] - 1], bufp, 0);
490 xbp =
__get_buf(hashp, bp[bp[0] - 1], bufp, 0);
491 if (!xbp || ((totlen =
495 if (bufp->
addr != save_addr) {
514 if (key->
size == (
size_t) -1)
539 mylen = hashp->BSIZE - bp[1];
541 save_addr = bufp->
addr;
542 totlen =
len + mylen;
551 xbp =
__get_buf(hashp, bp[bp[0] - 1], bufp, 0);
552 if (!xbp || ((totlen =
556 if (bufp->
addr != save_addr) {
612 (void)fprintf(stderr,
613 "BIG_SPLIT: %d->ovfl was %d is now %d\n", tmpp->
addr,
static int set(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
u_int32_t __call_hash(HTAB *hashp, char *k, int len)
static int collect_data(HTAB *hashp, BUFHEAD *bufp, int len, int set)
int __big_keydata(HTAB *hashp, BUFHEAD *bufp, DBT *key, DBT *val, int set)
static int collect_key(HTAB *hashp, BUFHEAD *bufp, int len, DBT *val, int set)
int __big_insert(HTAB *hashp, BUFHEAD *bufp, const DBT *key, const DBT *val)
int __find_bigpair(HTAB *hashp, BUFHEAD *bufp, int ndx, char *key, int size)
static int collect_key __P((HTAB *, BUFHEAD *, int, DBT *, int))
int __big_return(HTAB *hashp, BUFHEAD *bufp, int ndx, DBT *val, int set_current)
int __big_delete(HTAB *hashp, BUFHEAD *bufp)
u_int16_t __find_last_page(HTAB *hashp, BUFHEAD **bpp)
int __big_split(HTAB *hashp, BUFHEAD *op, BUFHEAD *np, BUFHEAD *big_keyp, int addr, u_int32_t obucket, SPLIT_RETURN *ret)
BUFHEAD * __get_buf(HTAB *hashp, u_int32_t addr, BUFHEAD *prev_bp, int newpage)
BUFHEAD * __add_ovflpage(HTAB *hashp, BUFHEAD *bufp)
void __free_ovflpage(HTAB *hashp, BUFHEAD *obufp)