From 956bb8ceb5a5d353c0b00cf3e599c8beb64fd0f3 Mon Sep 17 00:00:00 2001 From: Daniel Garcia-Sanchez Date: Wed, 15 Aug 2018 00:12:26 +0200 Subject: [PATCH] Get the pointer to the raw data of FullMatrix --- source/base/hdf5.cc | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/source/base/hdf5.cc b/source/base/hdf5.cc index d1c5a96e66..e040012f02 100644 --- a/source/base/hdf5.cc +++ b/source/base/hdf5.cc @@ -136,7 +136,8 @@ namespace HDF5 get_container_pointer(FullMatrix &data) { // It is very important to pass the variable "data" by reference otherwise - // the pointer will be wrong + // the pointer will be wrong. + // Use the first element of FullMatrix to get the pointer to the raw data return &data[0][0]; } @@ -210,11 +211,7 @@ namespace HDF5 // user has to free the memory. // // Todo: - // - In debug mode, check the type of the attribute. If it is not a variable - // length string raise an exception - // - Use valgrind to check that there are no memory leaks // - Use H5Dvlen_reclaim instead of free - // - Use collective char * string_out; hid_t attr; @@ -514,9 +511,8 @@ namespace HDF5 plist = H5P_DEFAULT; } - // The iterator of FullMatrix has to be converted to a pointer to the raw - // data - H5Dwrite(*hdf5_reference, *t_type, H5S_ALL, H5S_ALL, plist, &*data.begin()); + // Use the first element of FullMatrix to get the pointer to the raw data + H5Dwrite(*hdf5_reference, *t_type, H5S_ALL, H5S_ALL, plist, &data[0][0]); if (mpi) { -- 2.39.5