Hi there,

I've built a hashing program that works fine but I've used some hacks in it to get it working. Although it works I'm having trouble undersanding why different versions of the code dont work.

I set up the hash table as an arrray of pointers to pointers e.g.

struct record **hashtable;

hashtable = (struct record**)malloc(MAX_HASH_SIZE * sizeof(struct record *));

Now to add an element to a linked list in this hashing table I have to do

hashtable[slot] = update_list(hashtable[slot],element)

where update list returns a pointer to the same list but with the element added/updated

My question is why cant I just call update_list without having to have hashtable[slot] equal the returned value
e.g. just use

The reason i think this is that hashtable[slot] is being passed as a pointer(I think). If update_list changes the value pointed to by this pointer(which it does) shouldnt the value be changed in memory aswell.

However I'm finding that this method does not work, and all I get are seg faults. I think my reasoning behind the pointers OR syntax of the pointers is wrong, any help would be greatly appreceated



ps Sorry if this is confusing but I cant think of any other way to describe it without copius amounts of source