[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)
This commit is contained in:
Quincey Koziol 2010-01-22 23:39:40 -05:00
parent 2c872f398b
commit fcc03a356b
12 changed files with 796 additions and 1073 deletions

View File

@ -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;
}

View File

@ -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;
int_f ret_value = 0;
/*
* Call H5Eclear function.
*/
status = H5Eclear2(H5E_DEFAULT);
if(status < 0) return ret_val;
ret_val = 0;
return ret_val;
/*
* 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);
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)
DONE:
HDfree(c_name);
return ret_val;
/*
* 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;
int_f ret_value = 0;
/*
* Call H5Eprint2 function.
*/
status = H5Eprint2(H5E_DEFAULT, NULL);
if(status >= 0) ret_val = 0;
return ret_val;
/*
* 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;
char *c_name = NULL;
size_t c_namelen = (size_t)*namelen;
int_f ret_value = 0;
c_namelen = (size_t)*namelen;
if(c_namelen) c_name = (char*) HDmalloc(c_namelen + 1);
if(c_namelen) {
if(NULL == (c_name = (char *)HDmalloc(c_namelen + 1)))
HGOTO_DONE(FAIL)
} /* end if */
/*
* Call H5Eget_major function.
*/
H5Eget_msg(c_error_no, NULL, c_name, c_namelen);
HD5packFstring((char*)c_name, _fcdtocp(name), c_namelen);
/*
* 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);
if(!strcmp(c_name, "Invalid major error number")) return ret_val;
ret_val = 0;
return ret_val;
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;
char *c_name = NULL;
size_t c_namelen = (size_t)*namelen;
int_f ret_value = 0;
c_namelen = (size_t)*namelen;
if(c_namelen) c_name = (char*) HDmalloc(c_namelen + 1);
if(c_namelen) {
if(NULL == (c_name = (char *)HDmalloc(c_namelen + 1)))
HGOTO_DONE(FAIL)
} /* end if */
/*
* 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;
/*
* 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;
herr_t status = -1;
int_f ret_value = 0;
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;
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;
}

View File

@ -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 */
/*
* Call H5Lis_registered
*/
ret_value = (int_f)H5Lis_registered((H5L_type_t)*link_cls_id);
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;
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,84 +592,42 @@ 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
@ -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);
/*
* Convert FORTRAN name to C name
*/
if(NULL == (c_link_name = HD5f2cstring(link_name, (size_t)*link_namelen)))
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);
/*
* 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;
}

View File

@ -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;
htri_t c_c_flag;
int_f ret_value = 0;
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;
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;
/*
* Call h5pset_data_transform function.
*/
ret = H5Pset_data_transform((hid_t)*plist_id, c_expression);
if(ret<0) return ret_value;
HGOTO_DONE(FAIL)
ret_value = 0;
if(c_expression)
HDfree(c_expression);
/*
* Call H5Pset_data_transform function.
*/
if(H5Pset_data_transform((hid_t)*plist_id, c_expression) < 0)
HGOTO_DONE(FAIL)
done:
if(c_expression)
HDfree(c_expression);
return ret_value;
}

View File

@ -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;
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;
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;
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;
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)
c_space_id = *space_id;
rank = H5Sget_simple_extent_ndims(c_space_id);
if (rank < 0 ) return ret_value;
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 */
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;
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;
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) return ret_value;
c_space_id = *space_id;
rank = H5Sget_simple_extent_ndims(c_space_id);
if(rank < 0)
HGOTO_DONE(FAIL)
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];
/*
* 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)
status = H5Soffset_simple(c_space_id, c_offset);
if ( status >= 0 ) ret_value = 0;
HDfree(c_offset);
return ret_value;
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;
hsize_t c_current_size[H5S_MAX_RANK];
hsize_t c_maximum_size[H5S_MAX_RANK];
int i;
int_f ret_value = 0;
c_current_size = malloc(sizeof(hsize_t)*(*rank));
if (!c_current_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];
} /* end for */
c_maximum_size = malloc(sizeof(hsize_t)*(*rank));
if (!c_maximum_size) return ret_value;
if(H5Sset_extent_simple((hid_t)*space_id, (int)*rank, c_current_size, c_maximum_size) < 0)
HGOTO_DONE(FAIL)
/*
* 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;
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;
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) return ret_value;
c_space_id = *space_id;
rank = H5Sget_simple_extent_ndims(c_space_id);
if(rank < 0)
HGOTO_DONE(FAIL)
c_dims = malloc(sizeof(hsize_t)*rank);
if (!c_dims) return ret_value;
if(H5Sget_simple_extent_dims(c_space_id, c_dims, c_maxdims) < 0)
HGOTO_DONE(FAIL)
c_maxdims = malloc(sizeof(hsize_t)*rank);
if (!c_maxdims) return ret_value;
/*
* 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 */
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];
}
ret_value = rank;
if ( status >= 0 ) ret_value = rank;
HDfree(c_dims);
HDfree(c_maxdims);
return ret_value;
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;
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;
H5S_seloper_t c_op;
herr_t status;
int rank;
int i;
rank = H5Sget_simple_extent_ndims((hid_t)*space_id);
if(rank < 0 )
HGOTO_DONE(FAIL)
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;
/*
* Reverse dimensions due to C-FORTRAN storage order.
*/
for(i = 0; i < rank; i++) {
int t = (rank - i) - 1;
c_count = (hsize_t *)HDmalloc(sizeof(hsize_t)*rank);
if (c_count == NULL) goto DONE;
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 */
c_stride = (hsize_t *)HDmalloc(sizeof(hsize_t)*rank);
if (c_stride == NULL) goto DONE;
if(H5Sselect_hyperslab((hid_t)*space_id, (H5S_seloper_t)*op, c_start, c_stride, c_count, c_block) < 0)
HGOTO_DONE(FAIL)
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;
done:
return ret_value;
}
#ifdef NEW_HYPERSLAB_API
/*----------------------------------------------------------------------------
* Name: h5scombine_hyperslab_c

View File

@ -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;
}

View File

@ -17,7 +17,7 @@
#include "H5IMcc.h"
#include "H5LTf90proto.h"
#include "H5Eprivate.h"
/*-------------------------------------------------------------------------
* Function: h5immake_image_8bit_c
@ -377,49 +377,30 @@ nh5immake_palette_c (hid_t_f *loc_id,
hsize_t_f *dims,
void *buf)
{
int ret_value = -1;
herr_t ret;
hid_t c_loc_id;
char *c_name = NULL;
int c_namelen;
hsize_t *c_dims;
hsize_t c_dims[H5S_MAX_RANK];
int i;
int rank=2;
int_f ret_value = 0;
/*
* convert FORTRAN name to C name
*/
c_namelen = *namelen;
c_name = (char *)HD5f2cstring(name, c_namelen);
if (c_name == NULL)
goto done;
if(NULL == (c_name = (char *)HD5f2cstring(name, (int)*namelen)))
HGOTO_DONE(FAIL)
c_dims = malloc(sizeof(hsize_t) * (rank ));
if (c_dims == NULL)
goto done;
for (i = 0; i < rank ; i++)
{
for(i = 0; i < rank ; i++)
c_dims[i] = dims[i];
}
/*
* call H5IMmake_palette function.
*/
c_loc_id = (hid_t)*loc_id;
ret = H5IMmake_palettef(c_loc_id,c_name,c_dims,buf);
if (ret < 0)
goto done;
ret_value = 0;
if(H5IMmake_palettef((hid_t)*loc_id, c_name, c_dims, buf) < 0)
HGOTO_DONE(FAIL)
done:
if(c_name!=NULL)
free(c_name);
if(c_dims!=NULL)
free(c_dims);
if(c_name)
HDfree(c_name);
return ret_value;
}

