summaryrefslogtreecommitdiffstats
path: root/fortran
diff options
context:
space:
mode:
Diffstat (limited to 'fortran')
-rw-r--r--fortran/src/H5Gf.c2
-rw-r--r--fortran/src/H5Git.c25
-rw-r--r--fortran/src/H5Git.h2
3 files changed, 19 insertions, 10 deletions
diff --git a/fortran/src/H5Gf.c b/fortran/src/H5Gf.c
index e86d342..a57b475 100644
--- a/fortran/src/H5Gf.c
+++ b/fortran/src/H5Gf.c
@@ -133,7 +133,7 @@ nh5gget_obj_info_idx_c
*/
c_loc_id = *loc_id;
c_idx = *idx;
- c_ret_value = H5Gget_obj_info_idx(c_loc_id, c_name, c_idx, &c_obj_name, &type);
+ c_ret_value = H5Gget_obj_info_idx(c_loc_id, c_name, c_idx, &c_obj_name, (size_t)*obj_namelen, &type);
if (c_ret_value < 0) {
HDfree(c_obj_name);
diff --git a/fortran/src/H5Git.c b/fortran/src/H5Git.c
index 4ffd8c8..2998753 100644
--- a/fortran/src/H5Git.c
+++ b/fortran/src/H5Git.c
@@ -10,8 +10,7 @@
#define FALSE 0
herr_t count_elems(hid_t loc_id, const char *name, void *opdata);
-/*herr_t obj_info(hid_t loc_id, const char *name, void *opdata);*/
-herr_t obj_info(hid_t loc_id, char *name, void *opdata);
+herr_t obj_info(hid_t loc_id, const char *name, void *opdata);
typedef struct retval {
char * name;
@@ -101,7 +100,7 @@ H5Gn_members( hid_t loc_id, char *group_name )
*-------------------------------------------------------------------------
*/
herr_t
-H5Gget_obj_info_idx( hid_t loc_id, char *group_name, int idx, char **objname, int *type )
+H5Gget_obj_info_idx( hid_t loc_id, char *group_name, int idx, char **objname, size_t max_objname_len, int *type )
{
int res;
retval_t retVal;
@@ -110,7 +109,19 @@ H5Gget_obj_info_idx( hid_t loc_id, char *group_name, int idx, char **objname, in
if (res < 0) {
return res;
}
- *objname = retVal.name;
+
+ /* Only play with the string if it was returned */
+ if(retVal.name!=NULL) {
+ /* Copy the name to return & truncate if necessary */
+ strncpy(*objname,retVal.name,max_objname_len);
+ (*objname)[max_objname_len]='\0';
+
+ /* Free the name we strdup'ed in obj_info() */
+ free(retVal.name);
+ } /* end if */
+ else
+ *(*objname)='\0';
+
*type = retVal.type;
return 0;
}
@@ -200,8 +211,7 @@ count_elems(hid_t loc_id, const char *name, void *opdata)
* group, or named datatype)
*/
static herr_t
-/*obj_info(hid_t loc_id, const char *name, void *opdata)*/
-obj_info(hid_t loc_id, char *name, void *opdata)
+obj_info(hid_t loc_id, const char *name, void *opdata)
{
herr_t res;
H5G_stat_t statbuf;
@@ -213,8 +223,7 @@ obj_info(hid_t loc_id, char *name, void *opdata)
return 1;
} else {
((retval_t *)opdata)->type = statbuf.type;
-/* ((retval_t *)opdata)->name = strdup(name); */
- ((retval_t *)opdata)->name = name;
+ ((retval_t *)opdata)->name = strdup(name);
return 1;
}
}
diff --git a/fortran/src/H5Git.h b/fortran/src/H5Git.h
index 7211440..20760b0 100644
--- a/fortran/src/H5Git.h
+++ b/fortran/src/H5Git.h
@@ -11,6 +11,6 @@
int H5Gn_members( hid_t loc_id, char *group_name );
-herr_t H5Gget_obj_info_idx( hid_t loc_id, char *group_name, int idx, char **objname, int *type );
+herr_t H5Gget_obj_info_idx( hid_t loc_id, char *group_name, int idx, char **objname, size_t max_objname_len, int *type );
#endif /*_H5Git_H*/