diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2003-08-26 18:35:37 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2003-08-26 18:35:37 (GMT) |
commit | 438248d01de7c779e6b7f3b9a75c3f706bbe14f4 (patch) | |
tree | bef9581b4a471e32d4b8fc4b3c23806ac671f54b /src | |
parent | 7e9c4449d4a78e756f6935ef828bc440224a86ab (diff) | |
download | hdf5-438248d01de7c779e6b7f3b9a75c3f706bbe14f4.zip hdf5-438248d01de7c779e6b7f3b9a75c3f706bbe14f4.tar.gz hdf5-438248d01de7c779e6b7f3b9a75c3f706bbe14f4.tar.bz2 |
[svn-r7412] Purpose:
Bug fix
Description:
H5Gget_objname_by_idx should allow NULL for the 'name' parameter, to allow
for querying for the name's length.
Solution:
Allow NULL for the 'name' parameter, the internal functions were already
ready to handle that case.
Clean up RM information about H5Gget_objname_by_idx and
H5Gget_objtype_by_idx also.
Platforms tested:
FreeBSD 4.8 (sleipnir)
h5committest
Diffstat (limited to 'src')
-rw-r--r-- | src/H5G.c | 11 |
1 files changed, 6 insertions, 5 deletions
@@ -520,8 +520,6 @@ H5Gget_objname_by_idx(hid_t loc_id, hsize_t idx, char *name, size_t size) HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a location ID"); if(H5G_get_type(loc,H5AC_ind_dxpl_id)!=H5G_GROUP) HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a group"); - if (!name) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "nil pointer for name"); if (H5G_get_num_objs(loc, &num_objs, H5AC_ind_dxpl_id)<0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "unable to retrieve number of members"); @@ -2634,12 +2632,15 @@ H5G_get_objname_by_idx(H5G_entry_t *loc, hsize_t idx, char* name, size_t size, h H5G_node_name, loc->cache.stab.btree_addr, &udata))<0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "iteration operator failed"); + /* Get the length of the name */ ret_value = (ssize_t)HDstrlen(udata.name); - if(name && size>0) { - HDstrncpy(name, udata.name, MIN((size_t)(ret_value+1),size-1)); + + /* Copy the name into the user's buffer, if given */ + if(name) { + HDstrncpy(name, udata.name, MIN((size_t)(ret_value+1),size)); if((size_t)ret_value >= size) name[size-1]='\0'; - } + } /* end if */ done: /* Free the duplicated name */ |