summaryrefslogtreecommitdiffstats
path: root/src/H5Tcommit.c
diff options
context:
space:
mode:
authorJames Laird <jlaird@hdfgroup.org>2006-08-18 20:48:54 (GMT)
committerJames Laird <jlaird@hdfgroup.org>2006-08-18 20:48:54 (GMT)
commit75d22ed839a6b7a5e048ac52708d04eb4ad590d3 (patch)
tree6a564780972e92f08cd4f8fd633945dd10180401 /src/H5Tcommit.c
parente8c1fdd5545240b47ea996be3db3fa9e27fb42a0 (diff)
downloadhdf5-75d22ed839a6b7a5e048ac52708d04eb4ad590d3.zip
hdf5-75d22ed839a6b7a5e048ac52708d04eb4ad590d3.tar.gz
hdf5-75d22ed839a6b7a5e048ac52708d04eb4ad590d3.tar.bz2
[svn-r12596] Refactored how external files are opened and closed.
Object header locations (H5O_loc_t's) can now "hold open" a file and decrement its open object count when they close. This means that locations (H5O_loc_t's and H5G_loc_t's) should always be freed. Added more thorough tests to ensure that external files are closed.
Diffstat (limited to 'src/H5Tcommit.c')
-rw-r--r--src/H5Tcommit.c27
1 files changed, 22 insertions, 5 deletions
diff --git a/src/H5Tcommit.c b/src/H5Tcommit.c
index cccee9e..8527c96 100644
--- a/src/H5Tcommit.c
+++ b/src/H5Tcommit.c
@@ -79,6 +79,10 @@ H5Tcommit(hid_t loc_id, const char *name, hid_t type_id)
{
H5G_loc_t loc;
H5G_loc_t type_loc;
+ H5G_loc_t insertion_loc; /* Loc of group in which to create object */
+ H5G_name_t insert_path; /* Path of group in which to create object */
+ H5O_loc_t insert_oloc; /* oloc of group in which to create object */
+ hbool_t insert_loc_valid = FALSE; /* Is insertion_loc valid? */
H5F_t *file;
H5T_t *type = NULL;
hbool_t uncommit = FALSE; /* TRUE if H5T_commit needs to be undone */
@@ -96,9 +100,14 @@ H5Tcommit(hid_t loc_id, const char *name, hid_t type_id)
if(NULL == (type = H5I_object_verify(type_id, H5I_DATATYPE)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype")
- /* Find the insertion file */
- if(NULL == (file = H5G_insertion_file(&loc, name, H5AC_dxpl_id)))
- HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to find insertion point")
+ /* What file is the datatype being added to? */
+ insertion_loc.path = &insert_path;
+ insertion_loc.oloc = &insert_oloc;
+ H5G_loc_reset(&insertion_loc);
+ if(H5G_insertion_loc(&loc, name, &insertion_loc, H5AC_dxpl_id) < 0)
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to locate insertion point")
+ insert_loc_valid=TRUE;
+ file = insertion_loc.oloc->file;
/* Record the type's state so that we can revert to it if linking fails */
old_state = type->shared->state;
@@ -118,6 +127,10 @@ H5Tcommit(hid_t loc_id, const char *name, hid_t type_id)
}
done:
+ if(insert_loc_valid) {
+ if(H5G_loc_free(&insertion_loc) < 0)
+ HDONE_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "unable to free location")
+ }
/* If the datatype was committed but couldn't be linked, we need to return it to the state it was in
* before it was committed. */
if(TRUE == uncommit)
@@ -455,7 +468,7 @@ done:
H5T_close(type);
else {
if(obj_found && H5F_addr_defined(type_loc.oloc->addr))
- H5G_name_free(type_loc.path);
+ H5G_loc_free(&type_loc);
} /* end else */
} /* end if */
@@ -536,7 +549,7 @@ done:
H5T_close(type);
else {
if(obj_found && H5F_addr_defined(type_loc.oloc->addr))
- H5G_name_free(type_loc.path);
+ H5G_loc_free(&type_loc);
} /* end else */
} /* end if */
@@ -637,6 +650,10 @@ done:
if(dt) {
if(shared_fo == NULL) /* Need to free shared fo */
H5FL_FREE(H5T_shared_t, dt->shared);
+
+ H5O_loc_free(&(dt->oloc));
+ H5G_name_free(&(dt->path));
+
H5FL_FREE(H5T_t, dt);
} /* end if */