testing
+5 −4 · 2 files changed
-
mylib/src/myhash.c+1 −0 -
mylib/test/t_hash.c+4 −4
@@ -112,6 +112,7 @@ HashNode *h_insert (HashTable *hTable, char *key, char *value) { hTable->h_items[resultHash] = newNode; } else { // Keys are the same , reeuse key and assign a different value + 1 for '/0' + // Latest value will be used for the key. newNode->h_value = (char *) realloc((void *) newNode->h_value, strlen(value)+1); newNode->h_value = strcpy(newNode->h_value,value); } @@ -114,7 +114,7 @@ static char *readFile(char *fn) { // Allocate string that can hold all of the data // includes + 1 for null character + 1 to codfy end of file for Tuple - buf = (char *) malloc(sizeof(char) * (s.st_size + 2)); + buf = (char *) malloc(s.st_size + 2); // read readSize = fread(buf, sizeof(char), s.st_size, stream); @@ -148,9 +148,9 @@ int main(int argc, char** argv){ // initialise filename to NULL char *fileRead = NULL; - + // the two strings need to be stored char *format,*format0; - + // local data strucure to store strucutre struct Tuple kv_tuple; if (argc != 2) { @@ -161,6 +161,7 @@ int main(int argc, char** argv){ // fileread from filename fileRead = readFile(fn); format = t_parseBuff(fileRead); + // save format0 = format; while (kv_format(&kv_tuple,&format)) { @@ -173,7 +174,6 @@ int main(int argc, char** argv){ if(++counter == 50) break; } - } dumpTable(tableResult,0);