* hash now can return its number of members.
authorWilfried Göesgens <willi@citadel.org>
Wed, 7 May 2008 06:55:17 +0000 (06:55 +0000)
committerWilfried Göesgens <willi@citadel.org>
Wed, 7 May 2008 06:55:17 +0000 (06:55 +0000)
libcitadel/debian/rules
libcitadel/lib/hash.c
libcitadel/lib/libcitadel.h

index 795a937098ed45567944d3a964bda2fcb7724933..ca93b045366d1a07e6c714f2593171eb42a03d7a 100755 (executable)
@@ -12,7 +12,7 @@ DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
 CFLAGS = -Wall -g
 
 ifneq (,$(findstring debug,$(DEB_BUILD_OPTIONS)))
-       CFLAGS += -O0 -ggdb -rdynamic -MD -MP 
+       CFLAGS += -O0 -ggdb -rdynamic -MD -MP -D DEBUG
 else
        CFLAGS += -O2
 endif
index f945fd5cb05e0c1ce91cc2b8237da19027ad7365..3908121d90c13a13bf54e3f774f8ee49436dd006 100644 (file)
@@ -163,6 +163,12 @@ HashList *NewHash(int Uniq, HashFunc F)
        return NewList;
 }
 
+int GetCount(HashList *Hash)
+{
+       return Hash->nMembersUsed;
+}
+
+
 /**
  * \brief private destructor for one hash element.
  * \param Data an element to free using the user provided destructor, or just plain free
@@ -282,16 +288,14 @@ static void InsertHashItem(HashList *Hash,
        /** but if we should be sorted into a specific place... */
        if ((Hash->nMembersUsed != 0) && 
            (HashPos != Hash->nMembersUsed) ) {
-               long InsertAt;
                long ItemsAfter;
 
                ItemsAfter = Hash->nMembersUsed - HashPos;
-               InsertAt = HashPos;
                /** make space were we can fill us in */
                if (ItemsAfter > 0)
                {
-                       memmove(&Hash->LookupTable[InsertAt + 1],
-                               &Hash->LookupTable[InsertAt],
+                       memmove(&Hash->LookupTable[HashPos + 1],
+                               &Hash->LookupTable[HashPos],
                                ItemsAfter * sizeof(HashKey*));
                } 
        }
index 4657ad5311b625d26ac132f461f235b8d9f412c9..7da1178f70e005a1a71d300dde7d5f125f68e438 100644 (file)
@@ -9,7 +9,7 @@
  */
 #include <time.h>
 #include <stdlib.h>
-#define LIBCITADEL_VERSION_NUMBER      111
+#define LIBCITADEL_VERSION_NUMBER      112
 
 /*
  * Here's a bunch of stupid magic to make the MIME parser portable.
@@ -298,7 +298,7 @@ int GetNextHashPos(HashList *Hash, HashPos *At, long *HKLen, char **HashKey, voi
 
 void SortByHashKey(HashList *Hash, int Order);
 void SortByHashKeyStr(HashList *Hash);
-
+int GetCount(HashList *Hash);
 const void *GetSearchPayload(const void *HashVoid);
 void SortByPayload(HashList *Hash, CompareFunc SortBy);