I'm writing an interface for HDF5 library for Delphi. So far I imported most of the library procedures; I can now successfully browse HDF5 files (query groups/datasets/attributes) and read data.
However I'm facing a problem regarding variable-length string attributes. When reading such attribute, HDF5 library does the memory allocation; but I couldn't find a documented way to properly free the memory.
I'm now using the following code, and it seems to do the job. But using H5Dvlen_reclaim for attribute data isn't probably correct (as H5D prefix suggests).
var
Attribute: IHDF5Attribute;
MemType: IHDF5Type;
Data: Pointer;
begin
Attribute := GetAttribute(AObj, AName);
MemType := THDF5Type.Create(
Dll.H5Tcopy(Dll.H5T_C_S1),
Dll.H5Tclose);
Dll.H5Tset_size(MemType.ID, H5T_VARIABLE);
Dll.H5Aread(Attribute.ID, MemType.ID, @Data);
try
// use Data
finally
Dll.H5Dvlen_reclaim(GetType(Attribute).ID,
GetSpace(Attribute).ID, H5P_DEFAULT, @Data);
end;
end;
What is the proper way to free the memory allocated by H5Aread for variable-length data?
Best wishes,
Andrey Paramonov
···
--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
I'm writing an interface for HDF5 library for Delphi. So far I imported most
of the library procedures; I can now successfully browse HDF5 files (query
groups/datasets/attributes) and read data.
However I'm facing a problem regarding variable-length string attributes.
When reading such attribute, HDF5 library does the memory allocation; but I
couldn't find a documented way to properly free the memory.
I'm now using the following code, and it seems to do the job. But using
H5Dvlen_reclaim for attribute data isn't probably correct (as H5D prefix
suggests).
var
Attribute: IHDF5Attribute;
MemType: IHDF5Type;
Data: Pointer;
begin
Attribute := GetAttribute(AObj, AName);
MemType := THDF5Type.Create(
Dll.H5Tcopy(Dll.H5T_C_S1),
Dll.H5Tclose);
Dll.H5Tset_size(MemType.ID, H5T_VARIABLE);
Dll.H5Aread(Attribute.ID, MemType.ID, @Data);
try
// use Data
finally
Dll.H5Dvlen_reclaim(GetType(Attribute).ID,
GetSpace(Attribute).ID, H5P_DEFAULT, @Data);
end;
end;
What is the proper way to free the memory allocated by H5Aread for
variable-length data?
Best wishes,
Andrey Paramonov
--
This message has been scanned for viruses and dangerous content by
MailScanner, and is believed to be clean.