I have a problem with my Linked List and the valgrind output. Without further adieu here is my linked list:
typedef struct Map map;
struct Map
{
void *addr
One problem that I see is that in delete_map_node
you free root
(which might be map_list
passed from find_and_free_address
), but you don't actually change map_list
which means that when delete_map_node
returns the map_list
variable points to unallocated memory. Accessing map_list
afterwards leads to undefined behavior.
The simple solution to this is to assign the return value of delete_map_node
to map_list
:
map_list = delete_map_node(map_list, current->free_time);
Also, what happens when delete_map_node
frees the node in the list that is current
in the find_and_free_address
function? Then current = current->next
will also lead to undefined behavior.