Freeing memory for dynamically allocated hashmap with structs as values – C

I have followed a few tutorials for hashmaps in c. From the code you can probably tell I relied heavily on this implementation which has a nice follow up video where he revisits it to show how he would free the hashmap link. My problem is I can’t seem to remove my memory leaks when… Read More Freeing memory for dynamically allocated hashmap with structs as values – C

How do I free memory allocated to a void* member of a struct in my c project without breaking my GoogleTest project?

I’m trying to free all the memory allocated in testing_malloc() with the method testing_free(). I am using a Google Test project to test my code and the MemoryLeakDetector mentioned in this answer. However, when I try to free the private_data I get the following heap corruption error. HEAP CORRUPTION DETECTED: after Normal block (#835) at… Read More How do I free memory allocated to a void* member of a struct in my c project without breaking my GoogleTest project?

Why am I getting an invalid pointer error when I try to free malloced pointers?

I’m trying to learn about how arrays of strings can be created in C using malloc (i.e. dynamically sized arrays of strings). I can get everything working but I’m getting an "invalid pointer" error when I try to free the char* pointers stored in namesArray->data[0] and namesArray->data[1] But if I don’t use free on these… Read More Why am I getting an invalid pointer error when I try to free malloced pointers?