diff --git a/include/openmc/hdf5_interface.h b/include/openmc/hdf5_interface.h index ea4284cb82..f0b3a245c7 100644 --- a/include/openmc/hdf5_interface.h +++ b/include/openmc/hdf5_interface.h @@ -162,8 +162,7 @@ void read_attribute(hid_t obj_id, const char* name, xt::xarray& arr) std::size_t size = 1; for (const auto x : shape) size *= x; - std::vector buffer; - buffer.resize(size); + std::vector buffer(size); // Read data from attribute read_attr(obj_id, name, H5TypeMap::type_id, buffer.data()); @@ -245,8 +244,7 @@ void read_dataset(hid_t dset, xt::xarray& arr, bool indep=false) std::size_t size = 1; for (const auto x : shape) size *= x; - std::vector buffer; - buffer.resize(size); + std::vector buffer(size); // Read data from attribute read_dataset(dset, nullptr, H5TypeMap::type_id, buffer.data(), indep); @@ -275,8 +273,7 @@ void read_dataset_as_shape(hid_t obj_id, const char* name, std::size_t size = 1; for (const auto x : arr.shape()) size *= x; - std::vector buffer; - buffer.resize(size); + std::vector buffer(size); // Read data from attribute read_dataset(dset, nullptr, H5TypeMap::type_id, buffer.data(), indep);