I have a HDF5 based application to read the hdf5 file which has dataset 
values with number of dimensions 2. I am using HDF 1.10.1 Windows10 x64. 
I allocate array of pointers to read the data values in the same way as 
given in the hdf5 documentation. Here is the code which is reading the 
dataset values.
In this code, the dynamic 2D array of pointers is not initialized as per 
the standard way using a loop.

unique_ptr<T*[]> apbuffer = make_unique<T*[]>(size_of_dimensions[0]);
T** buffer = apbuffer.get();
unique_ptr<T[]> apbuffer1 = make_unique<T[]>(size_of_dimensions[0] * 
size_of_dimensions[1]); 
buffer[0] = apbuffer1.get();
for (int i = 1; i < size_of_dimensions[0]; i++)  { 
        buffer[i] = buffer[0] + i * size_of_dimensions[1];
}
H5Dread(dataset_id, dataset_type_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, 
buffer[0]);

Can we allocate the buffer like the below code?
T** buffer= new T*[dims[0]];
for(int i = 0; i < dims[0]; ++i)
    buffer[i] = new T[dims[1]];

I would like to know, what are other possible ways to allocate the buffer 
to read 2 dimension dataset values?
Any insight is greatly appreciated. 
_______________________________________________
Hdf-forum is for HDF software users discussion.
Hdf-forum@lists.hdfgroup.org
http://lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.org
Twitter: https://twitter.com/hdf5

Reply via email to