Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/lib/libc/db/hash If MAX_BSIZE == hashp->BSIZE (65536) then i...
details: https://anonhg.NetBSD.org/src/rev/8dedc7ce91c0
branches: trunk
changeset: 341688:8dedc7ce91c0
user: christos <christos%NetBSD.org@localhost>
date: Wed Nov 18 00:23:39 2015 +0000
description:
If MAX_BSIZE == hashp->BSIZE (65536) then it does not fit in a short, and
we end up storing 0... This means that every entry needs a page. We store
MAX_BSIZE - 1 here, but it would be better to always store (avail - 1) here
so that we don't waste a byte and be consistent.
diffstat:
lib/libc/db/hash/hash_page.c | 8 +++++---
1 files changed, 5 insertions(+), 3 deletions(-)
diffs (29 lines):
diff -r 392d53043d46 -r 8dedc7ce91c0 lib/libc/db/hash/hash_page.c
--- a/lib/libc/db/hash/hash_page.c Tue Nov 17 22:01:39 2015 +0000
+++ b/lib/libc/db/hash/hash_page.c Wed Nov 18 00:23:39 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: hash_page.c,v 1.26 2013/12/01 00:22:48 christos Exp $ */
+/* $NetBSD: hash_page.c,v 1.27 2015/11/18 00:23:39 christos Exp $ */
/*-
* Copyright (c) 1990, 1993, 1994
@@ -37,7 +37,7 @@
#endif
#include <sys/cdefs.h>
-__RCSID("$NetBSD: hash_page.c,v 1.26 2013/12/01 00:22:48 christos Exp $");
+__RCSID("$NetBSD: hash_page.c,v 1.27 2015/11/18 00:23:39 christos Exp $");
/*
* PACKAGE: hashing
@@ -85,7 +85,9 @@
temp = 3 * sizeof(uint16_t); \
_DIAGASSERT((size_t)hashp->BSIZE >= temp); \
((uint16_t *)(void *)(P))[1] = (uint16_t)(hashp->BSIZE - temp); \
- ((uint16_t *)(void *)(P))[2] = hashp->BSIZE; \
+ /* we should be really storing always length - 1 here... */ \
+ ((uint16_t *)(void *)(P))[2] = \
+ hashp->BSIZE == MAX_BSIZE ? MAX_BSIZE - 1 : hashp->BSIZE; \
}
/*
Home |
Main Index |
Thread Index |
Old Index