Module Name: src
Committed By: christos
Date: Sat Sep 24 20:08:29 UTC 2016
Modified Files:
src/lib/libc/db/hash: hash_page.c
Log Message:
When writing out pages in the "other endian" format, make a copy instead of
trashing the in-memory one.
To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/lib/libc/db/hash/hash_page.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/lib/libc/db/hash/hash_page.c
diff -u src/lib/libc/db/hash/hash_page.c:1.28 src/lib/libc/db/hash/hash_page.c:1.29
--- src/lib/libc/db/hash/hash_page.c:1.28 Wed Nov 18 13:22:42 2015
+++ src/lib/libc/db/hash/hash_page.c Sat Sep 24 16:08:29 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: hash_page.c,v 1.28 2015/11/18 18:22:42 christos Exp $ */
+/* $NetBSD: hash_page.c,v 1.29 2016/09/24 20:08:29 christos Exp $ */
/*-
* Copyright (c) 1990, 1993, 1994
@@ -37,7 +37,7 @@
#endif
#include <sys/cdefs.h>
-__RCSID("$NetBSD: hash_page.c,v 1.28 2015/11/18 18:22:42 christos Exp $");
+__RCSID("$NetBSD: hash_page.c,v 1.29 2016/09/24 20:08:29 christos Exp $");
/*
* PACKAGE: hashing
@@ -593,6 +593,7 @@ __put_page(HTAB *hashp, char *p, uint32_
{
int fd, page, size;
ssize_t wsize;
+ char pbuf[MAX_BSIZE];
size = HASH_BSIZE(hashp);
if ((hashp->fp == -1) && (hashp->fp = __dbtemp("_hash", NULL)) == -1)
@@ -603,15 +604,18 @@ __put_page(HTAB *hashp, char *p, uint32_
int i;
int max;
+ memcpy(pbuf, p, size);
if (is_bitmap) {
max = (uint32_t)hashp->BSIZE >> 2; /* divide by 4 */
for (i = 0; i < max; i++)
- M_32_SWAP(((int *)(void *)p)[i]);
+ M_32_SWAP(((int *)(void *)pbuf)[i]);
} else {
- max = ((uint16_t *)(void *)p)[0] + 2;
+ uint16_t *bp = (uint16_t *)(void *)pbuf;
+ max = bp[0] + 2;
for (i = 0; i <= max; i++)
- M_16_SWAP(((uint16_t *)(void *)p)[i]);
+ M_16_SWAP(bp[i]);
}
+ p = pbuf;
}
if (is_bucket)
page = BUCKET_TO_PAGE(bucket);