You are quite right, Jason
I also have this problem with the calls from another language - for example,
Delphi.
Thus I always have to add the following code in every new release myself:
Add free memory for functions, returning * char
in:
H5public.h
H5_DLL herr_t H5free_mem(char * memToFree);
in:
H5.c
herr_t
H5free_mem(char * memToFree)
{
herr_t ret_value = SUCCEED;
FUNC_ENTER_API(FAIL)
H5TRACE0("e","");
/* Free memory */
free(memToFree);
done:
FUNC_LEAVE_API(ret_value)
}
It would be nice to have such permanent improvement in version 1.8.12 and
higher.
Regards,
Saulius
-----Original Message-----
From: Hdf-forum [mailto:[email protected]] On Behalf Of
Jason Sommerville
Sent: Thursday, October 24, 2013 12:15 AM
To: [email protected]
Subject: [Hdf-forum] Freeing returned strings
Is there a correct way to free strings returned by functions such as
H5Tget_member_name which return a char*?
The documentation says that they should be freed after use. That's all well
and good until you're using two different memory allocators. For example,
I'm currently developing a DLL which calls into the hdf5 libraries. Since
I'm developing the dll, I'm in "_DEBUG" mode and using Microsoft's debug
memory management. Therefore, if I call free on the returned pointer, it's
likely to cause an access violation because the free routine does not match
the alloc routine (I'm using the standard library hdf5 library straight from
the web).
I found a message to the forum from back in 2009 which is almost certainly
the same issue. Unfortunately, no one responded to the poor fellow.
http://hdf-forum.184993.n3.nabble.com/free-buffer-returned-by-H5Tget-member-
name-result-in-runtime-error-in-Windows-Vista-tt194656.html
Ideally, there would be a free function exported from the HDF5 library which
could be called to properly handle the deallocation. If there is, I haven't
found it in the docs. It seems like the proper function (MMfree, or
something like that) is #defined to free. Since it's a #define, it doesn't
end up helping at all.
Thanks,
Jason
_______________________________________________
Hdf-forum is for HDF software users discussion.
[email protected]
http://mail.lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.org
_______________________________________________
Hdf-forum is for HDF software users discussion.
[email protected]
http://mail.lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.org