Fix lookup of of hashitem to hashpos: we have to use the indirect position not the...
authorWilfried Goesgens <dothebart@citadel.org>
Mon, 21 Nov 2011 18:23:42 +0000 (19:23 +0100)
committerWilfried Goesgens <dothebart@citadel.org>
Mon, 21 Nov 2011 21:06:01 +0000 (22:06 +0100)
libcitadel/lib/hash.c

index d315358beae1115679872ef945c5ab54dbd1efc0..d4c2f5080f408b516c47ab98d800f5618beff19c 100644 (file)
@@ -622,10 +622,10 @@ void Put(HashList *Hash, const char *HKey, long HKLen, void *Data, DeleteHashDat
        /** oh, we're brand new... */
        if (Hash->LookupTable[HashAt] == NULL) {
                InsertHashItem(Hash, HashAt, HashBinKey, HKey, HKLen, Data, DeleteIt);
-       }/** Insert After? */
+       }/** Insert Before? */
        else if (Hash->LookupTable[HashAt]->Key > HashBinKey) {
                InsertHashItem(Hash, HashAt, HashBinKey, HKey, HKLen, Data, DeleteIt);
-       }/** Insert before? */
+       }/** Insert After? */
        else if (Hash->LookupTable[HashAt]->Key < HashBinKey) {
                InsertHashItem(Hash, HashAt + 1, HashBinKey, HKey, HKLen, Data, DeleteIt);
        }
@@ -769,7 +769,7 @@ int GetHashPosFromKey(HashList *Hash, const char *HKey, long HKLen, HashPos *At)
                return 0;
        }
        /** GOTCHA! */
-       At->Position = Hash->LookupTable[HashAt]->Position;
+       At->Position = HashAt;
        return 1;
 }