From 317f37bafbecbc5d4042aff8171d3f2400721086 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Wilfried=20G=C3=B6esgens?= Date: Wed, 7 May 2008 06:55:17 +0000 Subject: [PATCH] * hash now can return its number of members. --- libcitadel/debian/rules | 2 +- libcitadel/lib/hash.c | 12 ++++++++---- libcitadel/lib/libcitadel.h | 4 ++-- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/libcitadel/debian/rules b/libcitadel/debian/rules index 795a93709..ca93b0453 100755 --- a/libcitadel/debian/rules +++ b/libcitadel/debian/rules @@ -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 diff --git a/libcitadel/lib/hash.c b/libcitadel/lib/hash.c index f945fd5cb..3908121d9 100644 --- a/libcitadel/lib/hash.c +++ b/libcitadel/lib/hash.c @@ -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*)); } } diff --git a/libcitadel/lib/libcitadel.h b/libcitadel/lib/libcitadel.h index 4657ad531..7da1178f7 100644 --- a/libcitadel/lib/libcitadel.h +++ b/libcitadel/lib/libcitadel.h @@ -9,7 +9,7 @@ */ #include #include -#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); -- 2.30.2