Hi Matt,
On Sep 1, 2010, at 9:56 AM, Matt Calder wrote:
> Hi,
>
> This is perhaps a silly question, but if I create a resource, say:
>
> hid_t did = H5Dopen( loc_id, "data" );
>
> and then test,
>
> if (did >= 0) {
>
> }
>
> does it matter if I put the H5Dclose inside or outside the if-block?
> Does one leak resources in the case where did < 0 and the did is not
> closed? And, is the behavior the same for all the HDF api functions? I
> did not see any specific mention in the docs.
If H5Dopen (or any other function which returns an ID) fails (and
returns a negative value), the HDF5 library will not leak resources. BTW, the
[negative] ID value returned when one of these routines fails would be rejected
by the object close routine. It's analogous to malloc() returning NULL, you
can't pass NULL into free().
Quincey
_______________________________________________
Hdf-forum is for HDF software users discussion.
[email protected]
http://mail.hdfgroup.org/mailman/listinfo/hdf-forum_hdfgroup.org