summaryrefslogtreecommitdiffstats
path: root/fortran
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2010-01-23 04:39:40 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2010-01-23 04:39:40 (GMT)
commitfcc03a356b4dd5e58cc88b692b3d05d75b8ae5d0 (patch)
treea18fedef2b670c044913622650ef581dedce7ee1 /fortran
parent2c872f398b3824c416d42f2018c3d3ea0c40e80f (diff)
downloadhdf5-fcc03a356b4dd5e58cc88b692b3d05d75b8ae5d0.zip
hdf5-fcc03a356b4dd5e58cc88b692b3d05d75b8ae5d0.tar.gz
hdf5-fcc03a356b4dd5e58cc88b692b3d05d75b8ae5d0.tar.bz2
[svn-r18157] Description:
Bring back changes from Coverity session on 1/15/10: r18111: Fix Coverity issue #130: make certain that the cache gets freed on error. r18112: Fix Coverity issue #43 by making cache testing calls protected by 'pass' variable. r18113: Fix Coverity issue #129 by releasing the cache on error. r18115: Coverity #45 fix: patched an error check in H5Screate_simple to prevent future dereferencing of a NULL point. Added a verification in test/th5s.c. r18116: Fix Coverity issue #43 by releasing cache on error. r18117: Coverity #362,363 by adding HGOTO_DONE, freeing allocations and associated changes. REsolving coverity results #364-368, 369, 370-372, 377, 379, and 380. r18118: Fix Coverity issue #42: assert that cache & test specification pointer are valid. r18122: Coverity #362,363 by adding HGOTO_DONE and freeing allocations. This also takes care of #357,358. r18123: Coverity #359-361, 373-376: Added HGOTO_DONE(FAIL) statement after checking allocation for NULL. Verified allocation is freed in done block. r18128: Fixed coverity issue #10 -- removed dead code. Tested on: Mac OS X/32 10.6.2 (amazon)
Diffstat (limited to 'fortran')
-rw-r--r--fortran/src/H5Af.c123
-rw-r--r--fortran/src/H5Ef.c189
-rw-r--r--fortran/src/H5Lf.c213
-rw-r--r--fortran/src/H5Pf.c155
-rw-r--r--fortran/src/H5Sf.c334
-rw-r--r--fortran/test/t.c37
6 files changed, 485 insertions, 566 deletions
diff --git a/fortran/src/H5Af.c b/fortran/src/H5Af.c
index 37718b9..939fd81 100644
--- a/fortran/src/H5Af.c
+++ b/fortran/src/H5Af.c
@@ -1196,32 +1196,27 @@ nh5adelete_by_idx_c (hid_t_f *loc_id, _fcd obj_name, size_t_f *obj_namelen,
int_f *idx_type, int_f *order, hsize_t_f *n, hid_t_f *lapl_id)
{
char *c_obj_name = NULL; /* Buffer to hold C string */
- H5_index_t c_idx_type;
- H5_iter_order_t c_order;
int_f ret_value = 0; /* Return value */
/*
* Convert FORTRAN name to C name
*/
- if((c_obj_name = HD5f2cstring(obj_name, (size_t)*obj_namelen)) == NULL)
- HGOTO_DONE(FAIL);
-
- c_idx_type = (H5_index_t)*idx_type;
- c_order = (H5_iter_order_t)*order;
+ if(NULL == (c_obj_name = HD5f2cstring(obj_name, (size_t)*obj_namelen)))
+ HGOTO_DONE(FAIL)
/*
* Call H5Adelete_by_name function.
*/
-
- if(H5Adelete_by_idx((hid_t)*loc_id, c_obj_name, c_idx_type, c_order, (hsize_t)*n, (hid_t)*lapl_id) < 0)
- HGOTO_DONE(FAIL);
-
+ if(H5Adelete_by_idx((hid_t)*loc_id, c_obj_name, (H5_index_t)*idx_type, (H5_iter_order_t)*order, (hsize_t)*n, (hid_t)*lapl_id) < 0)
+ HGOTO_DONE(FAIL)
done:
if(c_obj_name)
HDfree(c_obj_name);
+
return ret_value;
}
+
/*----------------------------------------------------------------------------
* Name: h5aget_name_by_idx_c
* Purpose: Call h5aget_name_by_idx
@@ -1264,45 +1259,43 @@ nh5aget_name_by_idx_c (hid_t_f *loc_id, _fcd obj_name, size_t_f *obj_namelen,
size_t_f *size, hid_t_f *lapl_id)
{
char *c_obj_name = NULL; /* Buffer to hold C string */
- H5_index_t c_idx_type;
- H5_iter_order_t c_order;
- int_f ret_value = -1; /* Return value */
ssize_t c_size;
size_t c_buf_size;
- char *c_buf =NULL;
- /*
- * Convert FORTRAN name to C name
- */
- if((c_obj_name = HD5f2cstring(obj_name, (size_t)*obj_namelen)) == NULL)
- HGOTO_DONE(FAIL);
+ char *c_buf = NULL;
+ int_f ret_value = 0; /* Return value */
- c_idx_type = (H5_index_t)*idx_type;
- c_order = (H5_iter_order_t)*order;
+ /*
+ * Convert FORTRAN name to C name
+ */
+ if(NULL == (c_obj_name = HD5f2cstring(obj_name, (size_t)*obj_namelen)))
+ HGOTO_DONE(FAIL)
/*
* Allocate buffer to hold name of an attribute
*/
c_buf_size = (size_t)*size + 1;
- c_buf = (char *)HDmalloc(c_buf_size);
- if (c_buf == NULL) return ret_value;
+ if(NULL == (c_buf = (char *)HDmalloc(c_buf_size)))
+ HGOTO_DONE(FAIL)
+
/*
* Call H5Aget_name_by_idx function.
*/
- c_size = H5Aget_name_by_idx((hid_t)*loc_id, c_obj_name, c_idx_type, c_order, (hsize_t)*n, c_buf, c_buf_size,(hid_t)*lapl_id);
+ c_size = H5Aget_name_by_idx((hid_t)*loc_id, c_obj_name, (H5_index_t)*idx_type, (H5_iter_order_t)*order, (hsize_t)*n, c_buf, c_buf_size,(hid_t)*lapl_id);
+ if(c_size < 0)
+ HGOTO_DONE(FAIL)
- if (c_size < 0) goto done;
/*
* Convert C name to FORTRAN and place it in the given buffer
*/
- HD5packFstring(c_buf, _fcdtocp(name), c_buf_size-1);
+ HD5packFstring(c_buf, _fcdtocp(name), c_buf_size - 1);
*size = (size_t_f)c_size;
- ret_value = 0;
done:
if(c_obj_name)
- HDfree(c_obj_name);
- HDfree(c_buf);
+ HDfree(c_obj_name);
+ if(c_buf)
+ HDfree(c_buf);
return ret_value;
}
@@ -1339,27 +1332,24 @@ nh5aopen_by_idx_c (hid_t_f *loc_id, _fcd obj_name, size_t_f *obj_namelen,
int_f *idx_type, int_f *order, hsize_t_f *n, hid_t_f *aapl_id, hid_t_f *lapl_id, hid_t_f *attr_id )
{
char *c_obj_name = NULL; /* Buffer to hold C string */
- H5_index_t c_idx_type;
- H5_iter_order_t c_order;
int_f ret_value = 0; /* Return value */
- /*
- * Convert FORTRAN name to C name
- */
- if((c_obj_name = HD5f2cstring(obj_name, (size_t)*obj_namelen)) == NULL)
- HGOTO_DONE(FAIL);
-
- c_idx_type = (H5_index_t)*idx_type;
- c_order = (H5_iter_order_t)*order;
+ /*
+ * Convert FORTRAN name to C name
+ */
+ if(NULL == (c_obj_name = HD5f2cstring(obj_name, (size_t)*obj_namelen)))
+ HGOTO_DONE(FAIL)
/*
* Call H5Aopen_by_idx function.
*/
- if((*attr_id = (hid_t_f)H5Aopen_by_idx((hid_t)*loc_id, c_obj_name, c_idx_type, c_order, (hsize_t)*n, (hid_t)*aapl_id, (hid_t)*lapl_id)) < 0)
- HGOTO_DONE(FAIL);
+ if((*attr_id = (hid_t_f)H5Aopen_by_idx((hid_t)*loc_id, c_obj_name, (H5_index_t)*idx_type, (H5_iter_order_t)*order, (hsize_t)*n, (hid_t)*aapl_id, (hid_t)*lapl_id)) < 0)
+ HGOTO_DONE(FAIL)
+
done:
if(c_obj_name)
HDfree(c_obj_name);
+
return ret_value;
}
@@ -1445,36 +1435,34 @@ nh5aget_info_by_idx_c (hid_t_f *loc_id, _fcd obj_name, size_t_f *obj_namelen,
int_f *cset, hsize_t_f *data_size )
{
char *c_obj_name = NULL; /* Buffer to hold C string */
- H5_index_t c_idx_type;
- H5_iter_order_t c_order;
- int_f ret_value = 0; /* Return value */
H5A_info_t ainfo;
+ int_f ret_value = 0; /* Return value */
/*
* Convert FORTRAN name to C name
*/
- if((c_obj_name = HD5f2cstring(obj_name, (size_t)*obj_namelen)) == NULL)
- HGOTO_DONE(FAIL);
+ if(NULL == (c_obj_name = HD5f2cstring(obj_name, (size_t)*obj_namelen)))
+ HGOTO_DONE(FAIL)
- c_idx_type = (H5_index_t)*idx_type;
- c_order = (H5_iter_order_t)*order;
/*
* Call H5Ainfo_by_idx function.
*/
- if(H5Aget_info_by_idx((hid_t)*loc_id, c_obj_name, c_idx_type, c_order, (hsize_t)*n,
- &ainfo, (hid_t)*lapl_id) < 0)
- HGOTO_DONE(FAIL);
+ if(H5Aget_info_by_idx((hid_t)*loc_id, c_obj_name, (H5_index_t)*idx_type, (H5_iter_order_t)*order, (hsize_t)*n,
+ &ainfo, (hid_t)*lapl_id) < 0)
+ HGOTO_DONE(FAIL)
/* Unpack the structure */
-
*corder_valid = 0;
- if(ainfo.corder_valid > 0) *corder_valid = 1;
-
+ if(ainfo.corder_valid > 0)
+ *corder_valid = 1;
*corder = (int_f)ainfo.corder;
*cset = (int_f)ainfo.cset;
*data_size = (hsize_t)ainfo.data_size;
done:
+ if(c_obj_name)
+ HDfree(c_obj_name);
+
return ret_value;
}
@@ -1506,34 +1494,37 @@ nh5aget_info_by_name_c (hid_t_f *loc_id, _fcd obj_name, size_t_f *obj_namelen,
{
char *c_obj_name = NULL; /* Buffer to hold C string */
char *c_attr_name = NULL; /* Buffer to hold C string */
- int_f ret_value = 0; /* Return value */
H5A_info_t ainfo;
+ int_f ret_value = 0; /* Return value */
/*
* Convert FORTRAN name to C name
*/
- if((c_obj_name = HD5f2cstring(obj_name, (size_t)*obj_namelen)) == NULL)
- HGOTO_DONE(FAIL);
- if((c_attr_name = HD5f2cstring(attr_name, (size_t)*attr_namelen)) == NULL)
- HGOTO_DONE(FAIL);
+ if(NULL == (c_obj_name = HD5f2cstring(obj_name, (size_t)*obj_namelen)))
+ HGOTO_DONE(FAIL)
+ if(NULL == (c_attr_name = HD5f2cstring(attr_name, (size_t)*attr_namelen)))
+ HGOTO_DONE(FAIL)
/*
* Call H5Ainfo_by_name function.
*/
- if(H5Aget_info_by_name((hid_t)*loc_id, c_obj_name, c_attr_name,
- &ainfo, (hid_t)*lapl_id) < 0)
- HGOTO_DONE(FAIL);
+ if(H5Aget_info_by_name((hid_t)*loc_id, c_obj_name, c_attr_name, &ainfo, (hid_t)*lapl_id) < 0)
+ HGOTO_DONE(FAIL)
/* Unpack the structure */
-
*corder_valid = 0;
- if(ainfo.corder_valid > 0) *corder_valid = 1;
-
+ if(ainfo.corder_valid > 0)
+ *corder_valid = 1;
*corder = (int_f)ainfo.corder;
*cset = (int_f)ainfo.cset;
*data_size = (hsize_t)ainfo.data_size;
done:
+ if(c_obj_name)
+ HDfree(c_obj_name);
+ if(c_attr_name)
+ HDfree(c_attr_name);
+
return ret_value;
}
diff --git a/fortran/src/H5Ef.c b/fortran/src/H5Ef.c
index d3983af..4f9d652 100644
--- a/fortran/src/H5Ef.c
+++ b/fortran/src/H5Ef.c
@@ -16,7 +16,7 @@
/* This files contains C stubs for H5E Fortran APIs */
#include "H5f90.h"
-
+#include "H5Eprivate.h"
/*----------------------------------------------------------------------------
* Name: h5eclear_c
@@ -30,18 +30,18 @@
*---------------------------------------------------------------------------*/
int_f
-nh5eclear_c( )
+nh5eclear_c(void)
{
- int ret_val = -1;
- herr_t status;
-
- /*
- * Call H5Eclear function.
- */
- status = H5Eclear2(H5E_DEFAULT);
- if(status < 0) return ret_val;
- ret_val = 0;
- return ret_val;
+ int_f ret_value = 0;
+
+ /*
+ * Call H5Eclear function.
+ */
+ if(H5Eclear2(H5E_DEFAULT) < 0)
+ HGOTO_DONE(FAIL)
+
+done:
+ return ret_value;
}
/*----------------------------------------------------------------------------
@@ -59,26 +59,28 @@ nh5eclear_c( )
int_f
nh5eprint_c1(_fcd name, int_f* namelen)
{
- int ret_val = -1;
- herr_t status;
- FILE * file;
- char* c_name;
- size_t c_namelen;
- c_namelen = *namelen;
- c_name = (char*)HD5f2cstring(name, c_namelen);
- if(c_name == NULL) return ret_val;
- file = fopen(c_name, "a");
- if(!file) goto DONE;
- /*
- * Call H5Eprint2 function.
- */
- status = H5Eprint2(H5E_DEFAULT, file);
- if (status >=0 ) ret_val = 0;
- fclose(file);
-
-DONE:
- HDfree(c_name);
- return ret_val;
+ FILE *file = NULL;
+ char *c_name = NULL;
+ int_f ret_value = 0;
+
+ if(NULL == (c_name = (char*)HD5f2cstring(name, (size_t)*namelen)))
+ HGOTO_DONE(FAIL)
+ if(NULL == (file = HDfopen(c_name, "a")))
+ HGOTO_DONE(FAIL)
+
+ /*
+ * Call H5Eprint2 function.
+ */
+ if(H5Eprint2(H5E_DEFAULT, file) < 0)
+ HGOTO_DONE(FAIL)
+
+done:
+ if(file)
+ HDfclose(file);
+ if(c_name)
+ HDfree(c_name);
+
+ return ret_value;
}
@@ -94,17 +96,18 @@ DONE:
* Modifications:
*---------------------------------------------------------------------------*/
int_f
-nh5eprint_c2()
+nh5eprint_c2(void)
{
- int ret_val = -1;
- herr_t status;
-
- /*
- * Call H5Eprint2 function.
- */
- status = H5Eprint2(H5E_DEFAULT, NULL);
- if(status >= 0) ret_val = 0;
- return ret_val;
+ int_f ret_value = 0;
+
+ /*
+ * Call H5Eprint2 function.
+ */
+ if(H5Eprint2(H5E_DEFAULT, NULL) < 0)
+ HGOTO_DONE(FAIL)
+
+done:
+ return ret_value;
}
/*----------------------------------------------------------------------------
@@ -121,24 +124,28 @@ nh5eprint_c2()
int_f
nh5eget_major_c(int_f* error_no, _fcd name, size_t_f* namelen)
{
- int ret_val = -1;
- char *c_name = NULL;
- size_t c_namelen;
- hid_t c_error_no;
- c_error_no = (hid_t)*error_no;
-
- c_namelen = (size_t)*namelen;
- if(c_namelen) c_name = (char*) HDmalloc(c_namelen + 1);
-
- /*
- * Call H5Eget_major function.
- */
- H5Eget_msg(c_error_no, NULL, c_name, c_namelen);
- HD5packFstring((char*)c_name, _fcdtocp(name), c_namelen);
-
- if(!strcmp(c_name, "Invalid major error number")) return ret_val;
- ret_val = 0;
- return ret_val;
+ char *c_name = NULL;
+ size_t c_namelen = (size_t)*namelen;
+ int_f ret_value = 0;
+
+ if(c_namelen) {
+ if(NULL == (c_name = (char *)HDmalloc(c_namelen + 1)))
+ HGOTO_DONE(FAIL)
+ } /* end if */
+
+ /*
+ * Call H5Eget_major function.
+ */
+ H5Eget_msg((hid_t)*error_no, NULL, c_name, c_namelen);
+ HD5packFstring((char*)c_name, _fcdtocp(name), c_namelen);
+ if(!HDstrcmp(c_name, "Invalid major error number"))
+ HGOTO_DONE(FAIL)
+
+done:
+ if(c_name)
+ HDfree(c_name);
+
+ return ret_value;
}
/*----------------------------------------------------------------------------
@@ -155,24 +162,28 @@ nh5eget_major_c(int_f* error_no, _fcd name, size_t_f* namelen)
int_f
nh5eget_minor_c(int_f* error_no, _fcd name, size_t_f* namelen)
{
- int ret_val = -1;
- char *c_name = NULL;
- size_t c_namelen;
- hid_t c_error_no;
- c_error_no = (hid_t)*error_no;
-
- c_namelen = (size_t)*namelen;
- if(c_namelen) c_name = (char*) HDmalloc(c_namelen + 1);
-
- /*
- * Call H5Eget_minor function.
- */
- H5Eget_msg(c_error_no, NULL, c_name, c_namelen);
- HD5packFstring((char*)c_name, _fcdtocp(name), c_namelen);
-
- if(!strcmp(c_name, "Invalid minor error number")) return ret_val;
- ret_val = 0;
- return ret_val;
+ char *c_name = NULL;
+ size_t c_namelen = (size_t)*namelen;
+ int_f ret_value = 0;
+
+ if(c_namelen) {
+ if(NULL == (c_name = (char *)HDmalloc(c_namelen + 1)))
+ HGOTO_DONE(FAIL)
+ } /* end if */
+
+ /*
+ * Call H5Eget_minor function.
+ */
+ H5Eget_msg((hid_t)*error_no, NULL, c_name, c_namelen);
+ HD5packFstring((char *)c_name, _fcdtocp(name), c_namelen);
+ if(!HDstrcmp(c_name, "Invalid minor error number"))
+ HGOTO_DONE(FAIL)
+
+done:
+ if(c_name)
+ HDfree(c_name);
+
+ return ret_value;
}
/*----------------------------------------------------------------------------
@@ -188,13 +199,17 @@ nh5eget_minor_c(int_f* error_no, _fcd name, size_t_f* namelen)
int_f
nh5eset_auto_c(int_f* printflag)
{
- int ret_val = -1;
- herr_t status = -1;
-
- if (*printflag == 1)
- status = H5Eset_auto2(H5E_DEFAULT, H5Eprint2, stderr);
- else if (*printflag == 0)
- status = H5Eset_auto2(H5E_DEFAULT, NULL, NULL);
- if (status >= 0) ret_val = 0;
- return ret_val;
+ herr_t status = -1;
+ int_f ret_value = 0;
+
+ if(*printflag == 1)
+ status = H5Eset_auto2(H5E_DEFAULT, (H5E_auto2_t)H5Eprint2, stderr);
+ else if(*printflag == 0)
+ status = H5Eset_auto2(H5E_DEFAULT, NULL, NULL);
+ if(status < 0)
+ HGOTO_DONE(FAIL)
+
+done:
+ return ret_value;
}
+
diff --git a/fortran/src/H5Lf.c b/fortran/src/H5Lf.c
index 2832d44..4d3e31c 100644
--- a/fortran/src/H5Lf.c
+++ b/fortran/src/H5Lf.c
@@ -44,30 +44,30 @@ nh5lcopy_c(hid_t_f *src_loc_id, _fcd src_name, size_t_f *src_namelen, hid_t_f *d
_fcd dest_name, size_t_f *dest_namelen,
hid_t_f *lcpl_id, hid_t_f *lapl_id)
{
- char *c_src_name = NULL;
- char *c_dest_name = NULL;
- int ret_value = 0;
+ char *c_src_name = NULL;
+ char *c_dest_name = NULL;
+ int_f ret_value = 0;
- /*
- * Convert FORTRAN name to C name
- */
- if((c_src_name = HD5f2cstring(src_name, (size_t)*src_namelen)) == NULL)
- HGOTO_DONE(FAIL);
- if((c_dest_name = HD5f2cstring(dest_name, (size_t)*dest_namelen)) == NULL)
- HGOTO_DONE(FAIL);
+ /*
+ * Convert FORTRAN name to C name
+ */
+ if(NULL == (c_src_name = HD5f2cstring(src_name, (size_t)*src_namelen)))
+ HGOTO_DONE(FAIL)
+ if(NULL == (c_dest_name = HD5f2cstring(dest_name, (size_t)*dest_namelen)))
+ HGOTO_DONE(FAIL)
- /*
- * Call H5Lcopy function.
- */
- if( H5Lcopy( (hid_t)*src_loc_id, c_src_name, (hid_t) *dest_loc_id,
- c_dest_name, (hid_t)*lcpl_id, (hid_t)*lapl_id ) < 0)
- HGOTO_DONE(FAIL);
+ /*
+ * Call H5Lcopy function.
+ */
+ if(H5Lcopy((hid_t)*src_loc_id, c_src_name, (hid_t) *dest_loc_id,
+ c_dest_name, (hid_t)*lcpl_id, (hid_t)*lapl_id ) < 0)
+ HGOTO_DONE(FAIL)
done:
- if(c_src_name)
- HDfree(c_src_name);
- if(c_dest_name)
- HDfree(c_dest_name);
+ if(c_src_name)
+ HDfree(c_src_name);
+ if(c_dest_name)
+ HDfree(c_dest_name);
return ret_value;
}
@@ -99,7 +99,7 @@ nh5lcreate_external_c(_fcd file_name, size_t_f *file_namelen, _fcd obj_name, siz
char *c_file_name = NULL;
char *c_obj_name = NULL;
char *c_link_name = NULL;
- int ret_value = 0;
+ int_f ret_value = 0;
/*
* Convert FORTRAN name to C name
@@ -149,7 +149,7 @@ int_f
nh5ldelete_c ( hid_t_f *loc_id, _fcd name, size_t_f *namelen, hid_t_f *lapl_id )
{
char *c_name = NULL;
- int ret_value = 0;
+ int_f ret_value = 0;
/*
* Convert FORTRAN name to C name
@@ -195,7 +195,7 @@ nh5lcreate_soft_c(_fcd target_path, size_t_f *target_path_len,
{
char *c_target_path = NULL;
char *c_link_name = NULL;
- int ret_value = 0;
+ int_f ret_value = 0;
/*
* Convert FORTRAN name to C name
@@ -247,7 +247,7 @@ nh5lcreate_hard_c(hid_t_f *obj_loc_id, _fcd obj_name, size_t_f *obj_namelen,
{
char *c_obj_name = NULL;
char *c_link_name = NULL;
- int ret_value = 0;
+ int_f ret_value = 0;
/*
* Convert FORTRAN name to C name
@@ -400,8 +400,8 @@ nh5lget_info_c (hid_t_f *link_loc_id, _fcd link_name, size_t_f *link_namelen,
hid_t_f *lapl_id)
{
char *c_link_name = NULL; /* Buffer to hold C string */
- int_f ret_value = 0; /* Return value */
H5L_info_t link_buff;
+ int_f ret_value = 0; /* Return value */
/*
* Convert FORTRAN name to C name
@@ -456,31 +456,26 @@ nh5lget_info_by_idx_c(hid_t_f *loc_id, _fcd group_name, size_t_f *group_namelen,
int_f *link_type, int_f *corder_valid, int_f *corder, int_f *cset, haddr_t_f *address, size_t_f *val_size, hid_t_f *lapl_id)
{
char *c_group_name = NULL; /* Buffer to hold C string */
- H5_index_t c_index_field;
- H5_iter_order_t c_order;
- int_f ret_value = 0; /* Return value */
H5L_info_t link_buff;
+ int_f ret_value = 0; /* Return value */
/*
* Convert FORTRAN name to C name
*/
- if((c_group_name = HD5f2cstring(group_name, (size_t)*group_namelen)) == NULL)
- HGOTO_DONE(FAIL);
+ if(NULL == (c_group_name = HD5f2cstring(group_name, (size_t)*group_namelen)))
+ HGOTO_DONE(FAIL)
- c_index_field = (H5_index_t)*index_field;
- c_order = (H5_iter_order_t)*order;
/*
* Call H5Linfo_by_idx function.
*/
- if(H5Lget_info_by_idx((hid_t)*loc_id, c_group_name, c_index_field, c_order, (hsize_t)*n,
+ if(H5Lget_info_by_idx((hid_t)*loc_id, c_group_name, (H5_index_t)*index_field, (H5_iter_order_t)*order, (hsize_t)*n,
&link_buff, (hid_t)*lapl_id) < 0)
- HGOTO_DONE(FAIL);
+ HGOTO_DONE(FAIL)
/* Unpack the structure */
-
*corder_valid = 0;
- if(link_buff.corder_valid > 0) *corder_valid = 1;
-
+ if(link_buff.corder_valid > 0)
+ *corder_valid = 1;
*corder = (int_f)link_buff.corder;
*cset = (int_f)link_buff.cset;
*link_type = (int_f)link_buff.type;
@@ -488,6 +483,9 @@ nh5lget_info_by_idx_c(hid_t_f *loc_id, _fcd group_name, size_t_f *group_namelen,
*val_size = (size_t_f)link_buff.u.val_size;
done:
+ if(c_group_name)
+ HDfree(c_group_name);
+
return ret_value;
}
@@ -507,20 +505,14 @@ done:
int_f
nh5lis_registered_c(int_f *link_cls_id)
{
- int_f ret_value = 0; /* Return value */
- H5L_type_t c_link_cls_id; /* User-defined link class identifier */
- htri_t registered; /* registration status */
-
+ int_f ret_value; /* Return value */
- c_link_cls_id = (H5L_type_t)*link_cls_id;
- /*
- * Call H5Lis_registered
- */
- registered = H5Lis_registered(c_link_cls_id);
-
- ret_value = (int_f)registered;
+ /*
+ * Call H5Lis_registered
+ */
+ ret_value = (int_f)H5Lis_registered((H5L_type_t)*link_cls_id);
- return ret_value;
+ return ret_value;
}
@@ -553,18 +545,24 @@ nh5lmove_c(hid_t_f *src_loc_id, _fcd src_name, size_t_f *src_namelen, hid_t_f *d
/*
* Convert FORTRAN name to C name
*/
- if((c_src_name = HD5f2cstring(src_name, (size_t)*src_namelen)) == NULL)
- HGOTO_DONE(FAIL);
- if((c_dest_name = HD5f2cstring(dest_name, (size_t)*dest_namelen)) == NULL)
- HGOTO_DONE(FAIL);
+ if(NULL == (c_src_name = HD5f2cstring(src_name, (size_t)*src_namelen)))
+ HGOTO_DONE(FAIL)
+ if(NULL == (c_dest_name = HD5f2cstring(dest_name, (size_t)*dest_namelen)))
+ HGOTO_DONE(FAIL)
/*
* Call H5Lmove function.
*/
if(H5Lmove((hid_t)*src_loc_id, c_src_name, (hid_t)*dest_loc_id,
c_dest_name, (hid_t)*lcpl_id, (hid_t)*lapl_id) < 0)
- HGOTO_DONE(FAIL);
+ HGOTO_DONE(FAIL)
+
done:
+ if(c_src_name)
+ HDfree(c_src_name);
+ if(c_dest_name)
+ HDfree(c_dest_name);
+
return ret_value;
}
@@ -594,85 +592,43 @@ nh5lget_name_by_idx_c(hid_t_f *loc_id, _fcd group_name, size_t_f *group_namelen,
{
char *c_group_name = NULL; /* Buffer to hold C string */
char *c_name = NULL; /* Buffer to hold C string */
- int_f ret_value = 0; /* Return value */
size_t c_size;
+ int_f ret_value = 0; /* Return value */
/*
* Convert FORTRAN name to C name
*/
- if((c_group_name = HD5f2cstring(group_name, (size_t)*group_namelen)) == NULL)
- HGOTO_DONE(FAIL);
+ if(NULL == (c_group_name = HD5f2cstring(group_name, (size_t)*group_namelen)))
+ HGOTO_DONE(FAIL)
c_size = (size_t)*size + 1;
- /*
- * Allocate buffer to hold name of an attribute
- */
+
+ /*
+ * Allocate buffer to hold name of an attribute
+ */
if ((c_name = HDmalloc(c_size)) == NULL)
- HGOTO_DONE(FAIL);
+ HGOTO_DONE(FAIL)
if((*size = (size_t)H5Lget_name_by_idx((hid_t)*loc_id, c_group_name, (H5_index_t)*index_field,
- (H5_iter_order_t)*order, (hsize_t)*n,c_name, c_size, (hid_t)*lapl_id)) < 0)
- HGOTO_DONE(FAIL);
+ (H5_iter_order_t)*order, (hsize_t)*n,c_name, c_size, (hid_t)*lapl_id)) < 0)
+ HGOTO_DONE(FAIL)
/*
* Convert C name to FORTRAN and place it in the given buffer
*/
- if(c_name != NULL)
- HD5packFstring(c_name, _fcdtocp(name), c_size-1);
+ if(c_name)
+ HD5packFstring(c_name, _fcdtocp(name), c_size - 1);
+
done:
- if(c_group_name) HDfree(c_group_name);
- if(c_name) HDfree(c_name);
+ if(c_group_name)
+ HDfree(c_group_name);
+ if(c_name)
+ HDfree(c_name);
+
return ret_value;
}
/*----------------------------------------------------------------------------
- * Name: h5lget_val_c
- * Purpose: Call H5Lget_val
- * Inputs:
- * link_loc_id - File or group identifier.
- * link_name - Name of the link for which valrmation is being sought
- * link_namelen - Name length
- * size - Maximum number of characters of link value to be returned.
- * lapl_id - Link access property list
- * Outputs:
- * linkval_buff - The buffer to hold the returned link value.
- *
- * Returns: 0 on success, -1 on failure
- * Programmer: M.S. Breitenfeld
- * March 3, 2008
- * Modifications: N/A
- *---------------------------------------------------------------------------*/
-/* int_f */
-/* nh5lget_val_c (hid_t_f *link_loc_id, _fcd link_name, size_t_f *link_namelen, */
-/* size_t_f *size, _fcd linkval_buff, */
-/* hid_t_f *lapl_id) */
-/* { */
-/* char *c_link_name = NULL; /\* Buffer to hold C string *\/ */
-/* int_f ret_value = 0; /\* Return value *\/ */
-/* void *c_linkval_buff = NULL; */
-
-/* /\* */
-/* * Convert FORTRAN name to C name */
-/* *\/ */
-/* if((c_link_name = HD5f2cstring(link_name, (size_t)*link_namelen)) == NULL) */
-/* HGOTO_DONE(FAIL); */
-/* /\* */
-/* * Call H5Lval function. */
-/* *\/ */
-/* if(H5Lget_val((hid_t)*link_loc_id, c_link_name, &linkval_buff, (size_t)*size, (hid_t)*lapl_id) < 0) */
-/* HGOTO_DONE(FAIL); */
-/* /\* */
-/* * Convert C name to FORTRAN */
-/* *\/ */
-/* HD5packFstring(c_buf, _fcdtocp(buf), c_bufsize-1); */
-
-
-/* done: */
-/* return ret_value; */
-/* } */
-
-
-/*----------------------------------------------------------------------------
* Name: H5Lregistered_c
* Purpose: Call H5Lregistered
* Inputs:
@@ -796,24 +752,25 @@ int_f
nh5lget_val_c(hid_t_f *link_loc_id, _fcd link_name, size_t_f *link_namelen, size_t_f *size,
void *linkval_buff, hid_t_f *lapl_id)
{
- int_f ret_value = 0; /* Return value */
- char *c_link_name = NULL; /* Buffer to hold C string */
+ char *c_link_name = NULL; /* Buffer to hold C string */
+ int_f ret_value = 0; /* Return value */
- /*
- * Convert FORTRAN name to C name
- */
- if((c_link_name = HD5f2cstring(link_name, (size_t)*link_namelen)) == NULL)
- HGOTO_DONE(FAIL);
-
- /*
- * Call H5Lget_val
- */
+ /*
+ * Convert FORTRAN name to C name
+ */
+ if(NULL == (c_link_name = HD5f2cstring(link_name, (size_t)*link_namelen)))
+ HGOTO_DONE(FAIL)
- if(H5Lget_val( (hid_t)*link_loc_id, c_link_name, &linkval_buff, (size_t)*size, (hid_t)*lapl_id )< 0)
- HGOTO_DONE(FAIL);
+ /*
+ * Call H5Lget_val
+ */
+ if(H5Lget_val((hid_t)*link_loc_id, c_link_name, &linkval_buff, (size_t)*size, (hid_t)*lapl_id )< 0)
+ HGOTO_DONE(FAIL)
done:
+ if(c_link_name)
+ HDfree(c_link_name);
+
return ret_value;
}
-
diff --git a/fortran/src/H5Pf.c b/fortran/src/H5Pf.c
index 0929d7a..ee2145d 100644
--- a/fortran/src/H5Pf.c
+++ b/fortran/src/H5Pf.c
@@ -17,6 +17,7 @@
/* This files contains C stubs for H5P Fortran APIs */
#include "H5f90.h"
+#include "H5Eprivate.h"
/*----------------------------------------------------------------------------
* Name: h5pcreate_c
@@ -32,16 +33,17 @@
int_f
nh5pcreate_c ( hid_t_f *class, hid_t_f *prp_id )
{
- hid_t c_class;
- int ret_value = 0;
- hid_t c_prp_id;
+ hid_t c_prp_id;
+ int_f ret_value = 0;
- c_class = (hid_t)*class;
- c_prp_id = H5Pcreate(c_class);
+ c_prp_id = H5Pcreate((hid_t)*class);
+ if(c_prp_id < 0)
+ HGOTO_DONE(FAIL)
- if ( c_prp_id < 0 ) ret_value = -1;
- *prp_id = (hid_t_f)c_prp_id;
- return ret_value;
+ *prp_id = (hid_t_f)c_prp_id;
+
+done:
+ return ret_value;
}
/*----------------------------------------------------------------------------
@@ -57,11 +59,12 @@ nh5pcreate_c ( hid_t_f *class, hid_t_f *prp_id )
int_f
nh5pclose_c ( hid_t_f *prp_id )
{
- int ret_value = 0;
- hid_t c_prp_id=(*prp_id);
+ int_f ret_value = 0;
- if ( H5Pclose(c_prp_id) < 0 ) ret_value = -1;
- return ret_value;
+ if(H5Pclose((hid_t)*prp_id) < 0)
+ ret_value = -1;
+
+ return ret_value;
}
@@ -79,15 +82,17 @@ nh5pclose_c ( hid_t_f *prp_id )
int_f
nh5pcopy_c ( hid_t_f *prp_id , hid_t_f *new_prp_id)
{
- int ret_value = 0;
- hid_t c_prp_id;
- hid_t c_new_prp_id;
+ hid_t c_new_prp_id;
+ int_f ret_value = 0;
- c_prp_id = *prp_id;
- c_new_prp_id = H5Pcopy(c_prp_id);
- if ( c_new_prp_id < 0 ) ret_value = -1;
- *new_prp_id = (hid_t_f)c_new_prp_id;
- return ret_value;
+ c_new_prp_id = H5Pcopy((hid_t)*prp_id);
+ if(c_new_prp_id < 0)
+ HGOTO_DONE(FAIL)
+
+ *new_prp_id = (hid_t_f)c_new_prp_id;
+
+done:
+ return ret_value;
}
/*----------------------------------------------------------------------------
@@ -105,17 +110,17 @@ nh5pcopy_c ( hid_t_f *prp_id , hid_t_f *new_prp_id)
int_f
nh5pequal_c ( hid_t_f *plist1_id , hid_t_f *plist2_id, int_f * c_flag)
{
- int ret_value = 0;
- hid_t c_plist1_id;
- hid_t c_plist2_id;
- htri_t c_c_flag;
-
- c_plist1_id = (hid_t)*plist1_id;
- c_plist2_id = (hid_t)*plist2_id;
- c_c_flag = H5Pequal(c_plist1_id, c_plist2_id);
- if ( c_c_flag < 0 ) ret_value = -1;
- *c_flag = (int_f)c_c_flag;
- return ret_value;
+ htri_t c_c_flag;
+ int_f ret_value = 0;
+
+ c_c_flag = H5Pequal((hid_t)*plist1_id, (hid_t)*plist2_id);
+ if(c_c_flag < 0)
+ HGOTO_DONE(FAIL)
+
+ *c_flag = (int_f)c_c_flag;
+
+done:
+ return ret_value;
}
@@ -139,20 +144,19 @@ nh5pequal_c ( hid_t_f *plist1_id , hid_t_f *plist2_id, int_f * c_flag)
int_f
nh5pget_class_c ( hid_t_f *prp_id , int_f *classtype)
{
- int ret_value = 0;
- hid_t c_prp_id;
- hid_t c_classtype;
+ hid_t c_classtype;
+ int_f ret_value = 0;
- c_prp_id = *prp_id;
- c_classtype = H5Pget_class(c_prp_id);
- if (c_classtype == H5P_ROOT ) {
+ c_classtype = H5Pget_class((hid_t)*prp_id);
+ if(c_classtype == H5P_ROOT) {
*classtype = H5P_ROOT;
- ret_value = -1;
- return ret_value;
- }
- *classtype = (int_f)c_classtype;
+ HGOTO_DONE(FAIL)
+ }
- return ret_value;
+ *classtype = (int_f)c_classtype;
+
+done:
+ return ret_value;
}
/*----------------------------------------------------------------------------
@@ -3962,33 +3966,39 @@ nh5pget_copy_object_c(hid_t_f *ocp_plist_id, int_f *copy_options)
int_f
nh5pget_data_transform_c(hid_t_f *plist_id, _fcd expression, int_f *expression_len, size_t_f *size)
{
- int_f ret_value = -1;
- char *c_expression = NULL; /* Buffer to hold C string */
- size_t c_expression_len;
- ssize_t ret;
+ char *c_expression = NULL; /* Buffer to hold C string */
+ size_t c_expression_len;
+ ssize_t ret;
+ int_f ret_value = 0;
+ c_expression_len = (size_t)*expression_len + 1;
- c_expression_len = (size_t)*expression_len + 1;
+ /*
+ * Allocate memory to store the expression.
+ */
+ if(c_expression_len) {
+ c_expression = (char*)HDmalloc(c_expression_len);
+ if(NULL == c_expression)
+ HGOTO_DONE(FAIL)
+ } /* end if */
- /* should expression_len be size_t_f? */
- /*
- * Allocate memory to store the expression.
- */
- if( c_expression_len) c_expression = (char*) HDmalloc(c_expression_len);
- if (c_expression == NULL) return ret_value;
+ /*
+ * Call H5Pget_data_transform function.
+ */
+ ret = H5Pget_data_transform((hid_t)*plist_id, c_expression, c_expression_len);
+ if(ret < 0)
+ HGOTO_DONE(FAIL)
- /*
- * Call h5pget_data_transform function.
- */
- ret = H5Pget_data_transform((hid_t)*plist_id, c_expression, c_expression_len);
- if(ret < 0) return ret_value;
- /* or strlen ? */
- HD5packFstring(c_expression, _fcdtocp(expression), c_expression_len-1);
+ /* or strlen ? */
+ HD5packFstring(c_expression, _fcdtocp(expression), c_expression_len - 1);
- *size = (size_t_f)ret;
+ *size = (size_t_f)ret;
- ret_value = 0;
- return ret_value;
+done:
+ if(c_expression)
+ HDfree(c_expression);
+
+ return ret_value;
}
/*----------------------------------------------------------------------------
@@ -4012,23 +4022,24 @@ nh5pget_data_transform_c(hid_t_f *plist_id, _fcd expression, int_f *expression_l
int_f
nh5pset_data_transform_c(hid_t_f *plist_id, _fcd expression, int_f *expression_len)
{
- int_f ret_value = -1; /* Return value */
char* c_expression = NULL; /* Buffer to hold C string */
- herr_t ret;
+ int_f ret_value = 0; /* Return value */
+
/*
* Convert FORTRAN name to C name
*/
if(NULL == (c_expression = HD5f2cstring(expression, (size_t)*expression_len)))
- return ret_value;
+ HGOTO_DONE(FAIL)
+
/*
- * Call h5pset_data_transform function.
+ * Call H5Pset_data_transform function.
*/
- ret = H5Pset_data_transform((hid_t)*plist_id, c_expression);
- if(ret<0) return ret_value;
+ if(H5Pset_data_transform((hid_t)*plist_id, c_expression) < 0)
+ HGOTO_DONE(FAIL)
- ret_value = 0;
- if(c_expression)
- HDfree(c_expression);
+done:
+ if(c_expression)
+ HDfree(c_expression);
return ret_value;
}
diff --git a/fortran/src/H5Sf.c b/fortran/src/H5Sf.c
index da3db6e..9b0356f 100644
--- a/fortran/src/H5Sf.c
+++ b/fortran/src/H5Sf.c
@@ -14,6 +14,7 @@
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "H5f90.h"
+#include "H5Eprivate.h"
/*----------------------------------------------------------------------------
* Name: h5screate_simple_c
@@ -31,37 +32,30 @@
int_f
nh5screate_simple_c ( int_f *rank, hsize_t_f *dims, hsize_t_f *maxdims, hid_t_f *space_id )
{
- int ret_value = -1;
- hsize_t *c_dims;
- hsize_t *c_maxdims;
- hid_t c_space_id;
- int i;
-
- c_dims = malloc(sizeof(hsize_t) * (*rank ));
- if (!c_dims) return ret_value;
- c_maxdims = malloc(sizeof(hsize_t) * (*rank ));
- if (!c_maxdims) return ret_value;
-
- /*
- * Transpose dimension arrays because of C-FORTRAN storage order
- */
- for (i = 0; i < *rank ; i++) {
- c_dims[i] = dims[*rank - i - 1];
- c_maxdims[i] = maxdims[*rank - i - 1];
- }
-
- c_space_id = H5Screate_simple(*rank, c_dims, c_maxdims);
- if (c_space_id < 0) return ret_value;
-
- *space_id = (hid_t_f)c_space_id;
- ret_value = 0;
- HDfree (c_dims);
- HDfree (c_maxdims);
- return ret_value;
+ hsize_t c_dims[H5S_MAX_RANK];
+ hsize_t c_maxdims[H5S_MAX_RANK];
+ hid_t c_space_id;
+ int i;
+ int_f ret_value = 0;
+
+ /*
+ * Transpose dimension arrays because of C-FORTRAN storage order
+ */
+ for(i = 0; i < *rank ; i++) {
+ c_dims[i] = dims[*rank - i - 1];
+ c_maxdims[i] = maxdims[*rank - i - 1];
+ } /* end for */
+
+ c_space_id = H5Screate_simple(*rank, c_dims, c_maxdims);
+ if(c_space_id < 0)
+ HGOTO_DONE(FAIL)
+
+ *space_id = (hid_t_f)c_space_id;
+
+done:
+ return ret_value;
}
-
-
/*----------------------------------------------------------------------------
* Name: h5sclose_c
* Purpose: Call H5Sclose to close the dataspace
@@ -282,33 +276,27 @@ nh5sget_select_hyper_blocklist_c( hid_t_f *space_id ,hsize_t_f * startblock,
int_f
nh5sget_select_bounds_c( hid_t_f *space_id , hsize_t_f * start, hsize_t_f * end)
{
- int ret_value = -1;
- hid_t c_space_id;
- hsize_t* c_start, *c_end;
- int i, rank;
-
- c_space_id = *space_id;
- rank = H5Sget_simple_extent_ndims(c_space_id);
- if (rank < 0 ) return ret_value;
-
- c_start =(hsize_t*) malloc(sizeof(hsize_t)*rank);
- if (!c_start) return ret_value;
-
- c_end = (hsize_t*)malloc(sizeof(hsize_t)*rank);
- if(!c_end) return ret_value;
-
- ret_value = H5Sget_select_bounds(c_space_id, c_start, c_end);
- for(i = 0; i < rank; i++)
- {
- start[i] = (hsize_t_f)(c_start[rank-i-1]+1);
- end[i] = (hsize_t_f)(c_end[rank-i-1]+1);
- }
- if (ret_value >= 0 ) ret_value = 0;
-
- HDfree(c_start);
- HDfree(c_end);
-
- return ret_value;
+ hid_t c_space_id;
+ hsize_t c_start[H5S_MAX_RANK];
+ hsize_t c_end[H5S_MAX_RANK];
+ int i, rank;
+ int_f ret_value = 0;
+
+ c_space_id = *space_id;
+ rank = H5Sget_simple_extent_ndims(c_space_id);
+ if(rank < 0 )
+ HGOTO_DONE(FAIL)
+
+ if(H5Sget_select_bounds(c_space_id, c_start, c_end) < 0)
+ HGOTO_DONE(FAIL)
+
+ for(i = 0; i < rank; i++) {
+ start[i] = (hsize_t_f)(c_start[rank - i - 1] + 1);
+ end[i] = (hsize_t_f)(c_end[rank - i - 1] + 1);
+ } /* end for */
+
+done:
+ return ret_value;
}
/*----------------------------------------------------------------------------
@@ -574,29 +562,28 @@ nh5sget_simple_extent_type_c ( hid_t_f *space_id , int_f *classtype)
int_f
nh5soffset_simple_c ( hid_t_f *space_id , hssize_t_f *offset)
{
- int ret_value = -1;
- hid_t c_space_id;
- int rank;
- hssize_t *c_offset;
- herr_t status;
- int i;
-
- c_space_id = *space_id;
- rank = H5Sget_simple_extent_ndims(c_space_id);
- if (rank < 0) return ret_value;
-
- c_offset = malloc(sizeof(hssize_t)*rank);
- if (!c_offset) return ret_value;
-
- /*
- * Reverse dimensions due to C-FORTRAN storage order.
- */
- for (i=0; i < rank; i++) c_offset[i] = offset[rank - i - 1];
-
- status = H5Soffset_simple(c_space_id, c_offset);
- if ( status >= 0 ) ret_value = 0;
- HDfree(c_offset);
- return ret_value;
+ hid_t c_space_id;
+ int rank;
+ hssize_t c_offset[H5S_MAX_RANK];
+ int i;
+ int_f ret_value = 0;
+
+ c_space_id = *space_id;
+ rank = H5Sget_simple_extent_ndims(c_space_id);
+ if(rank < 0)
+ HGOTO_DONE(FAIL)
+
+ /*
+ * Reverse dimensions due to C-FORTRAN storage order.
+ */
+ for(i = 0; i < rank; i++)
+ c_offset[i] = offset[rank - i - 1];
+
+ if(H5Soffset_simple(c_space_id, c_offset) < 0)
+ HGOTO_DONE(FAIL)
+
+done:
+ return ret_value;
}
/*----------------------------------------------------------------------------
@@ -616,35 +603,24 @@ nh5soffset_simple_c ( hid_t_f *space_id , hssize_t_f *offset)
int_f
nh5sset_extent_simple_c ( hid_t_f *space_id , int_f *rank, hsize_t_f *current_size, hsize_t_f *maximum_size)
{
- int ret_value = -1;
- hid_t c_space_id;
- int c_rank;
- hsize_t *c_current_size;
- hsize_t *c_maximum_size;
- herr_t status;
- int i;
-
- c_current_size = malloc(sizeof(hsize_t)*(*rank));
- if (!c_current_size) return ret_value;
-
- c_maximum_size = malloc(sizeof(hsize_t)*(*rank));
- if (!c_maximum_size) return ret_value;
-
- /*
- * Reverse dimensions due to C-FORTRAN storage order.
- */
- for (i=0; i < *rank; i++) {
- c_current_size[i] = (hsize_t)current_size[*rank - i - 1];
- c_maximum_size[i] = (hsize_t)maximum_size[*rank - i - 1];
- }
-
- c_space_id = *space_id;
- c_rank = *rank;
- status = H5Sset_extent_simple(c_space_id, c_rank, c_current_size, c_maximum_size);
- if ( status >= 0 ) ret_value = 0;
- HDfree(c_current_size);
- HDfree(c_maximum_size);
- return ret_value;
+ hsize_t c_current_size[H5S_MAX_RANK];
+ hsize_t c_maximum_size[H5S_MAX_RANK];
+ int i;
+ int_f ret_value = 0;
+
+ /*
+ * Reverse dimensions due to C-FORTRAN storage order.
+ */
+ for(i = 0; i < *rank; i++) {
+ c_current_size[i] = (hsize_t)current_size[*rank - i - 1];
+ c_maximum_size[i] = (hsize_t)maximum_size[*rank - i - 1];
+ } /* end for */
+
+ if(H5Sset_extent_simple((hid_t)*space_id, (int)*rank, c_current_size, c_maximum_size) < 0)
+ HGOTO_DONE(FAIL)
+
+done:
+ return ret_value;
}
/*----------------------------------------------------------------------------
@@ -663,37 +639,33 @@ nh5sset_extent_simple_c ( hid_t_f *space_id , int_f *rank, hsize_t_f *current_si
int_f
nh5sget_simple_extent_dims_c ( hid_t_f *space_id , hsize_t_f *dims, hsize_t_f *maxdims)
{
- int ret_value = -1;
- hid_t c_space_id;
- hsize_t *c_dims;
- hsize_t *c_maxdims;
- int status;
- int rank;
- int i;
-
- c_space_id = *space_id;
- rank = H5Sget_simple_extent_ndims(c_space_id);
- if (rank < 0) return ret_value;
-
- c_dims = malloc(sizeof(hsize_t)*rank);
- if (!c_dims) return ret_value;
-
- c_maxdims = malloc(sizeof(hsize_t)*rank);
- if (!c_maxdims) return ret_value;
-
- status = H5Sget_simple_extent_dims(c_space_id, c_dims, c_maxdims);
- /*
- * Reverse dimensions due to C-FORTRAN storage order.
- */
- for (i=0; i < rank; i++) {
- dims[rank - i - 1] = (hsize_t_f)c_dims[i];
- maxdims[rank - i - 1] = (hsize_t_f)c_maxdims[i];
- }
-
- if ( status >= 0 ) ret_value = rank;
- HDfree(c_dims);
- HDfree(c_maxdims);
- return ret_value;
+ hid_t c_space_id;
+ hsize_t c_dims[H5S_MAX_RANK];
+ hsize_t c_maxdims[H5S_MAX_RANK];
+ int rank;
+ int i;
+ int_f ret_value;
+
+ c_space_id = *space_id;
+ rank = H5Sget_simple_extent_ndims(c_space_id);
+ if(rank < 0)
+ HGOTO_DONE(FAIL)
+
+ if(H5Sget_simple_extent_dims(c_space_id, c_dims, c_maxdims) < 0)
+ HGOTO_DONE(FAIL)
+
+ /*
+ * Reverse dimensions due to C-FORTRAN storage order.
+ */
+ for(i = 0; i < rank; i++) {
+ dims[rank - i - 1] = (hsize_t_f)c_dims[i];
+ maxdims[rank - i - 1] = (hsize_t_f)c_maxdims[i];
+ } /* end for */
+
+ ret_value = rank;
+
+done:
+ return ret_value;
}
/*----------------------------------------------------------------------------
@@ -792,61 +764,37 @@ nh5sset_extent_none_c ( hid_t_f *space_id )
int_f
nh5sselect_hyperslab_c ( hid_t_f *space_id , int_f *op, hsize_t_f *start, hsize_t_f *count, hsize_t_f *stride, hsize_t_f *block)
{
- int ret_value = -1;
- hid_t c_space_id;
- hsize_t *c_start = NULL;
- hsize_t *c_count = NULL;
- hsize_t *c_stride = NULL;
- hsize_t *c_block = NULL;
-
- H5S_seloper_t c_op;
- herr_t status;
- int rank;
- int i;
-
- rank = H5Sget_simple_extent_ndims(*space_id);
- if (rank < 0 ) return ret_value;
- c_start = (hsize_t *)HDmalloc(sizeof(hsize_t)*rank);
- if (c_start == NULL) goto DONE;
-
- c_count = (hsize_t *)HDmalloc(sizeof(hsize_t)*rank);
- if (c_count == NULL) goto DONE;
-
- c_stride = (hsize_t *)HDmalloc(sizeof(hsize_t)*rank);
- if (c_stride == NULL) goto DONE;
-
- c_block = (hsize_t *)HDmalloc(sizeof(hsize_t)*rank);
- if (c_block == NULL) goto DONE;
-
-
- /*
- * Reverse dimensions due to C-FORTRAN storage order.
- */
-
- for (i=0; i < rank; i++) {
- int t= (rank - i) - 1;
- c_start[i] = (hsize_t)start[t];
- c_count[i] = (hsize_t)count[t];
- c_stride[i] = (hsize_t)stride[t];
- c_block[i] = (hsize_t)block[t];
- }
-
- c_op = (H5S_seloper_t)*op;
-/*
- if (*op == H5S_SELECT_SET_F) c_op = H5S_SELECT_SET;
- if (*op == H5S_SELECT_OR_F) c_op = H5S_SELECT_OR;
-*/
-
- c_space_id = *space_id;
- status = H5Sselect_hyperslab(c_space_id, c_op, c_start, c_stride, c_count, c_block);
- if ( status >= 0 ) ret_value = 0;
-DONE:
- if(c_start != NULL) HDfree(c_start);
- if(c_count != NULL) HDfree(c_count);
- if(c_stride!= NULL) HDfree(c_stride);
- if(c_block != NULL) HDfree(c_block);
- return ret_value;
+ hsize_t c_start[H5S_MAX_RANK];
+ hsize_t c_count[H5S_MAX_RANK];
+ hsize_t c_stride[H5S_MAX_RANK];
+ hsize_t c_block[H5S_MAX_RANK];
+ int rank;
+ int i;
+ int_f ret_value = 0;
+
+ rank = H5Sget_simple_extent_ndims((hid_t)*space_id);
+ if(rank < 0 )
+ HGOTO_DONE(FAIL)
+
+ /*
+ * Reverse dimensions due to C-FORTRAN storage order.
+ */
+ for(i = 0; i < rank; i++) {
+ int t = (rank - i) - 1;
+
+ c_start[i] = (hsize_t)start[t];
+ c_count[i] = (hsize_t)count[t];
+ c_stride[i] = (hsize_t)stride[t];
+ c_block[i] = (hsize_t)block[t];
+ } /* end for */
+
+ if(H5Sselect_hyperslab((hid_t)*space_id, (H5S_seloper_t)*op, c_start, c_stride, c_count, c_block) < 0)
+ HGOTO_DONE(FAIL)
+
+done:
+ return ret_value;
}
+
#ifdef NEW_HYPERSLAB_API
/*----------------------------------------------------------------------------
* Name: h5scombine_hyperslab_c
diff --git a/fortran/test/t.c b/fortran/test/t.c
index 861a3e7..f2203d0 100644
--- a/fortran/test/t.c
+++ b/fortran/test/t.c
@@ -14,6 +14,7 @@
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "t.h"
+#include "H5Eprivate.h"
/*----------------------------------------------------------------------------
* Name: h5_fixname_c
@@ -31,35 +32,31 @@
int_f
nh5_fixname_c(_fcd base_name, size_t_f *base_namelen, hid_t_f* fapl, _fcd full_name, size_t_f *full_namelen)
{
- int ret_value = -1;
- char *c_base_name;
- char *c_full_name;
- hid_t c_fapl;
+ char *c_base_name = NULL;
+ char *c_full_name = NULL;
+ int_f ret_value = 0;
/*
- * Define ifile access property list
- */
- c_fapl = (hid_t)*fapl;
- /*
* Convert FORTRAN name to C name
*/
- c_base_name = (char *)HD5f2cstring(base_name, (size_t)*base_namelen);
- if (c_base_name == NULL) goto DONE;
- c_full_name = (char *) HDmalloc((size_t)*full_namelen + 1);
- if (c_full_name == NULL) goto DONE;
+ if(NULL == (c_base_name = (char *)HD5f2cstring(base_name, (size_t)*base_namelen)))
+ HGOTO_DONE(FAIL)
+ if(NULL == (c_full_name = (char *)HDmalloc((size_t)*full_namelen + 1)))
+ HGOTO_DONE(FAIL)
/*
* Call h5_fixname function.
*/
- if (NULL != h5_fixname(c_base_name, c_fapl, c_full_name, (size_t)*full_namelen + 1)) {
- HD5packFstring(c_full_name, _fcdtocp(full_name), (size_t)*full_namelen);
- ret_value = 0;
- goto DONE;
- }
+ if(NULL == h5_fixname(c_base_name, (hid_t)*fapl, c_full_name, (size_t)*full_namelen + 1))
+ HGOTO_DONE(FAIL)
+ HD5packFstring(c_full_name, _fcdtocp(full_name), (size_t)*full_namelen);
+
+done:
+ if(c_base_name)
+ HDfree(c_base_name);
+ if(c_full_name)
+ HDfree(c_full_name);
-DONE:
- if (NULL != c_base_name) HDfree(c_base_name);
- if (NULL != c_full_name) HDfree(c_full_name);
return ret_value;
}