diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2006-11-27 18:00:08 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2006-11-27 18:00:08 (GMT) |
commit | d219ff86a8e5ce698f73f89d5f9596ee910bcf82 (patch) | |
tree | 085f937cb4ca5640dca22bfc743b67c10744973d /src | |
parent | 59208d8a9b3e0c00cb604acfb153113789e66a28 (diff) | |
download | hdf5-d219ff86a8e5ce698f73f89d5f9596ee910bcf82.zip hdf5-d219ff86a8e5ce698f73f89d5f9596ee910bcf82.tar.gz hdf5-d219ff86a8e5ce698f73f89d5f9596ee910bcf82.tar.bz2 |
[svn-r12977] Description:
Added H5Gget_info[_by_idx] routines and deprecated H5Gget_num_objs routine.
Tested on:
Linux/32 2.6 (chicago)
Linux/64 2.6 (chicago2)
Diffstat (limited to 'src')
-rw-r--r-- | src/H5G.c | 249 | ||||
-rw-r--r-- | src/H5Gdeprec.c | 62 | ||||
-rw-r--r-- | src/H5Gent.c | 2 | ||||
-rw-r--r-- | src/H5Gobj.c | 35 | ||||
-rw-r--r-- | src/H5Gpkg.h | 9 | ||||
-rw-r--r-- | src/H5Gpublic.h | 29 | ||||
-rw-r--r-- | src/H5O.c | 25 |
7 files changed, 288 insertions, 123 deletions
@@ -404,7 +404,7 @@ done: } /* end if */ FUNC_LEAVE_API(ret_value) -} /* H5Gopen() */ +} /* end H5Gopen() */ /*------------------------------------------------------------------------- @@ -489,88 +489,7 @@ done: } /* end if */ FUNC_LEAVE_API(ret_value) -} - - -/*------------------------------------------------------------------------- - * Function: H5Gclose - * - * Purpose: Closes the specified group. The group ID will no longer be - * valid for accessing the group. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Robb Matzke - * Wednesday, December 31, 1997 - * - *------------------------------------------------------------------------- - */ -herr_t -H5Gclose(hid_t group_id) -{ - herr_t ret_value=SUCCEED; /* Return value */ - - FUNC_ENTER_API(H5Gclose, FAIL); - H5TRACE1("e","i",group_id); - - /* Check args */ - if (NULL == H5I_object_verify(group_id,H5I_GROUP)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a group"); - - /* - * Decrement the counter on the group atom. It will be freed if the count - * reaches zero. - */ - if (H5I_dec_ref(group_id) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "unable to close group"); - -done: - FUNC_LEAVE_API(ret_value); -} - - -/*------------------------------------------------------------------------- - * Function: H5Gget_num_objs - * - * Purpose: Returns the number of objects in the group. It iterates - * all B-tree leaves and sum up total number of group members. - * - * Return: Success: Non-negative - * - * Failure: Negative - * - * Programmer: Raymond Lu - * Nov 20, 2002 - * - *------------------------------------------------------------------------- - */ -herr_t -H5Gget_num_objs(hid_t loc_id, hsize_t *num_objs) -{ - H5G_loc_t loc; /* Location of object */ - H5O_type_t obj_type; /* Type of object at location */ - herr_t ret_value; - - FUNC_ENTER_API(H5Gget_num_objs, FAIL) - H5TRACE2("e","i*h",loc_id,num_objs); - - /* Check args */ - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location ID") - if(H5O_obj_type(loc.oloc, &obj_type, H5AC_ind_dxpl_id) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't get object type") - if(obj_type != H5O_TYPE_GROUP) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a group") - if(!num_objs) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "nil pointer") - - /* Call private function. */ - if((ret_value = H5G_obj_count(loc.oloc, num_objs, H5AC_ind_dxpl_id)) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTCOUNT, FAIL, "can't determine ") - -done: - FUNC_LEAVE_API(ret_value) -} /* end H5Gget_num_objs() */ +} /* end H5Gopen_expand() */ /*------------------------------------------------------------------------- @@ -657,6 +576,170 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Gget_create_plist() */ + +/*------------------------------------------------------------------------- + * Function: H5Gget_info + * + * Purpose: Retrieve information about a group. + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Quincey Koziol + * November 27 2006 + * + *------------------------------------------------------------------------- + */ +herr_t +H5Gget_info(hid_t loc_id, const char *name, H5G_info_t *grp_info, hid_t lapl_id) +{ + H5G_loc_t loc; /* Location of group */ + H5G_loc_t grp_loc; /* Location used to open group */ + H5G_name_t grp_path; /* Opened object group hier. path */ + H5O_loc_t grp_oloc; /* Opened object object location */ + hbool_t loc_found = FALSE; /* Location at 'name' found */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(H5Gget_info, FAIL) + + /* Check args */ + if(H5G_loc(loc_id, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") + if(!name || !*name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name") + if(!grp_info) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no info struct") + if(H5P_DEFAULT == lapl_id) + lapl_id = H5P_LINK_ACCESS_DEFAULT; + else + if(TRUE != H5P_isa_class(lapl_id, H5P_LINK_ACCESS)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID") + + /* Set up opened group location to fill in */ + grp_loc.oloc = &grp_oloc; + grp_loc.path = &grp_path; + H5G_loc_reset(&grp_loc); + + /* Find the group object */ + if(H5G_loc_find(&loc, name, &grp_loc/*out*/, lapl_id, H5AC_ind_dxpl_id) < 0) + HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "group not found") + loc_found = TRUE; + + /* Retrieve the group's information */ + if(H5G_obj_info(grp_loc.oloc, grp_info/*out*/, H5AC_ind_dxpl_id) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't retrieve group info") + +done: + if(loc_found && H5G_loc_free(&grp_loc) < 0) + HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "can't free location") + + FUNC_LEAVE_API(ret_value) +} /* end H5Gget_info() */ + + +/*------------------------------------------------------------------------- + * Function: H5Gget_info_by_idx + * + * Purpose: Retrieve information about a group, according to the order + * of an index. + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Quincey Koziol + * November 27 2006 + * + *------------------------------------------------------------------------- + */ +herr_t +H5Gget_info_by_idx(hid_t loc_id, const char *group_name, H5L_index_t idx_type, + H5_iter_order_t order, hsize_t n, H5G_info_t *grp_info, hid_t lapl_id) +{ + H5G_loc_t loc; /* Location of group */ + H5G_loc_t grp_loc; /* Location used to open group */ + H5G_name_t grp_path; /* Opened object group hier. path */ + H5O_loc_t grp_oloc; /* Opened object object location */ + hbool_t loc_found = FALSE; /* Entry at 'name' found */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(H5Gget_info_by_idx, FAIL) + + /* Check args */ + if(H5G_loc(loc_id, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") + if(!group_name || !*group_name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified") + if(idx_type <= H5L_INDEX_UNKNOWN || idx_type >= H5L_INDEX_N) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index type specified") + if(order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified") + if(!grp_info) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no info struct") + if(H5P_DEFAULT == lapl_id) + lapl_id = H5P_LINK_ACCESS_DEFAULT; + else + if(TRUE != H5P_isa_class(lapl_id, H5P_LINK_ACCESS)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID") + + /* Set up opened group location to fill in */ + grp_loc.oloc = &grp_oloc; + grp_loc.path = &grp_path; + H5G_loc_reset(&grp_loc); + + /* Find the object's location, according to the order in the index */ + if(H5G_loc_find_by_idx(&loc, group_name, idx_type, order, n, &grp_loc/*out*/, lapl_id, H5AC_ind_dxpl_id) < 0) + HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "group not found") + loc_found = TRUE; + + /* Retrieve the group's information */ + if(H5G_obj_info(grp_loc.oloc, grp_info/*out*/, H5AC_ind_dxpl_id) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't retrieve group info") + +done: + /* Release the object location */ + if(loc_found && H5G_loc_free(&grp_loc) < 0) + HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "can't free location") + + FUNC_LEAVE_API(ret_value) +} /* end H5Gget_info_by_idx() */ + + +/*------------------------------------------------------------------------- + * Function: H5Gclose + * + * Purpose: Closes the specified group. The group ID will no longer be + * valid for accessing the group. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Robb Matzke + * Wednesday, December 31, 1997 + * + *------------------------------------------------------------------------- + */ +herr_t +H5Gclose(hid_t group_id) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(H5Gclose, FAIL); + H5TRACE1("e","i",group_id); + + /* Check args */ + if(NULL == H5I_object_verify(group_id,H5I_GROUP)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a group") + + /* + * Decrement the counter on the group atom. It will be freed if the count + * reaches zero. + */ + if(H5I_dec_ref(group_id) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "unable to close group") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Gclose() */ + /* *------------------------------------------------------------------------- *------------------------------------------------------------------------- diff --git a/src/H5Gdeprec.c b/src/H5Gdeprec.c index 2a3d150..20b3096 100644 --- a/src/H5Gdeprec.c +++ b/src/H5Gdeprec.c @@ -625,9 +625,8 @@ H5G_set_comment(H5G_loc_t *loc, const char *name, const char *buf, hid_t dxpl_id done: /* Release obj_loc */ - if(loc_valid) - if(H5G_loc_free(&obj_loc) < 0) - HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "unable to free location") + if(loc_valid && H5G_loc_free(&obj_loc) < 0) + HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "unable to free location") FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_set_comment() */ @@ -684,9 +683,8 @@ H5G_get_comment(H5G_loc_t *loc, const char *name, size_t bufsize, char *buf, hid done: /* Release obj_loc */ - if(loc_valid) - if(H5G_loc_free(&obj_loc) < 0) - HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "unable to free location") + if(loc_valid && H5G_loc_free(&obj_loc) < 0) + HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "unable to free location") FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_get_comment() */ @@ -704,6 +702,8 @@ done: * group being iterated, a member name, and OP_DATA for each * member. * + * Note: Deprecated in favor of H5Literate + * * Return: Success: The return value of the first operator that * returns non-zero, or zero if all members were * processed with no operator returning non-zero. @@ -766,7 +766,6 @@ done: * Note: Deprecated in favor of H5Lget_info/H5Oget_info * * Return: Success: H5G_GROUP(1), H5G_DATASET(2), H5G_TYPE(3) - * * Failure: H5G_UNKNOWN * * Programmer: Raymond Lu @@ -990,3 +989,52 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_get_objinfo() */ + +/*------------------------------------------------------------------------- + * Function: H5Gget_num_objs + * + * Purpose: Returns the number of objects in the group. It iterates + * all B-tree leaves and sum up total number of group members. + * + * Note: Deprecated in favor of H5Gget_info + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Raymond Lu + * Nov 20, 2002 + * + *------------------------------------------------------------------------- + */ +herr_t +H5Gget_num_objs(hid_t loc_id, hsize_t *num_objs) +{ + H5G_loc_t loc; /* Location of object */ + H5G_info_t grp_info; /* Group information */ + H5O_type_t obj_type; /* Type of object at location */ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_API(H5Gget_num_objs, FAIL) + H5TRACE2("e","i*h",loc_id,num_objs); + + /* Check args */ + if(H5G_loc(loc_id, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location ID") + if(H5O_obj_type(loc.oloc, &obj_type, H5AC_ind_dxpl_id) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't get object type") + if(obj_type != H5O_TYPE_GROUP) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a group") + if(!num_objs) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "bad pointer to # of objects") + + /* Retrieve information about the group */ + if(H5G_obj_info(loc.oloc, &grp_info, H5AC_ind_dxpl_id) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTCOUNT, FAIL, "can't determine") + + /* Set the number of objects [sic: links] in the group */ + *num_objs = grp_info.nlinks; + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Gget_num_objs() */ + diff --git a/src/H5Gent.c b/src/H5Gent.c index e011a05..56ec885 100644 --- a/src/H5Gent.c +++ b/src/H5Gent.c @@ -128,7 +128,7 @@ H5G_ent_decode(H5F_t *f, const uint8_t **pp, H5G_entry_t *ent) H5F_addr_decode(f, pp, &(ent->header)); UINT32DECODE(*pp, tmp); *pp += 4; /*reserved*/ - ent->type=(H5G_type_t)tmp; + ent->type=(H5G_cache_type_t)tmp; /* decode scratch-pad */ switch (ent->type) { diff --git a/src/H5Gobj.c b/src/H5Gobj.c index c1d81b5..45e6640 100644 --- a/src/H5Gobj.c +++ b/src/H5Gobj.c @@ -657,47 +657,60 @@ done: /*------------------------------------------------------------------------- - * Function: H5G_obj_count + * Function: H5G_obj_info * - * Purpose: Check the number of objects in a group + * Purpose: Retrieve information about a group * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol - * koziol@ncsa.uiuc.edu - * Sep 6 2005 + * koziol@hdfgroup.org + * Nov 27 2006 * *------------------------------------------------------------------------- */ herr_t -H5G_obj_count(H5O_loc_t *oloc, hsize_t *num_objs, hid_t dxpl_id) +H5G_obj_info(H5O_loc_t *oloc, H5G_info_t *grp_info, hid_t dxpl_id) { H5O_linfo_t linfo; /* Link info message */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(H5G_obj_count, FAIL) + FUNC_ENTER_NOAPI(H5G_obj_info, FAIL) /* Sanity check */ HDassert(oloc); - HDassert(num_objs); + HDassert(grp_info); /* Attempt to get the link info for this group */ if(H5O_read(oloc, H5O_LINFO_ID, 0, &linfo, dxpl_id)) { - /* Set the number of objects */ - *num_objs = linfo.nlinks; + /* Retrieve the information about the links */ + grp_info->nlinks = linfo.nlinks; + grp_info->min_corder = linfo.min_corder; + grp_info->max_corder = linfo.max_corder; + + /* Check if the group is using compact or dense storage for its links */ + if(H5F_addr_defined(linfo.link_fheap_addr)) + grp_info->storage_type = H5G_STORAGE_TYPE_DENSE; + else + grp_info->storage_type = H5G_STORAGE_TYPE_COMPACT; } /* end if */ else { /* Clear error stack from not finding the link info message */ H5E_clear_stack(NULL); /* Get the number of objects in this group by iterating over symbol table */ - if(H5G_stab_count(oloc, num_objs, dxpl_id) < 0) + if(H5G_stab_count(oloc, &grp_info->nlinks, dxpl_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTCOUNT, FAIL, "can't count objects") + + /* Set the other information about the group */ + grp_info->storage_type = H5G_STORAGE_TYPE_SYMBOL_TABLE; + grp_info->min_corder = 0; + grp_info->max_corder = 0; } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5G_obj_count() */ +} /* end H5G_obj_info() */ /*------------------------------------------------------------------------- diff --git a/src/H5Gpkg.h b/src/H5Gpkg.h index 8b23cd5..fdc0515 100644 --- a/src/H5Gpkg.h +++ b/src/H5Gpkg.h @@ -65,14 +65,14 @@ * points). This datatype determines what (if anything) is cached in the * symbol table entry. */ -typedef enum H5G_type_t { +typedef enum H5G_cache_type_t { H5G_CACHED_ERROR = -1, /*force enum to be signed */ H5G_NOTHING_CACHED = 0, /*nothing is cached, must be 0 */ H5G_CACHED_STAB = 1, /*symbol table, `stab' */ H5G_CACHED_SLINK = 2, /*symbolic link */ H5G_NCACHED /*THIS MUST BE LAST */ -} H5G_type_t; +} H5G_cache_type_t; /* * A symbol table entry caches these parameters from object header @@ -100,7 +100,7 @@ typedef union H5G_cache_t { */ typedef struct H5G_entry_t { hbool_t dirty; /*entry out-of-date? */ - H5G_type_t type; /*type of information cached */ + H5G_cache_type_t type; /*type of information cached */ H5G_cache_t cache; /*cached data from object header */ size_t name_off; /*offset of name within name heap */ haddr_t header; /*file address of object header */ @@ -510,8 +510,7 @@ H5_DLL herr_t H5G_obj_insert(H5O_loc_t *grp_oloc, const char *name, H5_DLL herr_t H5G_obj_iterate(hid_t loc_id, const char *group_name, H5L_index_t idx_type, H5_iter_order_t order, hsize_t skip, hsize_t *last_obj, H5G_link_iterate_t *lnk_op, void *op_data, hid_t dxpl_id); -H5_DLL herr_t H5G_obj_count(struct H5O_loc_t *oloc, hsize_t *num_objs, - hid_t dxpl_id); +H5_DLL herr_t H5G_obj_info(H5O_loc_t *oloc, H5G_info_t *grp_info, hid_t dxpl_id); H5_DLL ssize_t H5G_obj_get_name_by_idx(H5O_loc_t *oloc, H5L_index_t idx_type, H5_iter_order_t order, hsize_t n, char* name, size_t size, hid_t dxpl_id); H5_DLL H5G_obj_t H5G_obj_get_type_by_idx(H5O_loc_t *oloc, hsize_t idx, diff --git a/src/H5Gpublic.h b/src/H5Gpublic.h index 26e6c89..61c419a 100644 --- a/src/H5Gpublic.h +++ b/src/H5Gpublic.h @@ -38,13 +38,14 @@ /* Public Macros */ /*****************/ +/* Deprecated macros, for backward compatibility */ + /* Macros for types of objects in a group (see H5G_obj_t definition) */ #define H5G_NTYPES 256 /* Max possible number of types */ #define H5G_NLIBTYPES 8 /* Number of internal types */ #define H5G_NUSERTYPES (H5G_NTYPES-H5G_NLIBTYPES) #define H5G_USERTYPE(X) (8+(X)) /* User defined types */ -/* Deprecated macros, for backward compatibility */ #define H5G_LINK_ERROR H5L_TYPE_ERROR #define H5G_LINK_HARD H5L_TYPE_HARD #define H5G_LINK_SOFT H5L_TYPE_SOFT @@ -59,6 +60,25 @@ extern "C" { /* Public Typedefs */ /*******************/ +/* Types of link storage for groups */ +typedef enum H5G_storage_type_t { + H5G_STORAGE_TYPE_UNKNOWN = -1, /* Unknown link storage type */ + H5G_STORAGE_TYPE_SYMBOL_TABLE, /* Links in group are stored with a "symbol table" */ + /* (this is sometimes called "old-style" groups) */ + H5G_STORAGE_TYPE_COMPACT, /* Links are stored in object header */ + H5G_STORAGE_TYPE_DENSE /* Links are stored in fractal heap & indexed with v2 B-tree */ +} H5G_storage_type_t; + +/* Information struct for group (for H5Gget_info/H5Gget_info_by_idx) */ +typedef struct H5G_info_t { + H5G_storage_type_t storage_type; /* Type of storage for links in group */ + hsize_t nlinks; /* Number of links in group */ + int64_t min_corder; /* Current min. creation order value for group */ + int64_t max_corder; /* Current max. creation order value for group */ +} H5G_info_t; + +/* Deprecated typedefs, for backward compatibility */ + /* * An object has a certain type. The first few numbers are reserved for use * internally by HDF5. Users may add their own types with higher values. The @@ -104,8 +124,12 @@ H5_DLL hid_t H5Gcreate(hid_t loc_id, const char *name, size_t size_hint); H5_DLL hid_t H5Gcreate_expand(hid_t loc_id, hid_t gcpl_id, hid_t gapl_id); H5_DLL hid_t H5Gopen(hid_t loc_id, const char *name); H5_DLL hid_t H5Gopen_expand(hid_t loc_id, const char *name, hid_t gapl_id); -H5_DLL herr_t H5Gget_num_objs(hid_t loc_id, hsize_t *num_objs); H5_DLL hid_t H5Gget_create_plist(hid_t group_id); +H5_DLL herr_t H5Gget_info(hid_t loc_id, const char *name, H5G_info_t *ginfo, + hid_t lapl_id); +H5_DLL herr_t H5Gget_info_by_idx(hid_t loc_id, const char *group_name, + H5L_index_t idx_type, H5_iter_order_t order, hsize_t n, H5G_info_t *ginfo, + hid_t lapl_id); H5_DLL herr_t H5Gclose(hid_t group_id); /* Functions and variables defined for compatibility with previous versions @@ -134,6 +158,7 @@ H5_DLL herr_t H5Giterate(hid_t loc_id, const char *name, int *idx, H5_DLL H5G_obj_t H5Gget_objtype_by_idx(hid_t loc_id, hsize_t idx); H5_DLL herr_t H5Gget_objinfo(hid_t loc_id, const char *name, hbool_t follow_link, H5G_stat_t *statbuf/*out*/); +H5_DLL herr_t H5Gget_num_objs(hid_t loc_id, hsize_t *num_objs); #ifdef __cplusplus } @@ -273,10 +273,9 @@ H5Oopen(hid_t loc_id, const char *name, hid_t lapl_id) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open object") done: - if(ret_value < 0) - if(loc_found) - if(H5G_loc_free(&obj_loc) < 0) - HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "can't free location") + if(ret_value < 0 && loc_found) + if(H5G_loc_free(&obj_loc) < 0) + HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "can't free location") FUNC_LEAVE_API(ret_value) } /* end H5Oopen() */ @@ -425,10 +424,9 @@ H5Oopen_by_addr(hid_t loc_id, haddr_t addr) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open object") done: - if(ret_value < 0) - if(loc_found) - if(H5G_loc_free(&obj_loc) < 0) - HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "can't free location") + if(ret_value < 0 && loc_found) + if(H5G_loc_free(&obj_loc) < 0) + HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "can't free location") FUNC_LEAVE_API(ret_value) } /* end H5Oopen_by_addr() */ @@ -599,7 +597,7 @@ H5Oget_info(hid_t loc_id, const char *name, H5O_info_t *oinfo, hid_t lapl_id) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID") /* Retrieve the object's information */ - if(H5G_loc_info(&loc, name, oinfo/*out*/, lapl_id, H5AC_dxpl_id) < 0) + if(H5G_loc_info(&loc, name, oinfo/*out*/, lapl_id, H5AC_ind_dxpl_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "object not found") done: @@ -657,19 +655,18 @@ H5Oget_info_by_idx(hid_t loc_id, const char *group_name, H5L_index_t idx_type, H5G_loc_reset(&obj_loc); /* Find the object's location, according to the order in the index */ - if(H5G_loc_find_by_idx(&loc, group_name, idx_type, order, n, &obj_loc/*out*/, lapl_id, H5AC_dxpl_id) < 0) + if(H5G_loc_find_by_idx(&loc, group_name, idx_type, order, n, &obj_loc/*out*/, lapl_id, H5AC_ind_dxpl_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "group not found") loc_found = TRUE; /* Retrieve the object's information */ - if(H5O_get_info(obj_loc.oloc, oinfo, H5AC_dxpl_id) < 0) + if(H5O_get_info(obj_loc.oloc, oinfo, H5AC_ind_dxpl_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't retrieve object info") done: /* Release the object location */ - if(loc_found) - if(H5G_loc_free(&obj_loc) < 0) - HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "can't free location") + if(loc_found && H5G_loc_free(&obj_loc) < 0) + HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "can't free location") FUNC_LEAVE_API(ret_value) } /* end H5Oget_info_by_idx() */ |