More fixes to make Valgrind happy
Created by: smharper
Four fixes here:
In hdf5_interface.h we had prepared buffers for xtensor arrays by using T* buffer = new T[size]
. xtensor then deallocates them with (I think) allocator<double>::deallocate
which causes Valgrind to warn about mismatched free() / delete / delete []. I've fixed that by using std::vector
as the buffer.
When we called read_attribute_string
from Fortran, the buffer was undersized by one byte. (I assume we miscounted a null character somewhere). That's fixed now.
When computing photon production cross sections, we were interpolating on a Tabulated1D
with a value equal to the first grid point in that table. In that case, our search returned an index of -1
which we then indexed an array with.
You know all those may be used uninitialized in this function
warnings we used to get with strings in hdf5_interface.F90? Valgrind helped me figure out what that was about, and it's now fixed by making sure we allocate character arrays that are declared locally in hdf5_interface.F90 rather than those with inferred length returned by to_c_string
.
There are still a few small Valgrind errors raised by calls inside the HDF5 library which probably means we've messed up a buffer or a type or something, but I'm not sure now how to track that down.