foo = Hash->LookupTable[i]->HashKey;
if (First != NULL)
bar = First(Hash->Members[Hash->LookupTable[i]->Position]->Data);
+ else
+ bar = "";
if (Second != NULL)
bla = Second(Hash->Members[Hash->LookupTable[i]->Position]->Data);
+ else
+ bla = "";
}
#ifdef DEBUG
printf (" ---- Hashkey[%ld][%ld]: '%s' Value: '%s' ; %s\n", i, key, foo, bar, bla);
/**
* \brief private destructor for one hash element.
+ * Crashing? go one frame up and do 'print *FreeMe->LookupTable[i]'
* \param Data an element to free using the user provided destructor, or just plain free
*/
static void DeleteHashPayload (Payload *Data)
free(Data->Data);
}
+/**
+ * \brief Destructor for nested hashes
+ */
+void HDeleteHash(void *vHash)
+{
+ HashList *FreeMe = (HashList*)vHash;
+ DeleteHash(&FreeMe);
+}
+
/**
* \brief destroy a hashlist and all of its members
+ * Crashing? do 'print *FreeMe->LookupTable[i]'
* \param Hash Hash to destroy. Is NULL'ed so you are shure its done.
*/
void DeleteHash(HashList **Hash)
return SearchPos;
}
+
+/**
+ * \brief another hashing algorithm; treat it as just a pointer to long.
+ * \param str Our pointer to the long value
+ * \param len the length of the data pointed to; needs to be sizeof int, else we won't use it!
+ * \returns the calculated hash value
+ */
+int Flathash(const char *str, long len)
+{
+ if (len != sizeof (int))
+ return 0;
+ else return *(int*)str;
+}
+
/**
* \brief private abstract wrapper around the hashing algorithm
* \param HKey the hash string
* \param Data returns the Data found at HashPos
* \returns whether the item was found or not.
*/
-int GetNextHashPos(HashList *Hash, HashPos *At, long *HKLen, char **HashKey, void **Data)
+int GetNextHashPos(HashList *Hash, HashPos *At, long *HKLen, const char **HashKey, void **Data)
{
long PayloadPos;
* return strcmp (a, b);
* }
*/
+
+
+/*
+ * Generic function to free a pointer. This can be used as a callback with the
+ * hash table, even on systems where free() is defined as a macro or has had other
+ * horrible things done to it.
+ */
+void generic_free_handler(void *ptr) {
+ free(ptr);
+}
+
+/*
+ * Generic function to free a reference.
+ * since a reference actualy isn't needed to be freed, do nothing.
+ */
+void reference_free_handler(void *ptr)
+{
+ 1;
+}
+
+
+