I\'m trying to learn C and I\'m currently trying to write a basic stack data structure, but I can\'t seem to get basic malloc
/free
right.
Here\
Whenever you pass a parameter to a function, a copy is made, and the function works on that copy. So in your case, you are trying to free
a copy of the original object, which doesn't make any sense.
You should modify your function to take a pointer, and then you can have it call free
directly on that pointer.