I have been trying to free memory allocated via malloc() using free().
malloc()
free()
Some of the structs it does free but leaves some the way they were a
The function free takes a pointer to allocated memory, it does not however set that pointer to NULL, in fact there is no way it could do so (it would need to take the address of a pointer for that).
free
NULL
Typical use case in this scenario is:
free(myptr); myptr = NULL;