mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-27 21:55:41 -04:00
Fix memory errors caught by Valgrind
This commit is contained in:
parent
e6ae490a31
commit
5dc68fb665
2 changed files with 4 additions and 7 deletions
|
|
@ -282,17 +282,14 @@ void read_dataset(hid_t dset, xt::xarray<T>& arr, bool indep=false)
|
|||
// Get shape of dataset
|
||||
std::vector<hsize_t> shape = object_shape(dset);
|
||||
|
||||
// Allocate new array to read data into
|
||||
// Allocate space in the array to read data into
|
||||
std::size_t size = 1;
|
||||
for (const auto x : shape)
|
||||
size *= x;
|
||||
T* buffer = new T[size];
|
||||
arr.resize(shape);
|
||||
|
||||
// Read data from attribute
|
||||
read_dataset(dset, nullptr, H5TypeMap<T>::type_id, buffer, indep);
|
||||
|
||||
// Adapt into xarray
|
||||
arr = xt::adapt(buffer, size, xt::acquire_ownership(), shape);
|
||||
read_dataset(dset, nullptr, H5TypeMap<T>::type_id, arr.data(), indep);
|
||||
}
|
||||
|
||||
template<>
|
||||
|
|
|
|||
|
|
@ -413,7 +413,7 @@ void Nuclide::init_grid()
|
|||
while (std::log(grid.energy[j + 1]/E_min) <= umesh(k)) {
|
||||
// Ensure that for isotopes where maxval(grid.energy) << E_max that
|
||||
// there are no out-of-bounds issues.
|
||||
if (j + 1 == grid.energy.size()) break;
|
||||
if (j + 2 == grid.energy.size()) break;
|
||||
++j;
|
||||
}
|
||||
grid.grid_index[k] = j;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue