]>
Commit | Line | Data |
---|---|---|
1 | --- hash_page.c.orig 2009-11-06 12:41:16.000000000 -0800 | |
2 | +++ hash_page.c 2009-11-06 12:43:23.000000000 -0800 | |
3 | @@ -70,7 +70,7 @@ __FBSDID("$FreeBSD: src/lib/libc/db/hash | |
4 | #include <db.h> | |
5 | #include "hash.h" | |
6 | #include "page.h" | |
7 | -#include "extern.h" | |
8 | +#include "hash_extern.h" | |
9 | ||
10 | static u_int32_t *fetch_bitmap(HTAB *, int); | |
11 | static u_int32_t first_free(u_int32_t); | |
12 | @@ -571,7 +571,7 @@ __get_page(HTAB *hashp, char *p, u_int32 | |
13 | int | |
14 | __put_page(HTAB *hashp, char *p, u_int32_t bucket, int is_bucket, int is_bitmap) | |
15 | { | |
16 | - int fd, page, size, wsize; | |
17 | + int fd, page, size, wsize, max; | |
18 | ||
19 | size = hashp->BSIZE; | |
20 | if ((hashp->fp == -1) && open_temp(hashp)) | |
21 | @@ -579,7 +579,7 @@ __put_page(HTAB *hashp, char *p, u_int32 | |
22 | fd = hashp->fp; | |
23 | ||
24 | if (hashp->LORDER != BYTE_ORDER) { | |
25 | - int i, max; | |
26 | + int i; | |
27 | ||
28 | if (is_bitmap) { | |
29 | max = hashp->BSIZE >> 2; /* divide by 4 */ | |
30 | @@ -602,6 +602,18 @@ __put_page(HTAB *hashp, char *p, u_int32 | |
31 | errno = EFTYPE; | |
32 | return (-1); | |
33 | } | |
34 | + /* 4485533 - reswap the in-memory copy */ | |
35 | + if (hashp->LORDER != BYTE_ORDER) { | |
36 | + int i; | |
37 | + | |
38 | + if (is_bitmap) { | |
39 | + for (i = 0; i < max; i++) | |
40 | + M_32_SWAP(((int *)p)[i]); | |
41 | + } else { | |
42 | + for (i = 0; i <= max; i++) | |
43 | + M_16_SWAP(((u_int16_t *)p)[i]); | |
44 | + } | |
45 | + } | |
46 | return (0); | |
47 | } | |
48 |