Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions src/IO/HDF5/HDF5IOHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1479,18 +1479,19 @@ HDF5IOHandlerImpl::readAttribute(Writable* writable,
{
if( H5Tis_variable_str(attr_type) )
{
char* c = nullptr;
// refs.:
// https://github.com/HDFGroup/hdf5/blob/hdf5-1_12_0/tools/src/h5dump/h5dump_xml.c
hsize_t size = H5Tget_size(attr_type); // not yet the actual string length
std::vector< char > vc(size); // byte buffer to vlen strings
status = H5Aread(attr_id,
attr_type,
c);
VERIFY(status == 0,
"[HDF5] Internal error: Failed to read attribute " + attr_name +
" at " + concrete_h5_file_position(writable));
a = Attribute(auxiliary::strip(std::string(c), {'\0'}));
status = H5Dvlen_reclaim(attr_type,
attr_space,
H5P_DEFAULT,
c);
vc.data());
auto c_str = *((char**)vc.data()); // get actual string out
a = Attribute(std::string(c_str));
// free dynamically allocated vlen memory from H5Aread
H5Dvlen_reclaim(attr_type, attr_space, H5P_DEFAULT, vc.data());
// 1.12+:
//H5Treclaim(attr_type, attr_space, H5P_DEFAULT, vc.data());
} else
{
hsize_t size = H5Tget_size(attr_type);
Expand Down