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~