Dynamic Hash Table Implementation
I'm working on a hash table that expands in size dynamically as it fills up. Basically when the existing table is a certain percentage (say 90%) full i want to double it in size. I propose to use a pointer to my struct (list struct for chaining) and then allocating memory e.g. realloc(table_size*sizeof(struct)). The only problem with this is that my hash function will rely on the table size so changing the table size will change the hash values, rendering data in the table 'unreachable'.
Can anyone recommend a solution to this - the only thing I can think to do is build a completely new table each time it is resized which is obviously inefficient.