X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=libcitadel%2Flib%2Fhash.c;h=c1e8d4d422bc16b81295b2802257d9f29a8b45d2;hb=19fb2763b48d73c87bf6852d29e84353fd941842;hp=38d780ed4f4695ace5a61a24dda0f9b02ca85a28;hpb=5a21ba7fa52434ea1d6d27d2116dc6d05e61da98;p=citadel.git diff --git a/libcitadel/lib/hash.c b/libcitadel/lib/hash.c index 38d780ed4..c1e8d4d42 100644 --- a/libcitadel/lib/hash.c +++ b/libcitadel/lib/hash.c @@ -162,6 +162,10 @@ int PrintHash(HashList *Hash, TransitionFunc Trans, PrintHashDataFunc PrintEntry return i; } +const char *dbg_PrintStrBufPayload(const char *Key, void *Item, int Odd) +{ + return ChrPtr((StrBuf*)Item); +} /** * @ingroup HashListDebug @@ -230,7 +234,12 @@ int dbg_PrintHash(HashList *Hash, PrintHashContent First, PrintHashContent Secon } #ifdef DEBUG - printf (" ---- Hashkey[%ld][%ld]: '%s' Value: '%s' ; %s\n", i, key, foo, bar, bla); + if ((Hash->Algorithm == lFlathash) || (Hash->Algorithm == Flathash)) { + printf (" ---- Hashkey[%ld][%ld]: %ld '%s' Value: '%s' ; %s\n", i, key, *(long*) foo, foo, bar, bla); + } + else { + printf (" ---- Hashkey[%ld][%ld]: '%s' Value: '%s' ; %s\n", i, key, foo, bar, bla); + } #endif } #ifdef DEBUG @@ -618,7 +627,13 @@ static long FindInHash(HashList *Hash, long HashBinKey) long Flathash(const char *str, long len) { if (len != sizeof (int)) + { +#ifdef DEBUG + int *crash = NULL; + *crash = 1; +#endif return 0; + } else return *(int*)str; } @@ -632,7 +647,13 @@ long Flathash(const char *str, long len) long lFlathash(const char *str, long len) { if (len != sizeof (long)) + { +#ifdef DEBUG + int *crash = NULL; + *crash = 1; +#endif return 0; + } else return *(long*)str; } @@ -809,6 +830,30 @@ HashPos *GetNewHashPos(const HashList *Hash, int StepWidth) return Ret; } +/** + * @ingroup HashListAccess + * @brief resets a hash-linear iterator object + * @param Hash the list we reference + * @param StepWidth in which step width should we iterate? + * @param it the iterator object to manipulate + * If negative, the last position matching the + * step-raster is provided. + * @return the hash iterator + */ +void RewindHashPos(const HashList *Hash, HashPos *it, int StepWidth) +{ + if (StepWidth != 0) + it->StepWidth = StepWidth; + else + it->StepWidth = 1; + if (it->StepWidth < 0) { + it->Position = Hash->nLookupTableItems - 1; + } + else { + it->Position = 0; + } +} + /** * @ingroup HashListAccess * @brief Set iterator object to point to key. If not found, don't change iterator