so I should add it to the front of the list and , in other words add to temp?
Code:
boolean HashTableInsert(HashTable *this, const char* key, const char* value)
{
list_t *temp;
int_u4 hashval = StringHash(key) % this->length;
/* Does item already exist? */
for (temp = this->table[hashval]; temp != NULL; temp = temp->next){
if (strcmp(key, temp->key) == 0){
StringDestruct(temp->value);
temp->value = StringConstruct(value);
return false;
}
}
list_t *new_list;
if ((new_list = malloc(sizeof(list_t))) == NULL)
outOfMemory_(__LINE__, __FILE__, "struct node creation");
new_list->key = StringConstruct(key);
new_list->value = StringConstruct(value);
new_list->next = NULL;
temp->next = new_list;
this->length = this->length + 1;
return true;
}
I am not sure if I missed temp by one slot..