#include <db.h>
#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);
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))
fd = hashp->fp;
if (hashp->LORDER != BYTE_ORDER) {
- int i, max;
+ int i;
if (is_bitmap) {
max = hashp->BSIZE >> 2; /* divide by 4 */
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);
}