Hi
I had a question on the memory management when converting variable-length datatypes.
Taking the following code as an example
#include "H5Cpp.h"
#include <vector>
int main()
{
std::vector<int> data{2, 3, -4, 122};
hvl_t original{data.size(), data.data()};
H5::VarLenType sourceType(&H5::PredType::NATIVE_INT);
H5::VarLenType targetType(&H5::PredType::NATIVE_DOUBLE);
// Use this to hold the converted value
hvl_t converted = original;
sourceType.convert(targetType, 1, &converted, nullptr);
}
If I look at the memory that converted.p
points to I can see that it does contain the correct bytes to represent the same numbers as doubles (including being larger).
My question is - am I responsible for freeing the memory that converted.p
points to?
I couldn’t find this information in the documentation… I don’t run into any problems if I call std::free(converted.p)
(assuming I don’t then try and access the memory) but I don’t know if that’s a solid guarantee that I’m responsible for that memory.
Cheers,
Jon