summaryrefslogtreecommitdiffstats
path: root/src/H5Pint.c
diff options
context:
space:
mode:
authorVailin Choi <vchoi@hdfgroup.org>2013-10-18 20:03:47 (GMT)
committerVailin Choi <vchoi@hdfgroup.org>2013-10-18 20:03:47 (GMT)
commit9729a518b49a2217307c3c7ce9b33b064fc83147 (patch)
tree28b22bf7d1972b4a537bcec377778147c976420c /src/H5Pint.c
parent1bc858b1b889ae2d0eeca463646592d195db8c94 (diff)
downloadhdf5-9729a518b49a2217307c3c7ce9b33b064fc83147.zip
hdf5-9729a518b49a2217307c3c7ce9b33b064fc83147.tar.gz
hdf5-9729a518b49a2217307c3c7ce9b33b064fc83147.tar.bz2
[svn-r24332] Bring revision #24330 from revise_chunks. h5committested.
Diffstat (limited to 'src/H5Pint.c')
-rw-r--r--src/H5Pint.c26
1 files changed, 11 insertions, 15 deletions
diff --git a/src/H5Pint.c b/src/H5Pint.c
index 13cc3c1..40d0a9c 100644
--- a/src/H5Pint.c
+++ b/src/H5Pint.c
@@ -4787,9 +4787,6 @@ done:
char *
H5P_get_class_path(H5P_genclass_t *pclass)
{
- char *par_path; /* Parent class's full path */
- size_t par_path_len;/* Parent class's full path's length */
- size_t my_path_len; /* This class's name's length */
char *ret_value; /* return value */
FUNC_ENTER_NOAPI_NOINIT
@@ -4797,33 +4794,32 @@ H5P_get_class_path(H5P_genclass_t *pclass)
HDassert(pclass);
/* Recursively build the full path */
- if(pclass->parent!=NULL) {
+ if(pclass->parent != NULL) {
+ char *par_path; /* Parent class's full path */
+
/* Get the parent class's path */
- par_path=H5P_get_class_path(pclass->parent);
- if(par_path!=NULL) {
- /* Get the string lengths we need to allocate space */
- par_path_len=HDstrlen(par_path);
- my_path_len=HDstrlen(pclass->name);
+ par_path = H5P_get_class_path(pclass->parent);
+ if(par_path != NULL) {
+ size_t ret_str_len;
/* Allocate enough space for the parent class's path, plus the '/'
* separator, this class's name and the string terminator
*/
- if(NULL == (ret_value = (char *)H5MM_malloc(par_path_len + 1 + my_path_len + 1)))
+ ret_str_len = HDstrlen(par_path) + 1 + HDstrlen(pclass->name) + 1;
+ if(NULL == (ret_value = (char *)H5MM_malloc(ret_str_len)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for class name")
/* Build the full path for this class */
- HDstrcpy(ret_value,par_path);
- HDstrcat(ret_value,"/");
- HDstrcat(ret_value,pclass->name);
+ HDsnprintf(ret_value, ret_str_len, "%s/%s", par_path, pclass->name);
/* Free the parent class's path */
H5MM_xfree(par_path);
} /* end if */
else
- ret_value=H5MM_xstrdup(pclass->name);
+ ret_value = H5MM_xstrdup(pclass->name);
} /* end if */
else
- ret_value=H5MM_xstrdup(pclass->name);
+ ret_value = H5MM_xstrdup(pclass->name);
done:
FUNC_LEAVE_NOAPI(ret_value)