summaryrefslogtreecommitdiffstats
path: root/Hashtable.c
diff options
context:
space:
mode:
authorHisham Muhammad <hisham@gobolinux.org>2007-04-05 19:53:23 +0000
committerHisham Muhammad <hisham@gobolinux.org>2007-04-05 19:53:23 +0000
commita227b20fefda7d14316523ddd3aa1ce2b439169c (patch)
tree08ddd2b5636ded3fee6ac175c16014986e5d0969 /Hashtable.c
parente3198ca63b0996f4a2e46ab5bbb98650de47ea3e (diff)
Switch to unsigned keys in hash, according to issue #1688290
in the sf tracker
Diffstat (limited to 'Hashtable.c')
-rw-r--r--Hashtable.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/Hashtable.c b/Hashtable.c
index 4cd63109..cfd14704 100644
--- a/Hashtable.c
+++ b/Hashtable.c
@@ -19,7 +19,7 @@ typedef struct Hashtable_ Hashtable;
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 @@ int Hashtable_count(Hashtable* this) {
#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 @@ inline int Hashtable_size(Hashtable* this) {
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 @@ void Hashtable_put(Hashtable* this, int key, void* value) {
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 @@ void* Hashtable_remove(Hashtable* this, int key) {
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) {

© 2014-2024 Faster IT GmbH | imprint | privacy policy