Close callgrind file on exit.
Convert to C++ make make use of std::{vector,map,string}.