summaryrefslogtreecommitdiffstats
path: root/fortran
diff options
context:
space:
mode:
Diffstat (limited to 'fortran')
-rw-r--r--fortran/src/H5Pf.c26
-rw-r--r--fortran/test/fortranlib_test_1_8.f9010
2 files changed, 21 insertions, 15 deletions
diff --git a/fortran/src/H5Pf.c b/fortran/src/H5Pf.c
index dba2aa4..262ce55 100644
--- a/fortran/src/H5Pf.c
+++ b/fortran/src/H5Pf.c
@@ -3370,14 +3370,15 @@ nh5pclose_class_c(hid_t_f *cls)
ret_value = 0;
return ret_value;
}
+
/****if* H5Pf/h5pget_class_name_c
* NAME
* h5pget_class_name_c
* PURPOSE
* Call H5Pget_class_name to get property class name
* INPUTS
- * cls - identifier of property class
- * name - ibuffer to retrieve name in
+ * cls - identifier of property class
+ * name - buffer to retrieve name in
* name_len - length of the "name" buffer
* RETURNS
* 0 on success, -1 on failure
@@ -3393,30 +3394,25 @@ nh5pget_class_name_c(hid_t_f *cls, _fcd name, int_f *name_len)
/******/
{
int_f ret_value = -1;
- char *c_name = NULL; /* Buffer to hold C string */
- size_t c_size;
- c_size = (size_t)*name_len + 1;
-
- /*
- * Allocate buffer to hold name
- */
- if(NULL == (c_name = (char *)HDmalloc(c_size)))
- goto DONE;
+ /* Buffer to return name by C function */
+ char *c_name;
/*
- * Call H5Pget_class_name function.
+ * Call H5Pget_class_name function. c_name is allocated by the library,
+ * has to be freed by application.
*/
- c_name = H5Pget_class_name((hid_t)*cls);
- if(c_name == NULL) goto DONE;
+ if(NULL == (c_name = H5Pget_class_name((hid_t)*cls)))
+ goto DONE;
HD5packFstring(c_name, _fcdtocp(name), (size_t)*name_len);
ret_value = (int_f)HDstrlen(c_name);
+ HDfree(c_name);
DONE:
- HDfree(c_name);
return ret_value;
}
+
/****if* H5Pf/h5psetc_c
* NAME
* h5psetc_c
diff --git a/fortran/test/fortranlib_test_1_8.f90 b/fortran/test/fortranlib_test_1_8.f90
index d3ced72..dc45560 100644
--- a/fortran/test/fortranlib_test_1_8.f90
+++ b/fortran/test/fortranlib_test_1_8.f90
@@ -196,6 +196,16 @@ SUBROUTINE test_genprop_basic_class(cleanup, total_error)
INTEGER :: size
LOGICAL :: flag
+ !/* Output message about test being performed */
+
+ !WRITE(*,*) "Testing Basic Generic Property List Class Creation Functionality"
+
+ ! Try some bogus value for class identifier; function should fail gracefully
+
+ cid1 = 456
+ CALL H5Pget_class_name_f(cid1, name, size, error)
+ CALL VERIFY("H5Pget_class_name", error, -1, error)
+
! /* Create a new generic class, derived from the root of the class hierarchy */
CALL H5Pcreate_class_f(H5P_ROOT_F, CLASS1_NAME, cid1, error)
CALL check("H5Pcreate_class", error, total_error)