X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=libcitadel%2Flib%2Fhash.c;h=b3c75795bd1438ac130240a054cc9df5e885b055;hb=7218848cd779f370a4932be9c459259f70707983;hp=fd8916f1757988627045b9dca75f7088e5b6025f;hpb=16939d06be6f78ee5ca6b0d5e7072e3cfcfdbb3f;p=citadel.git diff --git a/libcitadel/lib/hash.c b/libcitadel/lib/hash.c index fd8916f17..b3c75795b 100644 --- a/libcitadel/lib/hash.c +++ b/libcitadel/lib/hash.c @@ -634,6 +634,28 @@ int GetNextHashPos(HashList *Hash, HashPos *At, long *HKLen, const char **HashKe return 1; } +/** + * \brief Get the data located where At points to + * note: you should prefer iterator operations instead of using me. + * \param Hash your Hashlist peek from + * \param HKLen returns Length of Hashkey Returned + * \param HashKey returns the Hashkey corrosponding to HashPos + * \param Data returns the Data found at HashPos + * \returns whether the item was found or not. + */ +int GetHashAt(HashList *Hash,long At, long *HKLen, const char **HashKey, void **Data) +{ + long PayloadPos; + + if ((Hash == NULL) || (At >= Hash->nMembersUsed)) + return 0; + *HKLen = Hash->LookupTable[At]->HKLen; + *HashKey = Hash->LookupTable[At]->HashKey; + PayloadPos = Hash->LookupTable[At]->Position; + *Data = Hash->Members[PayloadPos]->Data; + return 1; +} + /** * \brief sorting function for sorting the Hash alphabeticaly by their strings * \param Key1 first item