I changed my insert function and now using malloc:
Code:
void insert(unsigned long long key,int value,int valueType,int depth,Entry **table){
int index = compress(key);
if(table[index] == NULL){}
Entry *entryPtr = malloc(sizeof(Entry));
entryPtr->key = key;
entryPtr->value = value;
entryPtr->valueType = valueType;
entryPtr->depth = depth;
table[index] = entryPtr;
}
else{
table[index]->key = key;
table[index]->value = value;
table[index]->valueType = valueType;
table[index]->depth = depth;
}
is this acceptable?
And another question: as for the freeing memory part, when i do a loop and set all those pointers to NULL, it doesn't free the memory does it? I am asking because I want to empty the table after every move, and I don't know if i should free all the memory or just make all those pointers NULL again.