diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2007-10-11 16:24:11 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2007-10-11 16:24:11 (GMT) |
commit | d9e5ca72f39934531b534524d07cf784c3d0e613 (patch) | |
tree | 1913b13a317132523091035f1175b2291c8b9db7 /hl/src | |
parent | 053807fa81579e6bd9ac6a701ddcaac39e4d0b87 (diff) | |
download | hdf5-d9e5ca72f39934531b534524d07cf784c3d0e613.zip hdf5-d9e5ca72f39934531b534524d07cf784c3d0e613.tar.gz hdf5-d9e5ca72f39934531b534524d07cf784c3d0e613.tar.bz2 |
[svn-r14199] Description:
Add H5Dcreate to API versioned routines, replacing internal usage with
H5Dcreate2
Fix thread-safe error stack initialization for API versioned error
stack printing routines.
Tested on:
FreeBSD/32 6.2 (duty) in debug mode
FreeBSD/64 6.2 (liberty) w/C++ & FORTRAN, in debug mode
Linux/32 2.6 (kagiso) w/PGI compilers, w/C++ & FORTRAN, w/threadsafe,
in debug mode
Linux/64-amd64 2.6 (smirom) w/default API=1.6.x, w/C++ & FORTRAN,
in production mode
Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, in production mode
Mac OS X/32 10.4.10 (amazon) in debug mode
Diffstat (limited to 'hl/src')
-rw-r--r-- | hl/src/H5LT.c | 383 | ||||
-rw-r--r-- | hl/src/H5PT.c | 66 | ||||
-rw-r--r-- | hl/src/H5TB.c | 102 |
3 files changed, 181 insertions, 370 deletions
diff --git a/hl/src/H5LT.c b/hl/src/H5LT.c index a98d567..e226f89 100644 --- a/hl/src/H5LT.c +++ b/hl/src/H5LT.c @@ -45,6 +45,61 @@ static herr_t H5LT_get_attribute_mem(hid_t loc_id, void *data); /*------------------------------------------------------------------------- + * Function: H5LT_make_dataset + * + * Purpose: Creates and writes a dataset of a type tid + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Quincey Koziol, koziol@hdfgroup.org + * + * Date: October 10, 2007 + * + *------------------------------------------------------------------------- + */ + +static herr_t +H5LT_make_dataset_numerical( hid_t loc_id, + const char *dset_name, + int rank, + const hsize_t *dims, + hid_t tid, + const void *data ) +{ + hid_t did = -1, sid = -1; + + /* Create the data space for the dataset. */ + if((sid = H5Screate_simple(rank, dims, NULL)) < 0) + return -1; + + /* Create the dataset. */ + if((did = H5Dcreate2(loc_id, dset_name, tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + goto out; + + /* Write the dataset only if there is data to write */ + if(data) + if(H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, data) < 0) + goto out; + + /* End access to the dataset and release resources used by it. */ + if(H5Dclose(did) < 0) + return -1; + + /* Terminate access to the data space. */ + if(H5Sclose(sid) < 0) + return -1; + + return 0; + +out: + H5E_BEGIN_TRY { + H5Dclose(did); + H5Sclose(sid); + } H5E_END_TRY; + return -1; +} + +/*------------------------------------------------------------------------- * * Public functions * @@ -77,39 +132,7 @@ herr_t H5LTmake_dataset( hid_t loc_id, hid_t tid, const void *data ) { - - hid_t did, sid; - - /* Create the data space for the dataset. */ - if ( (sid = H5Screate_simple( rank, dims, NULL )) < 0 ) - return -1; - - /* Create the dataset. */ - if ( (did = H5Dcreate( loc_id, dset_name, tid, sid, H5P_DEFAULT )) < 0 ) - goto out; - - /* Write the dataset only if there is data to write */ - - if ( data ) - { - if ( H5Dwrite( did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, data ) < 0 ) - goto out; - } - - /* End access to the dataset and release resources used by it. */ - if ( H5Dclose( did ) < 0 ) - return -1; - - /* Terminate access to the data space. */ - if ( H5Sclose( sid ) < 0 ) - return -1; - - return 0; - -out: - H5Dclose( did ); - H5Sclose( sid ); - return -1; + return(H5LT_make_dataset_numerical(loc_id, dset_name, rank, dims, tid, data)); } /*------------------------------------------------------------------------- @@ -137,39 +160,7 @@ herr_t H5LTmake_dataset_char( hid_t loc_id, const hsize_t *dims, const char *data ) { - - hid_t did, sid; - - /* Create the data space for the dataset. */ - if ( (sid = H5Screate_simple( rank, dims, NULL )) < 0 ) - return -1; - - /* Create the dataset. */ - if ( (did = H5Dcreate( loc_id, dset_name, H5T_NATIVE_CHAR, sid, H5P_DEFAULT )) < 0 ) - goto out; - - /* Write the dataset only if there is data to write */ - - if ( data ) - { - if ( H5Dwrite( did, H5T_NATIVE_CHAR, H5S_ALL, H5S_ALL, H5P_DEFAULT, data ) < 0 ) - goto out; - } - - /* End access to the dataset and release resources used by it. */ - if ( H5Dclose( did ) < 0 ) - return -1; - - /* Terminate access to the data space. */ - if ( H5Sclose( sid ) < 0 ) - return -1; - - return 0; - -out: - H5Dclose( did ); - H5Sclose( sid ); - return -1; + return(H5LT_make_dataset_numerical(loc_id, dset_name, rank, dims, H5T_NATIVE_CHAR, data)); } @@ -199,39 +190,7 @@ herr_t H5LTmake_dataset_short( hid_t loc_id, const hsize_t *dims, const short *data ) { - - hid_t did, sid; - - /* Create the data space for the dataset. */ - if ( (sid = H5Screate_simple( rank, dims, NULL )) < 0 ) - return -1; - - /* Create the dataset. */ - if ( (did = H5Dcreate( loc_id, dset_name, H5T_NATIVE_SHORT, sid, H5P_DEFAULT )) < 0 ) - goto out; - - /* Write the dataset only if there is data to write */ - - if ( data ) - { - if ( H5Dwrite( did, H5T_NATIVE_SHORT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data ) < 0 ) - goto out; - } - - /* End access to the dataset and release resources used by it. */ - if ( H5Dclose( did ) < 0 ) - return -1; - - /* Terminate access to the data space. */ - if ( H5Sclose( sid ) < 0 ) - return -1; - - return 0; - -out: - H5Dclose( did ); - H5Sclose( sid ); - return -1; + return(H5LT_make_dataset_numerical(loc_id, dset_name, rank, dims, H5T_NATIVE_SHORT, data)); } /*------------------------------------------------------------------------- @@ -260,39 +219,7 @@ herr_t H5LTmake_dataset_int( hid_t loc_id, const hsize_t *dims, const int *data ) { - - hid_t did, sid; - - /* Create the data space for the dataset. */ - if ( (sid = H5Screate_simple( rank, dims, NULL )) < 0 ) - return -1; - - /* Create the dataset. */ - if ( (did = H5Dcreate( loc_id, dset_name, H5T_NATIVE_INT, sid, H5P_DEFAULT )) < 0 ) - goto out; - - /* Write the dataset only if there is data to write */ - - if ( data ) - { - if ( H5Dwrite( did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data ) < 0 ) - goto out; - } - - /* End access to the dataset and release resources used by it. */ - if ( H5Dclose( did ) < 0 ) - return -1; - - /* Terminate access to the data space. */ - if ( H5Sclose( sid ) < 0 ) - return -1; - - return 0; - -out: - H5Dclose( did ); - H5Sclose( sid ); - return -1; + return(H5LT_make_dataset_numerical(loc_id, dset_name, rank, dims, H5T_NATIVE_INT, data)); } @@ -323,39 +250,7 @@ herr_t H5LTmake_dataset_long( hid_t loc_id, const hsize_t *dims, const long *data ) { - - hid_t did, sid; - - /* Create the data space for the dataset. */ - if ( (sid = H5Screate_simple( rank, dims, NULL )) < 0 ) - return -1; - - /* Create the dataset. */ - if ( (did = H5Dcreate( loc_id, dset_name, H5T_NATIVE_LONG, sid, H5P_DEFAULT )) < 0 ) - goto out; - - /* Write the dataset only if there is data to write */ - - if ( data ) - { - if ( H5Dwrite( did, H5T_NATIVE_LONG, H5S_ALL, H5S_ALL, H5P_DEFAULT, data ) < 0 ) - goto out; - } - - /* End access to the dataset and release resources used by it. */ - if ( H5Dclose( did ) < 0 ) - return -1; - - /* Terminate access to the data space. */ - if ( H5Sclose( sid ) < 0 ) - return -1; - - return 0; - -out: - H5Dclose( did ); - H5Sclose( sid ); - return -1; + return(H5LT_make_dataset_numerical(loc_id, dset_name, rank, dims, H5T_NATIVE_LONG, data)); } /*------------------------------------------------------------------------- @@ -384,39 +279,7 @@ herr_t H5LTmake_dataset_float( hid_t loc_id, const hsize_t *dims, const float *data ) { - - hid_t did, sid; - - /* Create the data space for the dataset. */ - if ( (sid = H5Screate_simple( rank, dims, NULL )) < 0 ) - return -1; - - /* Create the dataset. */ - if ( (did = H5Dcreate( loc_id, dset_name, H5T_NATIVE_FLOAT, sid, H5P_DEFAULT )) < 0 ) - goto out; - - /* Write the dataset only if there is data to write */ - - if ( data ) - { - if ( H5Dwrite( did, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data ) < 0 ) - goto out; - } - - /* End access to the dataset and release resources used by it. */ - if ( H5Dclose( did ) < 0 ) - return -1; - - /* Terminate access to the data space. */ - if ( H5Sclose( sid ) < 0 ) - return -1; - - return 0; - -out: - H5Dclose( did ); - H5Sclose( sid ); - return -1; + return(H5LT_make_dataset_numerical(loc_id, dset_name, rank, dims, H5T_NATIVE_FLOAT, data)); } @@ -447,39 +310,7 @@ herr_t H5LTmake_dataset_double( hid_t loc_id, const hsize_t *dims, const double *data ) { - - hid_t did, sid; - - /* Create the data space for the dataset. */ - if ( (sid = H5Screate_simple( rank, dims, NULL )) < 0 ) - return -1; - - /* Create the dataset. */ - if ( (did = H5Dcreate( loc_id, dset_name, H5T_NATIVE_DOUBLE, sid, H5P_DEFAULT )) < 0 ) - goto out; - - /* Write the dataset only if there is data to write */ - - if ( data ) - { - if ( H5Dwrite( did, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, data ) < 0 ) - goto out; - } - - /* End access to the dataset and release resources used by it. */ - if ( H5Dclose( did ) < 0 ) - return -1; - - /* Terminate access to the data space. */ - if ( H5Sclose( sid ) < 0 ) - return -1; - - return 0; - -out: - H5Dclose( did ); - H5Sclose( sid ); - return -1; + return(H5LT_make_dataset_numerical(loc_id, dset_name, rank, dims, H5T_NATIVE_DOUBLE, data)); } @@ -507,55 +338,53 @@ herr_t H5LTmake_dataset_string(hid_t loc_id, const char *dset_name, const char *buf ) { + hid_t did = -1; + hid_t sid = -1; + hid_t tid = -1; + size_t size; - hid_t did=-1; - hid_t sid=-1; - hid_t tid; - size_t size; - - /* create a string data type */ - if ( (tid = H5Tcopy( H5T_C_S1 )) < 0 ) - goto out; - - size = strlen(buf) + 1; /* extra null term */ + /* create a string data type */ + if((tid = H5Tcopy(H5T_C_S1)) < 0 ) + goto out; - if ( H5Tset_size(tid,size) < 0 ) - goto out; + size = strlen(buf) + 1; /* extra null term */ - if ( H5Tset_strpad(tid,H5T_STR_NULLTERM ) < 0 ) - goto out; + if(H5Tset_size(tid, size) < 0) + goto out; - /* Create the data space for the dataset. */ - if ( (sid = H5Screate( H5S_SCALAR )) < 0 ) - goto out; + if(H5Tset_strpad(tid, H5T_STR_NULLTERM) < 0) + goto out; - /* Create the dataset. */ - if ( (did = H5Dcreate(loc_id,dset_name,tid,sid,H5P_DEFAULT)) < 0 ) - goto out; + /* Create the data space for the dataset. */ + if((sid = H5Screate(H5S_SCALAR)) < 0) + goto out; - /* Write the dataset only if there is data to write */ + /* Create the dataset. */ + if((did = H5Dcreate2(loc_id, dset_name, tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + goto out; - if (buf) - { - if ( H5Dwrite(did,tid,H5S_ALL,H5S_ALL,H5P_DEFAULT,buf) < 0 ) - goto out; - } + /* Write the dataset only if there is data to write */ + if(buf) + if(H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + goto out; - /* close*/ - if ( H5Dclose(did) < 0 ) - return -1; - if ( H5Sclose(sid) < 0 ) - return -1; - if ( H5Tclose(tid) < 0 ) - goto out; + /* close*/ + if(H5Dclose(did) < 0) + return -1; + if(H5Sclose(sid) < 0) + return -1; + if(H5Tclose(tid) < 0) + goto out; - return 0; + return 0; out: - H5Dclose(did); - H5Tclose(tid); - H5Sclose(sid); - return -1; + H5E_BEGIN_TRY { + H5Dclose(did); + H5Tclose(tid); + H5Sclose(sid); + } H5E_END_TRY; + return -1; } @@ -574,7 +403,7 @@ out: */ static herr_t -H5LT_read_dataset(hid_t loc_id, const char *dset_name, hid_t tid, void *data) +H5LT_read_dataset_numerical(hid_t loc_id, const char *dset_name, hid_t tid, void *data) { hid_t did; @@ -616,7 +445,7 @@ herr_t H5LTread_dataset(hid_t loc_id, hid_t tid, void *data) { - return(H5LT_read_dataset(loc_id, dset_name, tid, data)); + return(H5LT_read_dataset_numerical(loc_id, dset_name, tid, data)); } @@ -638,7 +467,7 @@ herr_t H5LTread_dataset_char( hid_t loc_id, const char *dset_name, char *data ) { - return(H5LTread_dataset(loc_id, dset_name, H5T_NATIVE_CHAR, data)); + return(H5LT_read_dataset_numerical(loc_id, dset_name, H5T_NATIVE_CHAR, data)); } /*------------------------------------------------------------------------- @@ -659,7 +488,7 @@ herr_t H5LTread_dataset_short( hid_t loc_id, const char *dset_name, short *data ) { - return(H5LTread_dataset(loc_id, dset_name, H5T_NATIVE_SHORT, data)); + return(H5LT_read_dataset_numerical(loc_id, dset_name, H5T_NATIVE_SHORT, data)); } /*------------------------------------------------------------------------- @@ -680,7 +509,7 @@ herr_t H5LTread_dataset_int( hid_t loc_id, const char *dset_name, int *data ) { - return(H5LTread_dataset(loc_id, dset_name, H5T_NATIVE_INT, data)); + return(H5LT_read_dataset_numerical(loc_id, dset_name, H5T_NATIVE_INT, data)); } /*------------------------------------------------------------------------- @@ -701,7 +530,7 @@ herr_t H5LTread_dataset_long( hid_t loc_id, const char *dset_name, long *data ) { - return(H5LTread_dataset(loc_id, dset_name, H5T_NATIVE_LONG, data)); + return(H5LT_read_dataset_numerical(loc_id, dset_name, H5T_NATIVE_LONG, data)); } /*------------------------------------------------------------------------- @@ -722,7 +551,7 @@ herr_t H5LTread_dataset_float( hid_t loc_id, const char *dset_name, float *data ) { - return(H5LTread_dataset(loc_id, dset_name, H5T_NATIVE_FLOAT, data)); + return(H5LT_read_dataset_numerical(loc_id, dset_name, H5T_NATIVE_FLOAT, data)); } @@ -744,7 +573,7 @@ herr_t H5LTread_dataset_double( hid_t loc_id, const char *dset_name, double *data ) { - return(H5LTread_dataset(loc_id, dset_name, H5T_NATIVE_DOUBLE, data)); + return(H5LT_read_dataset_numerical(loc_id, dset_name, H5T_NATIVE_DOUBLE, data)); } diff --git a/hl/src/H5PT.c b/hl/src/H5PT.c index aedc7b5..f337360 100644 --- a/hl/src/H5PT.c +++ b/hl/src/H5PT.c @@ -83,8 +83,8 @@ hid_t H5PTcreate_fl ( hid_t loc_id, hid_t ret_value; /* Register the packet table ID type if this is the first table created */ - if( H5PT_ptable_id_type < 0) - if((H5PT_ptable_id_type = H5Iregister_type((size_t)H5PT_HASH_TABLE_SIZE, 0, (H5I_free_t)free)) <0) + if(H5PT_ptable_id_type < 0) + if((H5PT_ptable_id_type = H5Iregister_type((size_t)H5PT_HASH_TABLE_SIZE, 0, (H5I_free_t)free)) < 0) goto out; /* Get memory for the table identifier */ @@ -94,35 +94,33 @@ hid_t H5PTcreate_fl ( hid_t loc_id, dims[0] = 0; dims_chunk[0] = chunk_size; maxdims[0] = H5S_UNLIMITED; - if ( (space_id = H5Screate_simple( 1, dims, maxdims )) < 0 ) + if((space_id = H5Screate_simple(1, dims, maxdims)) < 0) goto out; /* Modify dataset creation properties to enable chunking */ - plist_id = H5Pcreate (H5P_DATASET_CREATE); - if ( H5Pset_chunk ( plist_id, 1, dims_chunk ) < 0 ) + plist_id = H5Pcreate(H5P_DATASET_CREATE); + if(H5Pset_chunk(plist_id, 1, dims_chunk) < 0) goto out; if(compression >= 0 && compression <= 9) - { - if( H5Pset_deflate(plist_id, (unsigned)compression) < 0) + if(H5Pset_deflate(plist_id, (unsigned)compression) < 0) goto out; - } /* Create the dataset. */ - if ( (dset_id=H5Dcreate( loc_id, dset_name, dtype_id, space_id, plist_id))<0 ) + if((dset_id = H5Dcreate2(loc_id, dset_name, dtype_id, space_id, H5P_DEFAULT, plist_id, H5P_DEFAULT)) < 0) goto out; /* Terminate access to the data space. */ - if ( H5Sclose( space_id ) < 0 ) + if(H5Sclose(space_id) < 0) goto out; /* End access to the property list */ - if ( H5Pclose( plist_id ) < 0 ) + if(H5Pclose(plist_id) < 0) goto out; /* Create the table identifier */ table->dset_id = dset_id; - if((table->type_id = H5Tcopy(dtype_id)) <0) + if((table->type_id = H5Tcopy(dtype_id)) < 0) goto out; H5PT_create_index(table); @@ -131,7 +129,7 @@ hid_t H5PTcreate_fl ( hid_t loc_id, /* Get an ID for this table */ ret_value = H5Iregister(H5PT_ptable_id_type, table); - if (ret_value != H5I_INVALID_HID) + if(ret_value != H5I_INVALID_HID) H5PT_ptable_count++; else H5PT_close(table); @@ -180,14 +178,14 @@ hid_t H5PTcreate_vl ( hid_t loc_id, /* Create a variable length type that uses single bytes as its base type */ vltype = H5Tvlen_create(H5T_NATIVE_UCHAR); - if (vltype < 0) + if(vltype < 0) goto out; - if((ret_value=H5PTcreate_fl(loc_id, dset_name, vltype, chunk_size, 0)) <0) + if((ret_value=H5PTcreate_fl(loc_id, dset_name, vltype, chunk_size, 0)) < 0) goto out; /* close the vltype */ - if (H5Tclose(vltype) < 0) + if(H5Tclose(vltype) < 0) goto out; return ret_value; @@ -229,7 +227,7 @@ hid_t H5PTopen( hid_t loc_id, /* Register the packet table ID type if this is the first table created */ if( H5PT_ptable_id_type < 0) - if((H5PT_ptable_id_type = H5Iregister_type((size_t)H5PT_HASH_TABLE_SIZE, 0, (H5I_free_t)free))<0) + if((H5PT_ptable_id_type = H5Iregister_type((size_t)H5PT_HASH_TABLE_SIZE, 0, (H5I_free_t)free)) < 0) goto out; table = (htbl_t *)malloc(sizeof(htbl_t)); @@ -237,35 +235,35 @@ hid_t H5PTopen( hid_t loc_id, /* Open the dataset */ if((table->dset_id = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) goto out; - if (table->dset_id < 0) + if(table->dset_id < 0) goto out; /* Get the dataset's disk datatype */ - if ((type_id = H5Dget_type(table->dset_id)) < 0) + if((type_id = H5Dget_type(table->dset_id)) < 0) goto out; /* Get the table's native datatype */ - if ((table->type_id = H5Tget_native_type(type_id, H5T_DIR_ASCEND)) < 0) + if((table->type_id = H5Tget_native_type(type_id, H5T_DIR_ASCEND)) < 0) goto out; - if (H5Tclose(type_id) < 0) + if(H5Tclose(type_id) < 0) goto out; /* Initialize the current record pointer */ - if((H5PT_create_index(table)) <0) + if((H5PT_create_index(table)) < 0) goto out; /* Get number of records in table */ - if((space_id=H5Dget_space(table->dset_id)) <0) + if((space_id=H5Dget_space(table->dset_id)) < 0) goto out; - if ( H5Sget_simple_extent_dims( space_id, dims, NULL) < 0 ) + if( H5Sget_simple_extent_dims( space_id, dims, NULL) < 0) goto out; table->size = dims[0]; /* Get an ID for this table */ ret_value = H5Iregister(H5PT_ptable_id_type, table); - if (ret_value != H5I_INVALID_HID) + if(ret_value != H5I_INVALID_HID) H5PT_ptable_count++; else H5PT_close(table); @@ -311,11 +309,11 @@ herr_t H5PT_close( htbl_t* table) goto out; /* Close the dataset */ - if (H5Dclose(table->dset_id) < 0) + if(H5Dclose(table->dset_id) < 0) goto out; /* Close the memory datatype */ - if (H5Tclose(table->type_id) < 0) + if(H5Tclose(table->type_id) < 0) goto out; free(table); @@ -370,7 +368,7 @@ herr_t H5PTclose( hid_t table_id ) /* Remove the packet table type ID if no more packet */ /* tables are open */ - if (H5PT_ptable_count == 0) + if(H5PT_ptable_count == 0) { H5Idestroy_type(H5PT_ptable_id_type); H5PT_ptable_id_type = H5I_UNINIT; @@ -419,11 +417,11 @@ herr_t H5PTappend( hid_t table_id, goto out; /* If we are asked to write 0 records, just do nothing */ - if (nrecords == 0) + if(nrecords == 0) return 0; if((H5TB_common_append_records(table->dset_id, table->type_id, - nrecords, table->size, data)) <0) + nrecords, table->size, data)) < 0) goto out; /* Update table size */ @@ -473,7 +471,7 @@ herr_t H5PTget_next( hid_t table_id, goto out; /* If nrecords == 0, do nothing */ - if (nrecords == 0) + if(nrecords == 0) return 0; if((H5TB_common_read_records(table->dset_id, table->type_id, @@ -516,11 +514,11 @@ herr_t H5PTread_packets( hid_t table_id, /* find the table struct from its ID */ table = (htbl_t *) H5Iobject_verify(table_id, H5PT_ptable_id_type); - if (table == NULL) + if(table == NULL) goto out; /* If nrecords == 0, do nothing */ - if (nrecords == 0) + if(nrecords == 0) return 0; if( H5TB_common_read_records(table->dset_id, table->type_id, @@ -799,7 +797,7 @@ herr_t H5PTfree_vlen_readbuff( hid_t table_id, if((table = (htbl_t *) H5Iobject_verify(table_id, H5PT_ptable_id_type)) == NULL) goto out; - if ((space_id = H5Screate_simple(1, &bufflen, NULL)) < 0) + if((space_id = H5Screate_simple(1, &bufflen, NULL)) < 0) goto out; /* Free the memory. If this succeeds, ret_value should be 0. */ diff --git a/hl/src/H5TB.c b/hl/src/H5TB.c index 9f4b161..2471466 100644 --- a/hl/src/H5TB.c +++ b/hl/src/H5TB.c @@ -117,50 +117,44 @@ herr_t H5TBmake_table( const char *table_title, return -1; /* Modify dataset creation properties, i.e. enable chunking */ - plist_id = H5Pcreate (H5P_DATASET_CREATE); - if(H5Pset_chunk ( plist_id, 1, dims_chunk ) < 0) + plist_id = H5Pcreate(H5P_DATASET_CREATE); + if(H5Pset_chunk(plist_id, 1, dims_chunk) < 0) return -1; /* Set the fill value using a struct as the data type. */ - if(fill_data ) - { - if(H5Pset_fill_value( plist_id, mem_type_id, fill_data ) < 0) + if(fill_data) + if(H5Pset_fill_value(plist_id, mem_type_id, fill_data) < 0) return -1; - } /* Dataset creation property list is modified to use GZIP compression with the compression effort set to 6. Note that compression can be used only when dataset is chunked. */ - if(compress ) - { - if(H5Pset_deflate( plist_id, 6) < 0) + if(compress) + if(H5Pset_deflate(plist_id, 6) < 0) return -1; - } /* Create the dataset. */ - if((did = H5Dcreate( loc_id, dset_name, mem_type_id, sid, plist_id )) < 0) + if((did = H5Dcreate2(loc_id, dset_name, mem_type_id, sid, H5P_DEFAULT, plist_id, H5P_DEFAULT)) < 0) goto out; /* Only write if there is something to write */ - if(data ) - { + if(data) /* Write data to the dataset. */ if(H5Dwrite( did, mem_type_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, data ) < 0) goto out; - } /* Terminate access to the data space. */ - if(H5Sclose( sid ) < 0) + if(H5Sclose(sid) < 0) goto out; /* End access to the dataset */ - if(H5Dclose( did ) < 0) + if(H5Dclose(did) < 0) goto out; /* End access to the property list */ - if(H5Pclose( plist_id ) < 0) + if(H5Pclose(plist_id) < 0) goto out; /*------------------------------------------------------------------------- @@ -1915,11 +1909,11 @@ herr_t H5TBcombine_tables( hid_t loc_id1, */ /* Clone the property list */ - if(( plist_id3 = H5Pcopy( plist_id1 )) < 0) + if((plist_id3 = H5Pcopy(plist_id1)) < 0) goto out; /* Clone the type id */ - if(( type_id3 = H5Tcopy( type_id1 )) < 0) + if((type_id3 = H5Tcopy(type_id1)) < 0) goto out; /*------------------------------------------------------------------------- @@ -1930,18 +1924,18 @@ herr_t H5TBcombine_tables( hid_t loc_id1, dims[0] = 0; /* Create a simple data space with unlimited size */ - if((space_id3 = H5Screate_simple( 1, dims, maxdims )) < 0) + if((space_id3 = H5Screate_simple(1, dims, maxdims)) < 0) return -1; /* Create the dataset */ - if((dataset_id3 = H5Dcreate( loc_id1, dset_name3, type_id3, space_id3, plist_id3 )) < 0) + if((dataset_id3 = H5Dcreate2(loc_id1, dset_name3, type_id3, space_id3, H5P_DEFAULT, plist_id3, H5P_DEFAULT)) < 0) goto out; /*------------------------------------------------------------------------- * Attach the conforming table attributes *------------------------------------------------------------------------- */ - if(H5TB_attach_attributes( "Merge table", loc_id1, dset_name3, nfields, type_id3 ) < 0) + if(H5TB_attach_attributes("Merge table", loc_id1, dset_name3, nfields, type_id3) < 0) goto out; /*------------------------------------------------------------------------- @@ -1949,13 +1943,13 @@ herr_t H5TBcombine_tables( hid_t loc_id1, *------------------------------------------------------------------------- */ - type_size = H5Tget_size( type_id3 ); + type_size = H5Tget_size(type_id3); /* alloc fill value attribute buffer */ - tmp_fill_buf = (unsigned char *)malloc((size_t) type_size ); + tmp_fill_buf = (unsigned char *)malloc(type_size); /* Get the fill value attributes */ - has_fill=H5TBAget_fill( loc_id1, dset_name1, dataset_id1, tmp_fill_buf ); + has_fill = H5TBAget_fill(loc_id1, dset_name1, dataset_id1, tmp_fill_buf); /*------------------------------------------------------------------------- * Attach the fill attributes from previous table @@ -2312,14 +2306,11 @@ herr_t H5TBinsert_field( hid_t loc_id, /* Insert the old fields, counting with the new one */ for ( i = 0; i < nfields + 1; i++) { - idx = i; if(inserted ) idx = i - 1; - if(i == position ) - { - + if(i == position ) { /* Get the new member size */ new_member_size = H5Tget_size( field_type ); @@ -2332,7 +2323,6 @@ herr_t H5TBinsert_field( hid_t loc_id, inserted = 1; continue; - } /* Get the member name */ @@ -2356,8 +2346,6 @@ herr_t H5TBinsert_field( hid_t loc_id, /* Close the member type */ if(H5Tclose( member_type_id ) < 0) goto out; - - } /* i */ /*------------------------------------------------------------------------- @@ -2366,20 +2354,20 @@ herr_t H5TBinsert_field( hid_t loc_id, */ /* Retrieve the size of chunk */ - if(H5Pget_chunk( plist_id1, 1, dims_chunk ) < 0) + if(H5Pget_chunk(plist_id1, 1, dims_chunk) < 0) goto out; /* Create a new simple data space with unlimited size, using the dimension */ - if(( space_id2 = H5Screate_simple( 1, dims, maxdims )) < 0) + if((space_id2 = H5Screate_simple( 1, dims, maxdims)) < 0) return -1; /* Modify dataset creation properties, i.e. enable chunking */ - plist_id2 = H5Pcreate (H5P_DATASET_CREATE); - if(H5Pset_chunk ( plist_id2, 1, dims_chunk ) < 0) + plist_id2 = H5Pcreate(H5P_DATASET_CREATE); + if(H5Pset_chunk(plist_id2, 1, dims_chunk) < 0) return -1; /* Create the dataset. */ - if(( dataset_id2 = H5Dcreate( loc_id, "new", type_id2, space_id2, plist_id2 )) < 0) + if((dataset_id2 = H5Dcreate2(loc_id, "new", type_id2, space_id2, H5P_DEFAULT, plist_id2, H5P_DEFAULT)) < 0) goto out; @@ -2388,20 +2376,20 @@ herr_t H5TBinsert_field( hid_t loc_id, *------------------------------------------------------------------------- */ - tmp_buf = (unsigned char *)calloc((size_t) nrecords, (size_t)total_size ); + tmp_buf = (unsigned char *)calloc((size_t)nrecords, (size_t)total_size); /* Define a hyperslab in the dataset of the size of the records */ offset[0] = 0; count[0] = nrecords; - if(H5Sselect_hyperslab( space_id1, H5S_SELECT_SET, offset, NULL, count, NULL) < 0) + if(H5Sselect_hyperslab(space_id1, H5S_SELECT_SET, offset, NULL, count, NULL) < 0) goto out; /* Create a memory dataspace handle */ mem_size[0] = count[0]; - if((mem_space_id1 = H5Screate_simple( 1, mem_size, NULL )) < 0) + if((mem_space_id1 = H5Screate_simple(1, mem_size, NULL)) < 0) goto out; - if(H5Dread( dataset_id1, type_id1, mem_space_id1, H5S_ALL, H5P_DEFAULT, tmp_buf ) < 0) + if(H5Dread(dataset_id1, type_id1, mem_space_id1, H5S_ALL, H5P_DEFAULT, tmp_buf) < 0) goto out; @@ -2837,12 +2825,11 @@ herr_t H5TBdelete_field( hid_t loc_id, curr_offset += member_size; - free( member_name ); + free(member_name); /* Close the member type */ - if(H5Tclose( member_type_id ) < 0) + if(H5Tclose(member_type_id) < 0) goto out; - } /* i */ /*------------------------------------------------------------------------- @@ -2851,48 +2838,45 @@ herr_t H5TBdelete_field( hid_t loc_id, */ /* Retrieve the size of chunk */ - if(H5Pget_chunk( plist_id1, 1, dims_chunk ) < 0) + if(H5Pget_chunk(plist_id1, 1, dims_chunk) < 0) goto out; /* Create a new simple data space with unlimited size, using the dimension */ - if(( space_id2 = H5Screate_simple( 1, dims, maxdims )) < 0) + if((space_id2 = H5Screate_simple(1, dims, maxdims)) < 0) return -1; /* Modify dataset creation properties, i.e. enable chunking */ - plist_id2 = H5Pcreate (H5P_DATASET_CREATE); - if(H5Pset_chunk ( plist_id2, 1, dims_chunk ) < 0) + plist_id2 = H5Pcreate(H5P_DATASET_CREATE); + if(H5Pset_chunk(plist_id2, 1, dims_chunk) < 0) return -1; /* Create the dataset. */ - if(( dataset_id2 = H5Dcreate( loc_id, "new", type_id2, space_id2, plist_id2 )) < 0) + if((dataset_id2 = H5Dcreate2(loc_id, "new", type_id2, space_id2, H5P_DEFAULT, plist_id2, H5P_DEFAULT)) < 0) goto out; /*------------------------------------------------------------------------- * We have to read field by field of the old dataset and save it into the new one *------------------------------------------------------------------------- */ - for ( i = 0; i < nfields; i++) - { - + for ( i = 0; i < nfields; i++) { /* Get the member name */ - member_name = H5Tget_member_name( type_id1,(unsigned) i ); + member_name = H5Tget_member_name(type_id1, (unsigned)i); /* Skip the field to delete */ - if(H5TB_find_field( member_name, field_name ) > 0 ) - { - free( member_name ); + if(H5TB_find_field(member_name, field_name) > 0) { + free(member_name); continue; } /* Get the member type */ - if(( member_type_id = H5Tget_member_type( type_id1, (unsigned)i )) < 0) + if((member_type_id = H5Tget_member_type(type_id1, (unsigned)i)) < 0) goto out; /* Get the member size */ - member_size = H5Tget_size( member_type_id ); + member_size = H5Tget_size(member_type_id); /* Create a read id */ - if(( read_type_id = H5Tcreate( H5T_COMPOUND, member_size )) < 0) + if((read_type_id = H5Tcreate(H5T_COMPOUND, member_size)) < 0) goto out; /* Insert it into the new type */ |