Deleted Added
full compact
hash_page.c (190487) hash_page.c (190489)
1/*-
2 * Copyright (c) 1990, 1993, 1994
3 * The Regents of the University of California. All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Margo Seltzer.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 20 unchanged lines hidden (view full) ---

29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 * SUCH DAMAGE.
31 */
32
33#if defined(LIBC_SCCS) && !defined(lint)
34static char sccsid[] = "@(#)hash_page.c 8.7 (Berkeley) 8/16/94";
35#endif /* LIBC_SCCS and not lint */
36#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 1990, 1993, 1994
3 * The Regents of the University of California. All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Margo Seltzer.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 20 unchanged lines hidden (view full) ---

29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 * SUCH DAMAGE.
31 */
32
33#if defined(LIBC_SCCS) && !defined(lint)
34static char sccsid[] = "@(#)hash_page.c 8.7 (Berkeley) 8/16/94";
35#endif /* LIBC_SCCS and not lint */
36#include <sys/cdefs.h>
37__FBSDID("$FreeBSD: head/lib/libc/db/hash/hash_page.c 190487 2009-03-28 06:12:39Z delphij $");
37__FBSDID("$FreeBSD: head/lib/libc/db/hash/hash_page.c 190489 2009-03-28 06:23:10Z delphij $");
38
39/*
40 * PACKAGE: hashing
41 *
42 * DESCRIPTION:
43 * Page manipulation for hashing package.
44 *
45 * ROUTINES:

--- 73 unchanged lines hidden (view full) ---

119/*
120 * Returns:
121 * 0 OK
122 * -1 error
123 */
124int
125__delpair(HTAB *hashp, BUFHEAD *bufp, int ndx)
126{
38
39/*
40 * PACKAGE: hashing
41 *
42 * DESCRIPTION:
43 * Page manipulation for hashing package.
44 *
45 * ROUTINES:

--- 73 unchanged lines hidden (view full) ---

119/*
120 * Returns:
121 * 0 OK
122 * -1 error
123 */
124int
125__delpair(HTAB *hashp, BUFHEAD *bufp, int ndx)
126{
127 u_int16_t *bp, newoff;
127 u_int16_t *bp, newoff, pairlen;
128 int n;
128 int n;
129 u_int16_t pairlen;
130
131 bp = (u_int16_t *)bufp->page;
132 n = bp[0];
133
134 if (bp[ndx + 1] < REAL_KEY)
135 return (__big_delete(hashp, bufp));
136 if (ndx != 1)
137 newoff = bp[ndx - 1];

--- 310 unchanged lines hidden (view full) ---

448 *
449 * Returns:
450 * pointer on success
451 * NULL on error
452 */
453BUFHEAD *
454__add_ovflpage(HTAB *hashp, BUFHEAD *bufp)
455{
129
130 bp = (u_int16_t *)bufp->page;
131 n = bp[0];
132
133 if (bp[ndx + 1] < REAL_KEY)
134 return (__big_delete(hashp, bufp));
135 if (ndx != 1)
136 newoff = bp[ndx - 1];

--- 310 unchanged lines hidden (view full) ---

447 *
448 * Returns:
449 * pointer on success
450 * NULL on error
451 */
452BUFHEAD *
453__add_ovflpage(HTAB *hashp, BUFHEAD *bufp)
454{
456 u_int16_t *sp;
457 u_int16_t ndx, ovfl_num;
455 u_int16_t *sp, ndx, ovfl_num;
458#ifdef DEBUG1
459 int tmp1, tmp2;
460#endif
461 sp = (u_int16_t *)bufp->page;
462
463 /* Check if we are dynamically determining the fill factor */
464 if (hashp->FFACTOR == DEF_FFACTOR) {
465 hashp->FFACTOR = sp[0] >> 1;

--- 34 unchanged lines hidden (view full) ---

500 * Returns:
501 * 0 indicates SUCCESS
502 * -1 indicates FAILURE
503 */
504int
505__get_page(HTAB *hashp, char *p, u_int32_t bucket, int is_bucket, int is_disk,
506 int is_bitmap)
507{
456#ifdef DEBUG1
457 int tmp1, tmp2;
458#endif
459 sp = (u_int16_t *)bufp->page;
460
461 /* Check if we are dynamically determining the fill factor */
462 if (hashp->FFACTOR == DEF_FFACTOR) {
463 hashp->FFACTOR = sp[0] >> 1;

--- 34 unchanged lines hidden (view full) ---

498 * Returns:
499 * 0 indicates SUCCESS
500 * -1 indicates FAILURE
501 */
502int
503__get_page(HTAB *hashp, char *p, u_int32_t bucket, int is_bucket, int is_disk,
504 int is_bitmap)
505{
508 int fd, page, size;
509 int rsize;
506 int fd, page, size, rsize;
510 u_int16_t *bp;
511
512 fd = hashp->fp;
513 size = hashp->BSIZE;
514
515 if ((fd == -1) || !is_disk) {
516 PAGE_INIT(p);
517 return (0);

--- 37 unchanged lines hidden (view full) ---

555 *
556 * Returns:
557 * 0 ==> OK
558 * -1 ==>failure
559 */
560int
561__put_page(HTAB *hashp, char *p, u_int32_t bucket, int is_bucket, int is_bitmap)
562{
507 u_int16_t *bp;
508
509 fd = hashp->fp;
510 size = hashp->BSIZE;
511
512 if ((fd == -1) || !is_disk) {
513 PAGE_INIT(p);
514 return (0);

--- 37 unchanged lines hidden (view full) ---

552 *
553 * Returns:
554 * 0 ==> OK
555 * -1 ==>failure
556 */
557int
558__put_page(HTAB *hashp, char *p, u_int32_t bucket, int is_bucket, int is_bitmap)
559{
563 int fd, page, size;
564 int wsize;
560 int fd, page, size, wsize;
565
566 size = hashp->BSIZE;
567 if ((hashp->fp == -1) && open_temp(hashp))
568 return (-1);
569 fd = hashp->fp;
570
571 if (hashp->LORDER != BYTE_ORDER) {
561
562 size = hashp->BSIZE;
563 if ((hashp->fp == -1) && open_temp(hashp))
564 return (-1);
565 fd = hashp->fp;
566
567 if (hashp->LORDER != BYTE_ORDER) {
572 int i;
573 int max;
568 int i, max;
574
575 if (is_bitmap) {
576 max = hashp->BSIZE >> 2; /* divide by 4 */
577 for (i = 0; i < max; i++)
578 M_32_SWAP(((int *)p)[i]);
579 } else {
580 max = ((u_int16_t *)p)[0] + 2;
581 for (i = 0; i <= max; i++)

--- 346 unchanged lines hidden ---
569
570 if (is_bitmap) {
571 max = hashp->BSIZE >> 2; /* divide by 4 */
572 for (i = 0; i < max; i++)
573 M_32_SWAP(((int *)p)[i]);
574 } else {
575 max = ((u_int16_t *)p)[0] + 2;
576 for (i = 0; i <= max; i++)

--- 346 unchanged lines hidden ---