ref: adac14ddd4c94027afe59381ea046ace0adbefc3
parent: c213b65f962b9a0a22274974fa5b213eb9f810c4
author: LTCHIPS <ltchips994@gmail.com>
date: Mon Mar 19 13:58:12 EDT 2018
fixed special key crash
--- a/rott/HashTable.c
+++ b/rott/HashTable.c
@@ -69,10 +69,12 @@
{
int index = HashFunc(hashTable,key);
- if (hashTable->table == 0)
+ if (hashTable->table[index] == 0)
{
- printf("ERROR: HashTable Lookup lead to a NULL Entry.");
- exit(1);
+ //printf("ERROR: HashTable Lookup lead to a NULL Entry. \n");
+ return 0;
+
+ //exit(1);
}
return SearchWithKey(hashTable->table[index], key);
--- a/rott/HashTable.h
+++ b/rott/HashTable.h
@@ -1,7 +1,7 @@
/*
* File: HashTable.h
- * Author: Steven LeVesque
+ * Author: LTCHIPS
*
* Created on March 13, 2018, 5:10 PM
*/
--- a/rott/LinkedList.c
+++ b/rott/LinkedList.c
@@ -6,6 +6,7 @@
{
linkedList->NumOfItems = 0;
linkedList->head = NULL;
+ linkedList->IsInit = 1;
}
void InsertInList(LinkedList * linkedList, int key, int item)
@@ -59,6 +60,10 @@
if (x->key == key)
{
return x->data;
+ }
+ if (x->next == NULL)
+ {
+ break;
}
}
return 0;
--- a/rott/LinkedList.h
+++ b/rott/LinkedList.h
@@ -22,6 +22,7 @@
typedef struct LinkedList
{
int NumOfItems;
+ int IsInit;
struct listNode * head;
} LinkedList;