View File

@ -17,6 +17,7 @@
#include "H5TBprivate.h"
#include "H5LTf90proto.h"
#include "H5Eprivate.h"
/*-------------------------------------------------------------------------
* Function: h5tbmake_table_c
@ -52,134 +53,99 @@ nh5tbmake_table_c(int_f *namelen1,
int_f *namelen2, /* field_names lenghts */
_fcd field_names) /* field_names */
{
int ret_value = -1;
herr_t ret;
char *c_name = NULL;
int c_namelen;
char *c_name1 = NULL;
int c_namelen1;
char *c_name = NULL;
char *c_name1 = NULL;
hsize_t num_elem;
hsize_t i;
int max_len=1;
hid_t c_loc_id = *loc_id;
hsize_t c_nfields = *nfields;
hsize_t c_nrecords = *nrecords;
int max_len = 1;
hid_t c_loc_id = *loc_id;
hsize_t c_nfields = *nfields;
hsize_t c_nrecords = *nrecords;
hsize_t c_chunk_size = *chunk_size;
size_t c_type_size = *type_size;
size_t *c_field_offset = NULL;
hid_t *c_field_types = NULL;
char **c_field_names = NULL;
char *tmp = NULL, *tmp_p = NULL;
size_t c_type_size = *type_size;
size_t *c_field_offset = NULL;
hid_t *c_field_types = NULL;
char **c_field_names = NULL;
char *tmp = NULL, *tmp_p;
int_f ret_value = 0;
num_elem = *nfields;
for ( i = 0; i < num_elem; i++)
{
if (namelen2[i] > max_len) max_len = namelen2[i];
for(i = 0; i < num_elem; i++) {
if(namelen2[i] > max_len)
max_len = namelen2[i];
}
/*
* convert FORTRAN name to C name
*/
c_namelen = *namelen;
c_name = (char *)HD5f2cstring(name, c_namelen);
if (c_name == NULL)
goto done;
* convert FORTRAN name to C name
*/
if(NULL == (c_name = (char *)HD5f2cstring(name, (size_t)*namelen)))
HGOTO_DONE(FAIL)
if(NULL == (c_name1 = (char *)HD5f2cstring(name1, (size_t)*namelen1)))
HGOTO_DONE(FAIL)
if(NULL == (c_field_offset = (size_t *)HDmalloc(sizeof(size_t) * (size_t)c_nfields)))
HGOTO_DONE(FAIL)
if(NULL == (c_field_types = (hid_t *)HDmalloc(sizeof(hid_t) * (size_t)c_nfields)))
HGOTO_DONE(FAIL)
c_namelen1 = *namelen1;
c_name1 = (char *)HD5f2cstring(name1, c_namelen1);
if (c_name1 == NULL)
goto done;
c_field_offset = (size_t*)malloc(sizeof(size_t) * (size_t)c_nfields);
if (!c_field_offset)
goto done;
c_field_types = (hid_t*)malloc(sizeof(hid_t) * (size_t)c_nfields);
if (!c_field_types)
goto done;
for ( i = 0; i < num_elem; i++)
{
for (i = 0; i < num_elem; i++) {
c_field_offset[i] = field_offset[i];
c_field_types[i] = field_types[i];
c_field_types[i] = field_types[i];
}
/*
* allocate array of character pointers
*/
c_field_names = (char **)malloc((size_t)num_elem * sizeof(char *));
if (c_field_names == NULL)
goto done;
* allocate array of character pointers
*/
if(NULL == (c_field_names = (char **)HDcalloc((size_t)num_elem, sizeof(char *))))
HGOTO_DONE(FAIL)
/* copy data to long C string */
tmp = (char *)HD5f2cstring(field_names, (int)(max_len*num_elem));
if (tmp == NULL)
{
goto done;
}
if(NULL == (tmp = (char *)HD5f2cstring(field_names, (size_t)(max_len * num_elem))))
HGOTO_DONE(FAIL)
/*
* move data from temorary buffer
*/
* move data from temorary buffer
*/
tmp_p = tmp;
for (i=0; i < num_elem; i++)
{
c_field_names[i] = (char *) malloc((size_t)namelen2[i]+1);
memcpy(c_field_names[i], tmp_p, (size_t)namelen2[i]);
for(i = 0; i < num_elem; i++) {
if(NULL == (c_field_names[i] = (char *)HDmalloc((size_t)namelen2[i] + 1)))
HGOTO_DONE(FAIL)
HDmemcpy(c_field_names[i], tmp_p, (size_t)namelen2[i]);
c_field_names[i][namelen2[i]] = '\0';
tmp_p = tmp_p + max_len;
}
} /* end for */
/*
* call H5TBmake_table function.
*/
* call H5TBmake_table function.
*/
if(H5TBmake_table(c_name1, c_loc_id, c_name, c_nfields, c_nrecords,
c_type_size, c_field_names, c_field_offset, c_field_types,
c_chunk_size, NULL, *compress, NULL) < 0)
HGOTO_DONE(FAIL)
ret = H5TBmake_table(c_name1,
c_loc_id,
c_name,
c_nfields,
c_nrecords,
c_type_size,
c_field_names,
c_field_offset,
c_field_types,
c_chunk_size,
NULL,
*compress,
NULL);
if (ret < 0)
goto done;
ret_value = 0;
done:
if(c_name != NULL)
free(c_name);
if(c_name1 != NULL)
free(c_name1);
for ( i = 0; i < num_elem; i++)
{
if ( c_field_names[i] )
free (c_field_names[i]);
}
if ( c_field_names )
free(c_field_names);
if ( tmp )
free(tmp);
if ( c_field_offset )
free(c_field_offset);
if ( c_field_types )
free(c_field_types);
done:
if(c_name)
HDfree(c_name);
if(c_name1)
HDfree(c_name1);
if(c_field_names) {
for(i = 0; i < num_elem; i++) {
if(c_field_names[i])
HDfree(c_field_names[i]);
}
HDfree(c_field_names);
} /* end if */
if(tmp)
HDfree(tmp);
if(c_field_offset)
HDfree(c_field_offset);
if(c_field_types)
HDfree(c_field_types);
return ret_value;
}
/*-------------------------------------------------------------------------
* Function: h5tbwrite_field_name_c
*
@ -210,59 +176,34 @@ nh5tbwrite_field_name_c(hid_t_f *loc_id,
size_t_f *type_size,
void *buf)
{
int ret_value = -1;
herr_t ret;
char *c_name = NULL;
int c_namelen;
char *c_name1 = NULL;
int c_namelen1;
char *c_name = NULL;
char *c_name1 = NULL;
hid_t c_loc_id = *loc_id;
hsize_t c_start = *start;
hsize_t c_nrecords = *nrecords;
size_t c_type_size = *type_size;
size_t c_type_sizes[1];
c_type_sizes[0] = c_type_size;
int_f ret_value = 0;
/*
* convert FORTRAN name to C name
*/
c_namelen = *namelen;
c_name = (char *)HD5f2cstring(name, c_namelen);
if (c_name == NULL)
goto done;
c_namelen1 = *namelen1;
c_name1 = (char *)HD5f2cstring(field_name, c_namelen1);
if (c_name1 == NULL)
goto done;
if(NULL == (c_name = (char *)HD5f2cstring(name, (size_t)*namelen)))
HGOTO_DONE(FAIL)
if(NULL == (c_name1 = (char *)HD5f2cstring(field_name, (size_t)*namelen1)))
HGOTO_DONE(FAIL)
/*
* call H5TBwrite_fields_name function.
*/
ret = H5TBwrite_fields_name(c_loc_id,
c_name,
c_name1,
c_start,
c_nrecords,
c_type_size,
0,
c_type_sizes,
buf);
if (ret < 0)
goto done;
ret_value = 0;
if(H5TBwrite_fields_name(c_loc_id, c_name, c_name1, c_start, c_nrecords,
c_type_size, 0, &c_type_size, buf) < 0)
HGOTO_DONE(FAIL)
done:
if(c_name != NULL)
free(c_name);
if(c_name1 != NULL)
free(c_name1);
if(c_name)
HDfree(c_name);
if(c_name1)
HDfree(c_name1);
return ret_value;
}
@ -293,6 +234,7 @@ nh5tbwrite_field_name_fl_c(hid_t_f *loc_id,
{
return nh5tbwrite_field_name_c(loc_id,namelen,name,namelen1,field_name,start,nrecords,type_size,buf);
}
int_f
nh5tbwrite_field_name_dl_c(hid_t_f *loc_id,
int_f *namelen,
@ -306,6 +248,7 @@ nh5tbwrite_field_name_dl_c(hid_t_f *loc_id,
{
return nh5tbwrite_field_name_c(loc_id,namelen,name,namelen1,field_name,start,nrecords,type_size,buf);
}
int_f
nh5tbwrite_field_name_st_c(hid_t_f *loc_id,
int_f *namelen,
@ -319,6 +262,7 @@ nh5tbwrite_field_name_st_c(hid_t_f *loc_id,
{
return nh5tbwrite_field_name_c(loc_id,namelen,name,namelen1,field_name,start,nrecords,type_size,buf);
}
/*-------------------------------------------------------------------------
* Function: h5tbread_field_name_c
*
@ -349,57 +293,34 @@ nh5tbread_field_name_c(hid_t_f *loc_id,
size_t_f *type_size,
void *buf)
{
int ret_value = -1;
herr_t ret;
char *c_name = NULL;
int c_namelen;
char *c_name1 = NULL;
int c_namelen1;
char *c_name = NULL;
char *c_name1 = NULL;
hid_t c_loc_id = *loc_id;
hsize_t c_start = *start;
hsize_t c_nrecords = *nrecords;
size_t c_type_size = *type_size;
size_t c_type_sizes[1];
c_type_sizes[0] = c_type_size;
int_f ret_value = 0;
/*
* convert FORTRAN name to C name
*/
c_namelen = *namelen;
c_name = (char *)HD5f2cstring(name, c_namelen);
if (c_name == NULL)
goto done;
c_namelen1 = *namelen1;
c_name1 = (char *)HD5f2cstring(field_name, c_namelen1);
if (c_name1 == NULL)
goto done;
if(NULL == (c_name = (char *)HD5f2cstring(name, (size_t)*namelen)))
HGOTO_DONE(FAIL)
if(NULL == (c_name1 = (char *)HD5f2cstring(field_name, (size_t)*namelen1)))
HGOTO_DONE(FAIL)
/*
* call H5TBread_fields_name function.
*/
ret = H5TBread_fields_name(c_loc_id,
c_name,
c_name1,
c_start,
c_nrecords,
c_type_size,
0,
c_type_sizes,
buf);
if (ret < 0)
goto done;
ret_value = 0;
if(H5TBread_fields_name(c_loc_id, c_name, c_name1, c_start, c_nrecords,
c_type_size, 0, &c_type_size, buf) < 0)
HGOTO_DONE(FAIL)
done:
if(c_name != NULL)
free(c_name);
if(c_name)
HDfree(c_name);
if(c_name1)
HDfree(c_name1);
return ret_value;
}
@ -417,6 +338,7 @@ nh5tbread_field_name_int_c(hid_t_f *loc_id,
{
return nh5tbread_field_name_c(loc_id,namelen,name,namelen1,field_name,start,nrecords,type_size,buf);
}
int_f
nh5tbread_field_name_fl_c(hid_t_f *loc_id,
int_f *namelen,
@ -430,6 +352,7 @@ nh5tbread_field_name_fl_c(hid_t_f *loc_id,
{
return nh5tbread_field_name_c(loc_id,namelen,name,namelen1,field_name,start,nrecords,type_size,buf);
}
int_f
nh5tbread_field_name_dl_c(hid_t_f *loc_id,
int_f *namelen,
@ -443,6 +366,7 @@ nh5tbread_field_name_dl_c(hid_t_f *loc_id,
{
return nh5tbread_field_name_c(loc_id,namelen,name,namelen1,field_name,start,nrecords,type_size,buf);
}
int_f
nh5tbread_field_name_st_c(hid_t_f *loc_id,
int_f *namelen,
@ -486,45 +410,31 @@ nh5tbwrite_field_index_c(hid_t_f *loc_id,
size_t_f *type_size,
void *buf)
{
int ret_value = -1;
herr_t ret;
char *c_name = NULL;
int c_namelen;
char *c_name = NULL;
hid_t c_loc_id = *loc_id;
hsize_t c_start = *start;
hsize_t c_nrecords = *nrecords;
size_t c_type_size = *type_size;
size_t c_type_sizes[1];
int c_field_index[1];
c_type_sizes[0] = c_type_size;
c_field_index[0] = *field_index - 1; /* C zero based index */
int c_field_index = *field_index - 1; /* C zero based index */
int_f ret_value = 0;
/*
* convert FORTRAN name to C name
*/
c_namelen = *namelen;
c_name = (char *)HD5f2cstring(name, c_namelen);
if (c_name == NULL)
goto done;
if(NULL == (c_name = (char *)HD5f2cstring(name, (size_t)*namelen)))
HGOTO_DONE(FAIL)
/*
* call H5TBwrite_fields_name function.
*/
ret = H5TBwrite_fields_index(c_loc_id,c_name,(hsize_t)1,c_field_index,c_start,c_nrecords,c_type_size,
0,c_type_sizes,buf);
if (ret < 0)
goto done;
ret_value = 0;
if(H5TBwrite_fields_index(c_loc_id, c_name, (hsize_t)1, &c_field_index,
c_start, c_nrecords, c_type_size, 0, &c_type_size, buf) < 0)
HGOTO_DONE(FAIL)
done:
if(c_name != NULL)
free(c_name);
if(c_name)
HDfree(c_name);
return ret_value;
}
@ -541,6 +451,7 @@ nh5tbwrite_field_index_int_c(hid_t_f *loc_id,
{
return nh5tbwrite_field_index_c(loc_id,namelen,name,field_index,start,nrecords,type_size,buf);
}
int_f
nh5tbwrite_field_index_fl_c(hid_t_f *loc_id,
int_f *namelen,
@ -553,6 +464,7 @@ nh5tbwrite_field_index_fl_c(hid_t_f *loc_id,
{
return nh5tbwrite_field_index_c(loc_id,namelen,name,field_index,start,nrecords,type_size,buf);
}
int_f
nh5tbwrite_field_index_dl_c(hid_t_f *loc_id,
int_f *namelen,
@ -565,6 +477,7 @@ nh5tbwrite_field_index_dl_c(hid_t_f *loc_id,
{
return nh5tbwrite_field_index_c(loc_id,namelen,name,field_index,start,nrecords,type_size,buf);
}
int_f
nh5tbwrite_field_index_st_c(hid_t_f *loc_id,
int_f *namelen,
@ -607,51 +520,30 @@ nh5tbread_field_index_c(hid_t_f *loc_id,
size_t_f *type_size,
void *buf)
{
int ret_value = -1;
herr_t ret;
char *c_name = NULL;
int c_namelen;
char *c_name = NULL;
hid_t c_loc_id = *loc_id;
hsize_t c_start = *start;
hsize_t c_nrecords = *nrecords;
size_t c_type_size = *type_size;
size_t c_type_sizes[1];
int c_field_index[1];
c_type_sizes[0] = c_type_size;
c_field_index[0] = *field_index - 1; /* C zero based index */
int c_field_index = *field_index - 1; /* C zero based index */
int_f ret_value = 0;
/*
* convert FORTRAN name to C name
*/
c_namelen = *namelen;
c_name = (char *)HD5f2cstring(name, c_namelen);
if (c_name == NULL)
goto done;
* convert FORTRAN name to C name
*/
if(NULL == (c_name = (char *)HD5f2cstring(name, (size_t)*namelen)))
HGOTO_DONE(FAIL)
/*
* call H5TBread_fields_index function.
*/
ret = H5TBread_fields_index(c_loc_id,
c_name,(hsize_t)1,
c_field_index,
c_start,
c_nrecords,
c_type_size,
0,
c_type_sizes,
buf);
if (ret < 0)
goto done;
ret_value = 0;
* call H5TBread_fields_index function.
*/
if(H5TBread_fields_index(c_loc_id, c_name,(hsize_t)1, &c_field_index,
c_start, c_nrecords, c_type_size, 0, &c_type_size, buf) < 0)
HGOTO_DONE(FAIL)
done:
if(c_name != NULL)
free(c_name);
if(c_name)
HDfree(c_name);
return ret_value;
}
@ -668,6 +560,7 @@ nh5tbread_field_index_int_c(hid_t_f *loc_id,
{
return nh5tbread_field_index_c(loc_id,namelen,name,field_index,start,nrecords,type_size,buf);
}
int_f
nh5tbread_field_index_fl_c(hid_t_f *loc_id,
int_f *namelen,
@ -680,6 +573,7 @@ nh5tbread_field_index_fl_c(hid_t_f *loc_id,
{
return nh5tbread_field_index_c(loc_id,namelen,name,field_index,start,nrecords,type_size,buf);
}
int_f
nh5tbread_field_index_dl_c(hid_t_f *loc_id,
int_f *namelen,
@ -692,6 +586,7 @@ nh5tbread_field_index_dl_c(hid_t_f *loc_id,
{
return nh5tbread_field_index_c(loc_id,namelen,name,field_index,start,nrecords,type_size,buf);
}
int_f
nh5tbread_field_index_st_c(hid_t_f *loc_id,
int_f *namelen,
@ -734,51 +629,34 @@ nh5tbinsert_field_c(hid_t_f *loc_id,
int_f *position,
void *buf)
{
int ret_value = -1;
herr_t ret;
char *c_name = NULL;
int c_namelen;
char *c_name1 = NULL;
int c_namelen1;
char *c_name = NULL;
char *c_name1 = NULL;
hid_t c_loc_id = *loc_id;
hid_t c_field_type = *field_type;
hsize_t c_position = *position;
int_f ret_value = 0;
/*
* convert FORTRAN name to C name
*/
c_namelen = *namelen;
c_name = (char *)HD5f2cstring(name, c_namelen);
if (c_name == NULL)
goto done;
c_namelen1 = *namelen1;
c_name1 = (char *)HD5f2cstring(field_name, c_namelen1);
if (c_name1 == NULL)
goto done;
if(NULL == (c_name = (char *)HD5f2cstring(name, (size_t)*namelen)))
HGOTO_DONE(FAIL)
if(NULL == (c_name1 = (char *)HD5f2cstring(field_name, (size_t)*namelen1)))
HGOTO_DONE(FAIL)
/*
* call H5TBinsert_field function.
*/
ret = H5TBinsert_field(c_loc_id,
c_name,
c_name1,
c_field_type,
c_position,
NULL,
buf);
if (ret < 0)
goto done;
ret_value = 0;
if(H5TBinsert_field(c_loc_id, c_name, c_name1, c_field_type, c_position,
NULL, buf) < 0)
HGOTO_DONE(FAIL)
done:
if(c_name != NULL)
free(c_name);
if(c_name1 != NULL)
free(c_name1);
if(c_name )
HDfree(c_name);
if(c_name1)
HDfree(c_name1);
return ret_value;
}
@ -795,6 +673,7 @@ nh5tbinsert_field_int_c(hid_t_f *loc_id,
{
return nh5tbinsert_field_c(loc_id,namelen,name,namelen1,field_name,field_type,position,buf);
}
int_f
nh5tbinsert_field_fl_c(hid_t_f *loc_id,
int_f *namelen,
@ -807,6 +686,7 @@ nh5tbinsert_field_fl_c(hid_t_f *loc_id,
{
return nh5tbinsert_field_c(loc_id,namelen,name,namelen1,field_name,field_type,position,buf);
}
int_f
nh5tbinsert_field_dl_c(hid_t_f *loc_id,
int_f *namelen,
@ -819,6 +699,7 @@ nh5tbinsert_field_dl_c(hid_t_f *loc_id,
{
return nh5tbinsert_field_c(loc_id,namelen,name,namelen1,field_name,field_type,position,buf);
}
int_f
nh5tbinsert_field_st_c(hid_t_f *loc_id,
int_f *namelen,
@ -858,49 +739,32 @@ nh5tbdelete_field_c(hid_t_f *loc_id,
int_f *namelen1,
_fcd field_name)
{
int ret_value = -1;
herr_t ret;
char *c_name = NULL;
int c_namelen;
char *c_name1 = NULL;
int c_namelen1;
char *c_name = NULL;
char *c_name1 = NULL;
hid_t c_loc_id = *loc_id;
int_f ret_value = 0;
/*
* convert FORTRAN name to C name
*/
c_namelen = *namelen;
c_name = (char *)HD5f2cstring(name, c_namelen);
if (c_name == NULL)
goto done;
c_namelen1 = *namelen1;
c_name1 = (char *)HD5f2cstring(field_name, c_namelen1);
if (c_name1 == NULL)
goto done;
* convert FORTRAN name to C name
*/
if(NULL == (c_name = (char *)HD5f2cstring(name, (size_t)*namelen)))
HGOTO_DONE(FAIL)
if(NULL == (c_name1 = (char *)HD5f2cstring(field_name, (size_t)*namelen1)))
HGOTO_DONE(FAIL)
/*
* call H5TBinsert_field function.
*/
ret = H5TBdelete_field(c_loc_id,
c_name,
c_name1);
if (ret < 0)
goto done;
ret_value = 0;
* call H5TBinsert_field function.
*/
if(H5TBdelete_field(c_loc_id, c_name, c_name1) < 0)
HGOTO_DONE(FAIL)
done:
if(c_name != NULL)
free(c_name);
if(c_name)
HDfree(c_name);
return ret_value;
}
/*-------------------------------------------------------------------------
* Function: h5tbget_table_info_c
*
@ -927,42 +791,30 @@ nh5tbget_table_info_c(hid_t_f *loc_id,
hsize_t_f *nfields,
hsize_t_f *nrecords)
{
int ret_value = -1;
herr_t ret;
char *c_name = NULL;
int c_namelen;
char *c_name = NULL;
hid_t c_loc_id = *loc_id;
hsize_t c_nfields;
hsize_t c_nrecords;
int_f ret_value = 0;
/*
* convert FORTRAN name to C name
*/
c_namelen = *namelen;
c_name = (char *)HD5f2cstring(name, c_namelen);
if (c_name == NULL)
goto done;
* convert FORTRAN name to C name
*/
if(NULL == (c_name = (char *)HD5f2cstring(name, (size_t)*namelen)))
HGOTO_DONE(FAIL)
/*
* call H5TBread_fields_index function.
*/
ret = H5TBget_table_info(c_loc_id,
c_name,
&c_nfields,
&c_nrecords);
if (ret < 0)
goto done;
* call H5TBread_fields_index function.
*/
if(H5TBget_table_info(c_loc_id, c_name, &c_nfields, &c_nrecords) < 0)
HGOTO_DONE(FAIL)
*nfields = (hsize_t_f) c_nfields;;
*nrecords = (hsize_t_f) c_nrecords;
ret_value = 0;
done:
if(c_name != NULL)
free(c_name);
if(c_name)
HDfree(c_name);
return ret_value;
}
@ -999,113 +851,88 @@ nh5tbget_field_info_c(hid_t_f *loc_id,
_fcd field_names) /* field_names */
{
int ret_value = -1;
herr_t ret;
char *c_name = NULL;
int c_namelen;
char *c_name = NULL;
hsize_t num_elem;
hsize_t i;
int max_len=1;
int max_len = 1;
hid_t c_loc_id = *loc_id;
hsize_t c_nfields = *nfields;
size_t *c_field_sizes = NULL;
size_t *c_field_offsets = NULL;
size_t *c_field_sizes = NULL;
size_t *c_field_offsets = NULL;
size_t c_type_size;
char **c_field_names = NULL;
char *tmp = NULL, *tmp_p = NULL;
int c_lenmax=HLTB_MAX_FIELD_LEN;
size_t length = 0;
char **c_field_names = NULL;
char *tmp = NULL, *tmp_p;
int c_lenmax = HLTB_MAX_FIELD_LEN;
int_f ret_value = 0;
num_elem = c_nfields;
for (i=0; i < num_elem; i++)
{
if (namelen2[i] > max_len) max_len = namelen2[i];
for(i = 0; i < num_elem; i++) {
if(namelen2[i] > max_len)
max_len = namelen2[i];
}
/*
* convert FORTRAN name to C name
*/
c_namelen = *namelen;
c_name = (char *)HD5f2cstring(name, c_namelen);
if (c_name == NULL)
goto done;
* convert FORTRAN name to C name
*/
if(NULL == (c_name = (char *)HD5f2cstring(name, (size_t)*namelen)))
HGOTO_DONE(FAIL)
if(NULL == (c_field_offsets = (size_t *)HDmalloc(sizeof(size_t) * (size_t)c_nfields)))
HGOTO_DONE(FAIL)
if(NULL == (c_field_sizes = (size_t *)HDmalloc(sizeof(size_t) * (size_t)c_nfields)))
HGOTO_DONE(FAIL)
if(NULL == (c_field_names = (char **)HDcalloc((size_t)c_nfields, sizeof(char *))))
HGOTO_DONE(FAIL)
c_field_offsets = (size_t*)malloc(sizeof(size_t) * (size_t)c_nfields);
if (!c_field_offsets)
goto done;
c_field_sizes = (size_t*)malloc(sizeof(size_t) * (size_t)c_nfields);
if (!c_field_sizes)
goto done;
c_field_names = malloc( sizeof(char*) * (size_t)c_nfields );
if (!c_field_names) return ret_value;
for ( i = 0; i < c_nfields; i++)
{
c_field_names[i] = malloc( sizeof(char) * HLTB_MAX_FIELD_LEN );
}
for(i = 0; i < c_nfields; i++)
if(NULL == (c_field_names[i] = (char *)HDmalloc(sizeof(char) * HLTB_MAX_FIELD_LEN)))
HGOTO_DONE(FAIL)
/*
* call H5TBget_field_info function.
*/
ret = H5TBget_field_info(c_loc_id,
c_name,
c_field_names,
c_field_sizes,
c_field_offsets,
&c_type_size);
* call H5TBget_field_info function.
*/
if(H5TBget_field_info(c_loc_id, c_name, c_field_names, c_field_sizes,
c_field_offsets, &c_type_size) < 0)
HGOTO_DONE(FAIL)
/* return values*/
/* names array */
tmp = (char *)malloc(c_lenmax* (size_t) c_nfields + 1);
tmp_p = tmp;
memset(tmp,' ', c_lenmax* (size_t) c_nfields);
tmp[c_lenmax*c_nfields] = '\0';
for (i=0; i < c_nfields; i++)
{
memcpy(tmp_p, c_field_names[i], strlen(c_field_names[i]));
namelen2[i] = (int_f)strlen(c_field_names[i]);
length = MAX(length, strlen(c_field_names[i]));
tmp_p = tmp_p + c_lenmax;
}
HD5packFstring(tmp, _fcdtocp(field_names), (int)(c_lenmax*c_nfields));
if(NULL == (tmp = (char *)HDmalloc((c_lenmax * (size_t)c_nfields) + 1)))
HGOTO_DONE(FAIL)
tmp_p = tmp;
HDmemset(tmp, ' ', c_lenmax * (size_t)c_nfields);
tmp[c_lenmax * c_nfields] = '\0';
for(i = 0; i < c_nfields; i++) {
size_t field_name_len = HDstrlen(c_field_names[i]);
HDmemcpy(tmp_p, c_field_names[i], field_name_len);
namelen2[i] = (int_f)field_name_len;
tmp_p += c_lenmax;
}
HD5packFstring(tmp, _fcdtocp(field_names), (int)(c_lenmax * c_nfields));
*type_size = (size_t_f)c_type_size;
for (i=0; i < num_elem; i++)
{
for(i = 0; i < num_elem; i++) {
field_sizes[i] = (size_t_f)c_field_sizes[i];
field_offsets[i] = (size_t_f)c_field_offsets[i];
}
if (ret < 0)
goto done;
ret_value = 0;
done:
if(c_name != NULL)
free(c_name);
for ( i = 0; i < num_elem; i++)
{
if ( c_field_names[i] )
free (c_field_names[i]);
}
if ( c_field_names )
free(c_field_names);
if ( tmp )
free(tmp);
if ( c_field_offsets )
free(c_field_offsets);
if ( c_field_sizes )
free(c_field_sizes);
if(c_name)
HDfree(c_name);
if(c_field_names) {
for(i = 0; i < num_elem; i++)
if(c_field_names[i])
HDfree(c_field_names[i]);
HDfree(c_field_names);
} /* end if */
if(tmp)
HDfree(tmp);
if(c_field_offsets)
HDfree(c_field_offsets);
if(c_field_sizes)
HDfree(c_field_sizes);
return ret_value;
}

View File

@ -366,7 +366,6 @@ H5Oopen_by_addr(hid_t loc_id, haddr_t addr)
H5G_loc_t obj_loc; /* Location used to open group */
H5G_name_t obj_path; /* Opened object group hier. path */
H5O_loc_t obj_oloc; /* Opened object object location */
hbool_t loc_found = FALSE; /* Location at 'name' found */
hid_t lapl_id = H5P_LINK_ACCESS_DEFAULT; /* lapl to use to open this object */
hid_t ret_value = FAIL;
@ -392,9 +391,6 @@ H5Oopen_by_addr(hid_t loc_id, haddr_t addr)
HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open object")
done:
if(ret_value < 0 && loc_found)
if(H5G_loc_free(&obj_loc) < 0)
HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "can't free location")
FUNC_LEAVE_API(ret_value)
} /* end H5Oopen_by_addr() */

149
src/H5S.c
View File

@ -206,8 +206,10 @@ H5S_create(H5S_class_t type)
ret_value = new_ds;
done:
if(ret_value == NULL && new_ds)
H5S_close(new_ds);
if(ret_value == NULL) {
if(new_ds && H5S_close(new_ds) < 0)
HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, NULL, "unable to release dataspace")
} /* end if */
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5S_create() */
@ -237,7 +239,7 @@ H5Screate(H5S_class_t type)
H5S_t *new_ds=NULL; /* New dataspace structure */
hid_t ret_value; /* Return value */
FUNC_ENTER_API(H5Screate, FAIL);
FUNC_ENTER_API(H5Screate, FAIL)
H5TRACE1("i", "Sc", type);
/* Check args */
@ -252,10 +254,12 @@ H5Screate(H5S_class_t type)
HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register dataspace atom")
done:
if(ret_value < 0 && new_ds)
H5S_close(new_ds);
if(ret_value < 0) {
if(new_ds && H5S_close(new_ds) < 0)
HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release dataspace")
} /* end if */
FUNC_LEAVE_API(ret_value);
FUNC_LEAVE_API(ret_value)
} /* end H5Screate() */
@ -278,7 +282,7 @@ H5S_extent_release(H5S_extent_t *extent)
{
herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5S_extent_release, FAIL);
FUNC_ENTER_NOAPI(H5S_extent_release, FAIL)
assert(extent);
@ -291,7 +295,7 @@ H5S_extent_release(H5S_extent_t *extent)
} /* end if */
done:
FUNC_LEAVE_NOAPI(ret_value);
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5S_extent_release() */
@ -310,20 +314,22 @@ done:
herr_t
H5S_close(H5S_t *ds)
{
herr_t ret_value = SUCCEED; /* Return value */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5S_close, FAIL)
HDassert(ds);
/* Release selection (this should come before the extent release) */
H5S_SELECT_RELEASE(ds);
if(H5S_SELECT_RELEASE(ds) < 0)
HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release dataspace selection")
/* Release extent */
H5S_extent_release(&ds->extent);
if(H5S_extent_release(&ds->extent) < 0)
HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release dataspace extent")
/* Release the main structure */
(void)H5FL_FREE(H5S_t, ds);
ds = H5FL_FREE(H5S_t, ds);
done:
FUNC_LEAVE_NOAPI(ret_value)
@ -351,7 +357,7 @@ H5Sclose(hid_t space_id)
{
herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_API(H5Sclose, FAIL);
FUNC_ENTER_API(H5Sclose, FAIL)
H5TRACE1("e", "i", space_id);
/* Check args */
@ -363,7 +369,7 @@ H5Sclose(hid_t space_id)
HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "problem freeing id")
done:
FUNC_LEAVE_API(ret_value);
FUNC_LEAVE_API(ret_value)
}
@ -390,29 +396,29 @@ H5Scopy(hid_t space_id)
H5S_t *dst = NULL;
hid_t ret_value;
FUNC_ENTER_API(H5Scopy, FAIL);
FUNC_ENTER_API(H5Scopy, FAIL)
H5TRACE1("i", "i", space_id);
/* Check args */
if (NULL==(src=(H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE)))
if(NULL == (src = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace")
/* Copy */
if (NULL == (dst = H5S_copy(src, FALSE, TRUE)))
if(NULL == (dst = H5S_copy(src, FALSE, TRUE)))
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to copy dataspace")
/* Atomize */
if ((ret_value=H5I_register (H5I_DATASPACE, dst, TRUE))<0)
if((ret_value = H5I_register (H5I_DATASPACE, dst, TRUE)) < 0)
HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register dataspace atom")
done:
if(ret_value<0) {
if(dst!=NULL)
H5S_close(dst);
if(ret_value < 0) {
if(dst && H5S_close(dst) < 0)
HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release dataspace")
} /* end if */
FUNC_LEAVE_API(ret_value);
}
FUNC_LEAVE_API(ret_value)
} /* end H5Scopy() */
/*-------------------------------------------------------------------------
@ -675,7 +681,7 @@ H5S_get_npoints_max(const H5S_t *ds)
hsize_t ret_value;
unsigned u;
FUNC_ENTER_NOAPI(H5S_get_npoints_max, 0);
FUNC_ENTER_NOAPI(H5S_get_npoints_max, 0)
/* check args */
assert(ds);
@ -712,7 +718,7 @@ H5S_get_npoints_max(const H5S_t *ds)
}
done:
FUNC_LEAVE_NOAPI(ret_value);
FUNC_LEAVE_NOAPI(ret_value)
}
@ -829,7 +835,7 @@ H5Sget_simple_extent_dims(hid_t space_id, hsize_t dims[]/*out*/,
H5S_t *ds;
int ret_value;
FUNC_ENTER_API(H5Sget_simple_extent_dims, FAIL);
FUNC_ENTER_API(H5Sget_simple_extent_dims, FAIL)
H5TRACE3("Is", "ixx", space_id, dims, maxdims);
/* Check args */
@ -839,7 +845,7 @@ H5Sget_simple_extent_dims(hid_t space_id, hsize_t dims[]/*out*/,
ret_value = H5S_get_simple_extent_dims(ds, dims, maxdims);
done:
FUNC_LEAVE_API(ret_value);
FUNC_LEAVE_API(ret_value)
}
@ -1109,7 +1115,7 @@ H5Sis_simple(hid_t space_id)
H5S_t *space; /* dataspace to modify */
htri_t ret_value;
FUNC_ENTER_API(H5Sis_simple, FAIL);
FUNC_ENTER_API(H5Sis_simple, FAIL)
H5TRACE1("t", "i", space_id);
/* Check args and all the boring stuff. */
@ -1119,7 +1125,7 @@ H5Sis_simple(hid_t space_id)
ret_value = H5S_is_simple(space);
done:
FUNC_LEAVE_API(ret_value);
FUNC_LEAVE_API(ret_value)
}
@ -1163,7 +1169,7 @@ H5Sset_extent_simple(hid_t space_id, int rank, const hsize_t dims[/*rank*/],
int u; /* local counting variable */
herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_API(H5Sset_extent_simple, FAIL);
FUNC_ENTER_API(H5Sset_extent_simple, FAIL)
H5TRACE4("e", "iIs*[a1]h*[a1]h", space_id, rank, dims, max);
/* Check args */
@ -1195,7 +1201,7 @@ H5Sset_extent_simple(hid_t space_id, int rank, const hsize_t dims[/*rank*/],
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to set simple extent")
done:
FUNC_LEAVE_API(ret_value);
FUNC_LEAVE_API(ret_value)
}
@ -1294,67 +1300,66 @@ done:
*
* Failure: Negative
*
* Errors:
*
* Programmer: Quincey Koziol
* Tuesday, January 27, 1998
*
* Modifications: Christian Chilan 01/17/2007
* Verifies that each element of DIMS is not equal to
* H5S_UNLIMITED.
*
*-------------------------------------------------------------------------
*/
hid_t
H5Screate_simple(int rank, const hsize_t dims[/*rank*/],
const hsize_t maxdims[/*rank*/])
{
hid_t ret_value;
H5S_t *space = NULL;
int i;
hid_t ret_value;
FUNC_ENTER_API(H5Screate_simple, FAIL);
FUNC_ENTER_API(H5Screate_simple, FAIL)
H5TRACE3("i", "Is*[a0]h*[a0]h", rank, dims, maxdims);
/* Check arguments */
if (rank<0)
if(rank < 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "dimensionality cannot be negative")
if (rank>H5S_MAX_RANK)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "dimensionality is too large")
if (!dims && dims!=0)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no dimensions specified")
if(rank > H5S_MAX_RANK)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "dimensionality is too large")
/* We allow users to use this function to create scalar or null dataspace.
* Check DIMS isn't set when the RANK is 0.
*/
if(!dims && rank != 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid dataspace information")
/* Check whether the current dimensions are valid */
for (i=0; i<rank; i++) {
if (H5S_UNLIMITED==dims[i])
for(i = 0; i < rank; i++) {
if(H5S_UNLIMITED == dims[i])
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "current dimension must have a specific size, not H5S_UNLIMITED")
if (maxdims) {
if (H5S_UNLIMITED!=maxdims[i] && maxdims[i]<dims[i])
if(maxdims) {
if(H5S_UNLIMITED != maxdims[i] && maxdims[i]<dims[i])
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "maxdims is smaller than dims")
if (H5S_UNLIMITED!=maxdims[i] && dims[i]==0)
if(H5S_UNLIMITED != maxdims[i] && dims[i] == 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "zero sized dimension for non-unlimited dimension")
}
} /* end if */
else {
if (dims[i]==0)
if(dims[i] == 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "zero sized dimension for non-unlimited dimension")
}
}
} /* end else */
} /* end else */
/* Create the space and set the extent */
if(NULL==(space=H5S_create_simple((unsigned)rank,dims,maxdims)))
if(NULL == (space = H5S_create_simple((unsigned)rank,dims,maxdims)))
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCREATE, FAIL, "can't create simple dataspace")
/* Atomize */
if ((ret_value=H5I_register (H5I_DATASPACE, space, TRUE))<0)
if((ret_value = H5I_register (H5I_DATASPACE, space, TRUE)) < 0)
HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register dataspace ID")
done:
if (ret_value<0) {
if (space!=NULL)
H5S_close(space);
if(ret_value < 0) {
if(space && H5S_close(space) < 0)
HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release dataspace")
} /* end if */
FUNC_LEAVE_API(ret_value);
}
FUNC_LEAVE_API(ret_value)
} /* end H5Screate_simple() */
/*-------------------------------------------------------------------------
@ -1382,7 +1387,7 @@ H5S_create_simple(unsigned rank, const hsize_t dims[/*rank*/],
{
H5S_t *ret_value; /* Return value */
FUNC_ENTER_NOAPI(H5S_create_simple, NULL);
FUNC_ENTER_NOAPI(H5S_create_simple, NULL)
/* Check arguments */
assert(rank <=H5S_MAX_RANK);
@ -1394,7 +1399,7 @@ H5S_create_simple(unsigned rank, const hsize_t dims[/*rank*/],
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, NULL, "can't set dimensions")
done:
FUNC_LEAVE_NOAPI(ret_value);
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5S_create_simple() */
@ -1422,7 +1427,7 @@ H5Sencode(hid_t obj_id, void *buf, size_t *nalloc)
H5S_t *dspace;
herr_t ret_value=SUCCEED;
FUNC_ENTER_API (H5Sencode, FAIL);
FUNC_ENTER_API (H5Sencode, FAIL)
H5TRACE3("e", "i*x*z", obj_id, buf, nalloc);
/* Check argument and retrieve object */
@ -1433,7 +1438,7 @@ H5Sencode(hid_t obj_id, void *buf, size_t *nalloc)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTENCODE, FAIL, "can't encode datatype")
done:
FUNC_LEAVE_API(ret_value);
FUNC_LEAVE_API(ret_value)
}
@ -1661,14 +1666,14 @@ H5S_get_simple_extent_type(const H5S_t *space)
{
H5S_class_t ret_value;
FUNC_ENTER_NOAPI(H5S_get_simple_extent_type, H5S_NO_CLASS);
FUNC_ENTER_NOAPI(H5S_get_simple_extent_type, H5S_NO_CLASS)
assert(space);
ret_value=H5S_GET_EXTENT_TYPE(space);
done:
FUNC_LEAVE_NOAPI(ret_value);
FUNC_LEAVE_NOAPI(ret_value)
}
@ -1696,7 +1701,7 @@ H5Sget_simple_extent_type(hid_t sid)
H5S_t *space;
H5S_class_t ret_value;
FUNC_ENTER_API(H5Sget_simple_extent_type, H5S_NO_CLASS);
FUNC_ENTER_API(H5Sget_simple_extent_type, H5S_NO_CLASS)
H5TRACE1("Sc", "i", sid);
/* Check arguments */
@ -1706,7 +1711,7 @@ H5Sget_simple_extent_type(hid_t sid)
ret_value=H5S_GET_EXTENT_TYPE(space);
done:
FUNC_LEAVE_API(ret_value);
FUNC_LEAVE_API(ret_value)
}
@ -1730,7 +1735,7 @@ H5Sset_extent_none(hid_t space_id)
H5S_t *space; /* dataspace to modify */
herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_API(H5Sset_extent_none, FAIL);
FUNC_ENTER_API(H5Sset_extent_none, FAIL)
H5TRACE1("e", "i", space_id);
/* Check args */
@ -1744,7 +1749,7 @@ H5Sset_extent_none(hid_t space_id)
space->extent.type=H5S_NO_CLASS;
done:
FUNC_LEAVE_API(ret_value);
FUNC_LEAVE_API(ret_value)
} /* end H5Sset_extent_none() */
@ -1770,7 +1775,7 @@ H5Soffset_simple(hid_t space_id, const hssize_t *offset)
H5S_t *space; /* dataspace to modify */
herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_API(H5Soffset_simple, FAIL);
FUNC_ENTER_API(H5Soffset_simple, FAIL)
H5TRACE2("e", "i*Hs", space_id, offset);
/* Check args */
@ -1787,7 +1792,7 @@ H5Soffset_simple(hid_t space_id, const hssize_t *offset)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "can't set offset")
done:
FUNC_LEAVE_API(ret_value);
FUNC_LEAVE_API(ret_value)
} /* end H5Soffset_simple() */

View File

@ -14548,23 +14548,8 @@ check_rename_entry__run_test(H5C_t * cache_ptr,
test_entry_t * entry_ptr = NULL;
H5C_cache_entry_t * test_ptr = NULL;
if ( cache_ptr == NULL ) {
pass = FALSE;
HDsnprintf(msg, (size_t)128,
"cache_ptr NULL on entry to rename test #%d.",
test_num);
failure_mssg = msg;
} else if ( spec_ptr == NULL ) {
pass = FALSE;
HDsnprintf(msg, (size_t)128,
"spec_ptr NULL on entry to rename test #%d.",
test_num);
failure_mssg = msg;
}
assert( cache_ptr );
assert( spec_ptr );
if ( pass ) {
@ -14589,12 +14574,16 @@ check_rename_entry__run_test(H5C_t * cache_ptr,
}
}
protect_entry(cache_ptr, spec_ptr->entry_type, spec_ptr->entry_index);
if ( pass ) {
unprotect_entry(cache_ptr, spec_ptr->entry_type, spec_ptr->entry_index,
(int)(spec_ptr->is_dirty), flags);
protect_entry(cache_ptr, spec_ptr->entry_type, spec_ptr->entry_index);
rename_entry(cache_ptr, spec_ptr->entry_type, spec_ptr->entry_index, FALSE);
unprotect_entry(cache_ptr, spec_ptr->entry_type, spec_ptr->entry_index,
(int)(spec_ptr->is_dirty), flags);
rename_entry(cache_ptr, spec_ptr->entry_type, spec_ptr->entry_index, FALSE);
}
if ( pass ) {
@ -17933,7 +17922,7 @@ check_check_evictions_enabled_err(void)
}
if ( pass ) {
if ( cache_ptr ) {
takedown_cache(cache_ptr, FALSE, FALSE);
}
@ -28232,7 +28221,7 @@ check_auto_cache_resize_input_errs(void)
}
}
if ( pass ) {
if ( cache_ptr ) {
takedown_cache(cache_ptr, FALSE, FALSE);
}
@ -28774,7 +28763,7 @@ check_auto_cache_resize_aux_fcns(void)
}
}
if ( pass ) {
if ( cache_ptr ) {
takedown_cache(cache_ptr, FALSE, FALSE);
}

View File

@ -699,11 +699,11 @@ test_h5s_scalar_write(void)
{
hid_t fid1; /* HDF5 File IDs */
hid_t dataset; /* Dataset ID */
hid_t sid1; /* Dataspace ID */
hid_t sid1; /* Dataspace ID */
int rank; /* Logical rank of dataspace */
hsize_t tdims[4]; /* Dimension array to test with */
hssize_t n; /* Number of dataspace elements */
H5S_class_t ext_type; /* Extent type */
H5S_class_t ext_type; /* Extent type */
herr_t ret; /* Generic return value */
/* Output message about test being performed */
@ -713,6 +713,12 @@ test_h5s_scalar_write(void)
fid1 = H5Fcreate(DATAFILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
CHECK(fid1, FAIL, "H5Fcreate");
/* Verify a non-zero rank fails with a NULL dimension. */
H5E_BEGIN_TRY {
sid1 = H5Screate_simple(SPACE1_RANK, NULL, NULL);
} H5E_END_TRY
VERIFY(sid1, FAIL, "H5Screate_simple");
/* Create scalar dataspace */
sid1 = H5Screate_simple(SPACE3_RANK, NULL, NULL);
CHECK(sid1, FAIL, "H5Screate_simple");