|
| From: | Richard Henderson |
| Subject: | Re: [Qemu-devel] [PATCH v3 08/11] qht: QEMU's fast, resizable and scalable Hash Table |
| Date: | Sun, 24 Apr 2016 13:01:31 -0700 |
| User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.7.1 |
On 04/19/2016 04:07 PM, Emilio G. Cota wrote:
+static void qht_insert__locked(struct qht *ht, struct qht_map *map,
+ struct qht_bucket *head, void *p, uint32_t hash)
+{
+ struct qht_bucket *b = head;
+ struct qht_bucket *prev = NULL;
+ struct qht_bucket *new = NULL;
+ int i;
+
+ for (;;) {
+ if (b == NULL) {
+ b = qemu_memalign(QHT_BUCKET_ALIGN, sizeof(*b));
+ memset(b, 0, sizeof(*b));
+ new = b;
+ }
+ for (i = 0; i < QHT_BUCKET_ENTRIES; i++) {
+ if (b->hashes[i]) {
+ continue;
+ }
Surely that's b->pointers[i] != NULL. We've made no provision that the hash function must return non-zero.
+static inline bool qht_remove__locked(struct qht_map *map, struct qht_bucket
*b,
+ const void *p, uint32_t hash)
+{
+ int i;
+
+ do {
+ for (i = 0; i < QHT_BUCKET_ENTRIES; i++) {
+ if (b->hashes[i] == hash && b->pointers[i] == p) {
Don't you only need to test p here? r~
| [Prev in Thread] | Current Thread | [Next in Thread] |