X-Git-Url: https://git.saurik.com/apple/libc.git/blobdiff_plain/1f2f436a38f7ae2d39a943ad2898d8fed4ed2e58..ad3c9f2af814c84582fdd1649e49ec4f68572c5a:/db/hash/FreeBSD/hash_page.c diff --git a/db/hash/FreeBSD/hash_page.c b/db/hash/FreeBSD/hash_page.c index 1f44bde..809a3b9 100644 --- a/db/hash/FreeBSD/hash_page.c +++ b/db/hash/FreeBSD/hash_page.c @@ -70,7 +70,7 @@ __FBSDID("$FreeBSD: src/lib/libc/db/hash/hash_page.c,v 1.16 2009/03/28 06:30:43 #include #include "hash.h" #include "page.h" -#include "extern.h" +#include "hash_extern.h" static u_int32_t *fetch_bitmap(HTAB *, int); static u_int32_t first_free(u_int32_t); @@ -571,7 +571,7 @@ __get_page(HTAB *hashp, char *p, u_int32_t bucket, int is_bucket, int is_disk, int __put_page(HTAB *hashp, char *p, u_int32_t bucket, int is_bucket, int is_bitmap) { - int fd, page, size, wsize; + int fd, page, size, wsize, max; size = hashp->BSIZE; if ((hashp->fp == -1) && open_temp(hashp)) @@ -579,7 +579,7 @@ __put_page(HTAB *hashp, char *p, u_int32_t bucket, int is_bucket, int is_bitmap) fd = hashp->fp; if (hashp->LORDER != BYTE_ORDER) { - int i, max; + int i; if (is_bitmap) { max = hashp->BSIZE >> 2; /* divide by 4 */ @@ -602,6 +602,18 @@ __put_page(HTAB *hashp, char *p, u_int32_t bucket, int is_bucket, int is_bitmap) errno = EFTYPE; return (-1); } + /* 4485533 - reswap the in-memory copy */ + if (hashp->LORDER != BYTE_ORDER) { + int i; + + if (is_bitmap) { + for (i = 0; i < max; i++) + M_32_SWAP(((int *)p)[i]); + } else { + for (i = 0; i <= max; i++) + M_16_SWAP(((u_int16_t *)p)[i]); + } + } return (0); }