On the below program, I need to call free() on Hash Table, List Elements and Unique words. I tried couple things but all either break the program or increases error messages. Some attempts are in comments and bold.
Does anyone know where and how to call free? Its confusing as pointers are involved.
h_ptr *htable;
int tsize;
void new_table(int size)
{
tsize = size;
htable = (h_ptr *) calloc(size, sizeof(h_ptr));
if (!htable) {
fprintf(stderr, "Couldn't allocate hash array, exiting\n");
exit(1);
}
for(int i=0; i<size; i++)
{
htable[i]=NULL;
}
}