summaryrefslogtreecommitdiffstats
path: root/src/H5G.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2003-08-26 18:37:33 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2003-08-26 18:37:33 (GMT)
commit15e1a2c0c0d53d264a5b4ea4f28d7beba6ccf1bd (patch)
treebd9d8d1d93916068eef38c224587a657e6828662 /src/H5G.c
parentff8132d5103a0a0399bd6cbc1faf6168c92db806 (diff)
downloadhdf5-15e1a2c0c0d53d264a5b4ea4f28d7beba6ccf1bd.zip
hdf5-15e1a2c0c0d53d264a5b4ea4f28d7beba6ccf1bd.tar.gz
hdf5-15e1a2c0c0d53d264a5b4ea4f28d7beba6ccf1bd.tar.bz2
[svn-r7413] 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/H5G.c')
-rw-r--r--src/H5G.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/H5G.c b/src/H5G.c
index 1ab8f66..1dd9544 100644
--- a/src/H5G.c
+++ b/src/H5G.c
@@ -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");
@@ -2669,12 +2667,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 */