bug fixes
[IRC.git] / Robust / src / Runtime / DSTM / interface / clookup.c
index 45ac76c6cbbaa7e2398150010eb27de72e8b72ae..e7bb74e84485554313c2564fb852e5f0eed94100 100644 (file)
@@ -66,12 +66,10 @@ unsigned int chashInsert(chashtable_t *table, unsigned int key, void *val) {
 
 // Search for an address for a given oid
 void *chashSearch(chashtable_t *table, unsigned int key) {
-       int index;
-       chashlistnode_t *ptr, *node;
+       int index = chashFunction(table, key);
+       chashlistnode_t *ptr =table -> table;
+       chashlistnode_t *node = &ptr[index];
 
-       ptr = table->table;
-       index = chashFunction(table, key);
-       node = &ptr[index];
        while(node != NULL) {
                if(node->key == key) {
                        return node->val;
@@ -177,12 +175,12 @@ unsigned int chashResize(chashtable_t *table, unsigned int newsize) {
 }
 
 //Delete the entire hash table
-void chashDelete(chashtable_t *table) {
+void chashDelete(chashtable_t *ctable) {
        int i, isFirst;
        chashlistnode_t *ptr, *curr, *next;
-       ptr = table->table;
+       ptr = ctable->table;
 
-       for(i=0 ; i<table->size ; i++) {
+       for(i=0 ; i<ctable->size ; i++) {
                curr = &ptr[i];
                isFirst = 1 ;
                while(curr  != NULL) {
@@ -196,6 +194,7 @@ void chashDelete(chashtable_t *table) {
        }
 
        free(ptr);
-       free(table);
-       table = NULL;
+       ptr = NULL;
+       free(ctable);
+       ctable = NULL;
 }