Starting with names5.c, replace the line at the end of main()

   // here we are lazy and do not free the list.

with a loop that calls free() on every malloc’d pointer in the list - so all malloc’d memory is free. Be careful!

You will also need to copy readlinep.h and readlinep.c along with names5.c to compile it successfully.

cp /thayerfs/courses/22spring/cosc050/workspace/names5.c . 
cp /thayerfs/courses/22spring/cosc050/workspace/readlinep.[hc] .
mygcc -o names names5.c readlinep.c

Solution

names5-free.c