Switch to unsigned keys in hash, according to issue #1688290
in the sf tracker
diff --git a/Hashtable.c b/Hashtable.c
index 4cd6310..cfd1470 100644
--- a/Hashtable.c
+++ b/Hashtable.c
@@ -19,7 +19,7 @@
typedef void(*Hashtable_PairFunction)(int, void*, void*);
typedef struct HashtableItem {
- int key;
+ unsigned int key;
void* value;
struct HashtableItem* next;
} HashtableItem;
@@ -61,7 +61,7 @@
#endif
-HashtableItem* HashtableItem_new(int key, void* value) {
+HashtableItem* HashtableItem_new(unsigned int key, void* value) {
HashtableItem* this;
this = (HashtableItem*) malloc(sizeof(HashtableItem));
@@ -104,8 +104,8 @@
return this->items;
}
-void Hashtable_put(Hashtable* this, int key, void* value) {
- int index = key % this->size;
+void Hashtable_put(Hashtable* this, unsigned int key, void* value) {
+ unsigned int index = key % this->size;
HashtableItem** bucketPtr = &(this->buckets[index]);
while (true)
if (*bucketPtr == NULL) {
@@ -122,8 +122,8 @@
assert(Hashtable_isConsistent(this));
}
-void* Hashtable_remove(Hashtable* this, int key) {
- int index = key % this->size;
+void* Hashtable_remove(Hashtable* this, unsigned int key) {
+ unsigned int index = key % this->size;
assert(Hashtable_isConsistent(this));
@@ -149,8 +149,8 @@
return NULL;
}
-inline void* Hashtable_get(Hashtable* this, int key) {
- int index = key % this->size;
+inline void* Hashtable_get(Hashtable* this, unsigned int key) {
+ unsigned int index = key % this->size;
HashtableItem* bucketPtr = this->buckets[index];
while (true) {
if (bucketPtr == NULL) {