I created a hashtable with separate chaining where I put structs called Chores, here is my implementation and struct:
Code:
typedef struct Chore{
char name [8000];
unsigned long id, duration, *deps;
int hasDeps;
}*pChore;
typedef struct nodehash{ /*Node of list*/
pChore obj;
struct nodehash*next;
}*link;
And here is my functions to search a Chore by its id:
Code:
pChore search(unsigned long id){
int i = hash(id, M);
return searchAux(heads[i], id);
}
pChore searchAux(link h, unsigned long id){
link x, t = h;
for(t = h;t != NULL; t = t->next){
if(t->obj != NULL && t->obj->id == id)
x = t;
}
return x->obj;
}
I keep getting seg fault on the searchAux function and I don't know why, I feel I'm transversing the list pretty well, can someone figure out what's wrong?