Sort and Search in C
Cool! I noticed something though.
One line 47, you have:
But I don't think that's enough, because the list memory looks like this:
free(list) does this:
But you still have to deallocate the other list elements.
So I think you have to loop through the list and free each element.
@DynamicSquid If you look in
list_generate you can see that
list is allocated with
calloc, meaning you only have to free the head pointer of the array.
If I tried to free each item in the list, like this:
We would get an error, as freeing the original pointer would free the whole list:
The memory of the list actually looks more like this: