I'm not sure if my unload() function worked properly. I tried to use Valgrind and it said memory leaked 8mb. I tried check50 and it said I have a memory leak.
What makes you think that the problem lies with unload? What's your thought process that leads you there? Or did you jump to that conclusion because that's where all the freeing is done? (Teachable moment question.)
Valgrind is telling you that the memory that's being leaked is being allocated on line 75. What's happening to that memory as the program proceeds?
The memory leak has nothing to do with unload. Look at lines 75 and 76. Line 75 does two things. It creates a pointer AND it allocates memory to that pointer. Then, line 76 reassigns new_node, making it point at something else. This essentially abandons the memory that was allocated on line 75. That's called a memory leak. Memory is allocated and then abandoned without being freed.
Easy fix. Instead of a malloc on line 75, assign NULL to the pointer to initialize it. Better still, combine lines 75 and 76.
node *node_next = hashtable[hashIndex];
As for taking 5 seconds to finish the program, well, that's an entirely different exercise. If you want to make it run faster, you need to look at the entire design and look for ways to make it more efficient. That's a good exercise and learning opportunity for you! Besides, how do you know that 5 seconds is too long?
Finally, you may or may not find other issues that still remain, but those are for another question. ;-)
If this answers your question, please click on the check mark to accept. Let's keep up on forum maintenance. ;-)