/* Given a pointer to the user entry data, return a pointer to the hash node */
static int HT_Compare (const void* Key1, const void* Key2);
-/* Compare two keys for equality */
+/* Compare two keys. The function must return a value less than zero if
+ * Key1 is smaller than Key2, zero if both are equal, and a value greater
+ * than zero if Key1 is greater then Key2.
+ */
static int HT_Compare (const void* Key1, const void* Key2)
-/* Compare two keys for equality */
+/* Compare two keys. The function must return a value less than zero if
+ * Key1 is smaller than Key2, zero if both are equal, and a value greater
+ * than zero if Key1 is greater then Key2.
+ */
{
- return (*(const unsigned*)Key1 == *(const unsigned*)Key2);
+ return (int)*(const unsigned*)Key1 - (int)*(const unsigned*)Key2;
}
/* Given a pointer to the user entry data, return a pointer to the hash node */
static int HT_Compare (const void* Key1, const void* Key2);
-/* Compare two keys for equality */
+/* Compare two keys. The function must return a value less than zero if
+ * Key1 is smaller than Key2, zero if both are equal, and a value greater
+ * than zero if Key1 is greater then Key2.
+ */
static int HT_Compare (const void* Key1, const void* Key2)
-/* Compare two keys for equality */
+/* Compare two keys. The function must return a value less than zero if
+ * Key1 is smaller than Key2, zero if both are equal, and a value greater
+ * than zero if Key1 is greater then Key2.
+ */
{
- return (strcmp (Key1, Key2) == 0);
+ return strcmp (Key1, Key2);
}
* if it is not really necessary.
*/
if (N->Hash == Hash &&
- T->Func->Compare (Key, T->Func->GetKey (N->Entry))) {
+ T->Func->Compare (Key, T->Func->GetKey (N->Entry)) == 0) {
/* Found */
break;
}
/* Given a pointer to the user entry data, return a pointer to the hash node */
int (*Compare) (const void* Key1, const void* Key2);
- /* Compare two keys for equality */
+ /* Compare two keys. The function must return a value less than zero if
+ * Key1 is smaller than Key2, zero if both are equal, and a value greater
+ * than zero if Key1 is greater then Key2.
+ */
};
/* Hash table */