I have been having trouble getting my program to free memory correctly. I believe the problem occurs when I try and free the memory of the block array. I figured out how to free the memory for the name of the jpeg (fileName). Whenever I free the memory in the spaces I commented out, I get an "Abort (core dumped)" after a backtrace and memory map. The program compiles and runs correctly as long as I do not try to free the memory of the block array.
[MOD: Removed the code as I found the solution]
Valgrind outputs that I have 5280 bytes in 15 blocks at exit. It also says that I have done 33 allocs and 34 frees. This only occurs when I have the
free(block) in use. Otherwise it says the same 5280 bytes in 15 blocks, but 33 allocs and 18 frees.