dbg_PrintHash(): #ifdef DEBUG everything related to pure verbose debugging.
[citadel.git] / libcitadel / lib / hash.c
index d315358beae1115679872ef945c5ab54dbd1efc0..e49adb80ab55b8fb500aaf6016a52251717f3a2c 100644 (file)
@@ -173,9 +173,11 @@ int PrintHash(HashList *Hash, TransitionFunc Trans, PrintHashDataFunc PrintEntry
  */
 int dbg_PrintHash(HashList *Hash, PrintHashContent First, PrintHashContent Second)
 {
+#ifdef DEBUG
        const char *foo;
        const char *bar;
        const char *bla = "";
+#endif
        long key;
        long i;
 
@@ -193,8 +195,11 @@ int dbg_PrintHash(HashList *Hash, PrintHashContent First, PrintHashContent Secon
                
                if (Hash->LookupTable[i] == NULL)
                {
+#ifdef DEBUG
                        foo = "";
                        bar = "";
+#endif
+
                        key = 0;
                }
                else 
@@ -202,13 +207,26 @@ int dbg_PrintHash(HashList *Hash, PrintHashContent First, PrintHashContent Secon
                        key = Hash->LookupTable[i]->Key;
                        foo = Hash->LookupTable[i]->HashKey;
                        if (First != NULL)
-                               bar = First(Hash->Members[Hash->LookupTable[i]->Position]->Data);
+#ifdef DEBUG
+                               bar =
+#endif
+                                       First(Hash->Members[Hash->LookupTable[i]->Position]->Data);
+#ifdef DEBUG
                        else 
                                bar = "";
+#endif
+
                        if (Second != NULL)
-                               bla = Second(Hash->Members[Hash->LookupTable[i]->Position]->Data);
+#ifdef DEBUG
+                               bla = 
+#endif 
+                                       Second(Hash->Members[Hash->LookupTable[i]->Position]->Data);
+#ifdef DEBUG
+
                        else
                                bla = "";
+#endif
+
                }
 #ifdef DEBUG
                printf (" ---- Hashkey[%ld][%ld]: '%s' Value: '%s' ; %s\n", i, key, foo, bar, bla);
@@ -622,10 +640,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 +787,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;
 }