diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2012-08-06 19:42:49 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2012-08-06 19:42:49 (GMT) |
commit | cd3f42096b9a957e37c9df48aa0d31d9ed4bc537 (patch) | |
tree | 86a1672d114762d3aea872e44104e65d1bc09254 /hl | |
parent | 434643dd4d14a841abdcc73ad7b3a0a8e06e4438 (diff) | |
download | hdf5-cd3f42096b9a957e37c9df48aa0d31d9ed4bc537.zip hdf5-cd3f42096b9a957e37c9df48aa0d31d9ed4bc537.tar.gz hdf5-cd3f42096b9a957e37c9df48aa0d31d9ed4bc537.tar.bz2 |
[svn-r22636] Description:
Bring r22599:22634 from trunk to revise_chunks branch
Tested on:
Mac OSX/64 10.7.4 (amazon) w/gcc 4.7.x, C++ & FORTRAN
(No need for h5committest yet on this branch)
Diffstat (limited to 'hl')
-rw-r--r-- | hl/c++/src/Makefile.in | 2 | ||||
-rw-r--r-- | hl/fortran/src/Makefile.in | 2 | ||||
-rw-r--r-- | hl/src/H5LT.c | 9 | ||||
-rw-r--r-- | hl/src/H5TB.c | 10 | ||||
-rw-r--r-- | hl/src/Makefile.in | 2 | ||||
-rw-r--r-- | hl/test/test_table.c | 117 |
6 files changed, 135 insertions, 7 deletions
diff --git a/hl/c++/src/Makefile.in b/hl/c++/src/Makefile.in index f22d1c8..b0492bf 100644 --- a/hl/c++/src/Makefile.in +++ b/hl/c++/src/Makefile.in @@ -421,7 +421,7 @@ CHECK_CLEANFILES = *.chkexe *.chklog *.clog # Add libtool shared library version numbers to the HDF5 library # See libtool versioning documentation online. LT_VERS_INTERFACE = 6 -LT_VERS_REVISION = 114 +LT_VERS_REVISION = 115 LT_VERS_AGE = 0 # Include src directory diff --git a/hl/fortran/src/Makefile.in b/hl/fortran/src/Makefile.in index aeea150..30d2cac 100644 --- a/hl/fortran/src/Makefile.in +++ b/hl/fortran/src/Makefile.in @@ -436,7 +436,7 @@ CHECK_CLEANFILES = *.chkexe *.chklog *.clog # Add libtool shared library version numbers to the HDF5 library # See libtool versioning documentation online. LT_VERS_INTERFACE = 6 -LT_VERS_REVISION = 114 +LT_VERS_REVISION = 115 LT_VERS_AGE = 0 INCLUDES = -I$(top_srcdir)/src -I$(top_srcdir)/hl/src -I$(top_builddir)/hl/src \ -I$(top_srcdir)/fortran/src -I$(top_builddir)/fortran/src diff --git a/hl/src/H5LT.c b/hl/src/H5LT.c index 678642f..eed2721 100644 --- a/hl/src/H5LT.c +++ b/hl/src/H5LT.c @@ -3024,8 +3024,11 @@ herr_t H5LTget_attribute_string( hid_t loc_id, return -1; /* Get the attribute */ - if ( H5LT_get_attribute_disk( obj_id, attr_name, data ) < 0 ) - return -1; + if ( H5LT_get_attribute_disk( obj_id, attr_name, data ) < 0 ) + { + H5Oclose(obj_id); + return -1; + } /* Close the object */ if(H5Oclose(obj_id) < 0) @@ -3458,6 +3461,8 @@ static herr_t H5LT_get_attribute_mem(hid_t loc_id, return 0; out: + if(obj_id > 0) + H5Oclose(obj_id); if(attr_id > 0) H5Aclose(attr_id); return -1; diff --git a/hl/src/H5TB.c b/hl/src/H5TB.c index 6edc244..8a77f13 100644 --- a/hl/src/H5TB.c +++ b/hl/src/H5TB.c @@ -1298,6 +1298,7 @@ herr_t H5TBdelete_record( hid_t loc_id, hid_t tid=-1; hid_t sid=-1; hid_t m_sid=-1; + hid_t mem_type_id=-1; hsize_t count[1]; hsize_t offset[1]; hsize_t mem_size[1]; @@ -1364,6 +1365,10 @@ herr_t H5TBdelete_record( hid_t loc_id, if ((sid = H5Dget_space( did )) < 0) goto out; + /* create the memory data type. */ + if ((mem_type_id=H5TB_create_type( loc_id, dset_name, src_size, src_offset, src_sizes, tid)) < 0) + goto out; + /* define a hyperslab in the dataset of the size of the records */ offset[0] = start; count[0] = read_nrecords; @@ -1375,12 +1380,14 @@ herr_t H5TBdelete_record( hid_t loc_id, if ((m_sid = H5Screate_simple( 1, mem_size, NULL )) < 0) goto out; - if (H5Dwrite( did, tid, m_sid, sid, H5P_DEFAULT, tmp_buf ) < 0) + if (H5Dwrite( did, mem_type_id, m_sid, sid, H5P_DEFAULT, tmp_buf ) < 0) goto out; /* close */ if (H5Sclose( m_sid ) < 0) goto out; + if (H5Tclose( mem_type_id ) < 0) + goto out; if (H5Sclose( sid ) < 0) goto out; if (H5Tclose( tid ) < 0) @@ -1416,6 +1423,7 @@ out: free( tmp_buf ); H5E_BEGIN_TRY { + H5Tclose(mem_type_id); H5Dclose(did); H5Tclose(tid); H5Sclose(sid); diff --git a/hl/src/Makefile.in b/hl/src/Makefile.in index 9b2bbdb..eaeac2e 100644 --- a/hl/src/Makefile.in +++ b/hl/src/Makefile.in @@ -420,7 +420,7 @@ CHECK_CLEANFILES = *.chkexe *.chklog *.clog # Add libtool shared library version numbers to the HDF5 library # See libtool versioning documentation online. LT_VERS_INTERFACE = 6 -LT_VERS_REVISION = 114 +LT_VERS_REVISION = 115 LT_VERS_AGE = 0 # This library is our main target. diff --git a/hl/test/test_table.c b/hl/test/test_table.c index e3e040e..cdae768 100644 --- a/hl/test/test_table.c +++ b/hl/test/test_table.c @@ -114,6 +114,27 @@ typedef struct particle3_t int lati; } particle3_t; +/*------------------------------------------------------------------------- + * a particle, used in the delete field test differing memory layout + *------------------------------------------------------------------------- + */ + +/* Push current alignment rule forcing 4-byte alignment boundary + * to the internal stack ... + */ +#pragma pack(push,4) + typedef struct particle4_t { + uint32_t state; + double posx; + double posy; + float atx[3]; + float aty[3]; + float rro[2]; + } particle4_t; +/* + * ... and restore original alignment rules from stack + */ +#pragma pack(pop) /*------------------------------------------------------------------------- @@ -350,6 +371,34 @@ static int test_table(hid_t fid, int do_write) sizeof( rbuf3[0].temperature), sizeof( rbuf3[0].lati)}; + /*------------------------------------------------------------------------- + * initialize table parameters + * size and the offsets of struct members in memory + * these are used for the delete field test with differing memory layout + *------------------------------------------------------------------------- + */ + + /* Calculate the size and the offsets of our struct members in memory */ + size_t tbl_size = sizeof(particle4_t); + size_t tbl_offset[NFIELDS+1] = { HOFFSET(particle4_t, state), + HOFFSET(particle4_t, posx), + HOFFSET(particle4_t, posy), + HOFFSET(particle4_t, atx), + HOFFSET(particle4_t, aty), + HOFFSET(particle4_t, rro) + }; + + /* Define an array of Particles */ + particle4_t p_data[NRECORDS] = { + {12112, 1.4, 2.5, {1,2,3},{4,5,6}, {99,100}}, + {12113, 1.4, 2.5, {1,2,3},{4,5,6}, {99,100}}, + {12114, 1.4, 2.5, {1,2,3},{4,5,6}, {99,100}}, + {12115, 1.4, 2.5, {1,2,3},{4,5,6}, {99,100}}, + {12116, 1.4, 2.5, {1,2,3},{4,5,6}, {99,100}}, + {12117, 1.4, 2.5, {1,2,3},{4,5,6}, {99,100}}, + {12118, 1.4, 2.5, {1,2,3},{4,5,6}, {99,100}}, + {12119, 1.4, 2.5, {1,2,3},{4,5,6}, {99,100}} + }; /*------------------------------------------------------------------------- * initialize table parameters @@ -376,10 +425,23 @@ static int test_table(hid_t fid, int do_write) sizeof( rbuf[0].temperature), sizeof( rbuf[0].lati) }; + + const char *field_names4[NFIELDS+1] = + { "F1", "F2", "F3", "F4", "F5", "F6"}; + hid_t field_type4[NFIELDS+1]; + particle4_t fill_data[1] = { {9999999, -9999999, 999999, {999,999,999},{999,999,999}, {999,999}} }; + + hsize_t nfields_out; + hsize_t nrecords_out; + hid_t arry3_32f; + hid_t arry2_32f; + hsize_t dims; + const char *field_names[NFIELDS] = - { "Name","Longitude","Pressure","Temperature","Latitude" }; + { "Name","Longitude","Pressure","Temperature","Latitude" }; hid_t field_type[NFIELDS]; hid_t string_type = H5Tcopy( H5T_C_S1 ); + H5Tset_size( string_type, 16 ); field_type[0] = string_type; field_type[1] = H5T_NATIVE_LONG; @@ -820,6 +882,59 @@ static int test_table(hid_t fid, int do_write) PASSED(); } + /*------------------------------------------------------------------------ + * Functions tested: + * + * H5TBdelete_record -- With differing memory layout from machine memory + * layout. HDFFV-8055 + * + *------------------------------------------------------------------------- + */ + if (do_write) + { + TESTING2("deleting records (differing memory layout)"); + + dims = 3; + arry3_32f = H5Tarray_create2(H5T_NATIVE_FLOAT, 1, &dims); + + dims = 2; + arry2_32f = H5Tarray_create2(H5T_NATIVE_FLOAT, 1, &dims); + + /* Initialize the field field_type */ + field_type4[0] = H5T_NATIVE_UINT32; + field_type4[1] = H5T_NATIVE_DOUBLE; + field_type4[2] = H5T_NATIVE_DOUBLE; + field_type4[3] = arry3_32f; + field_type4[4] = arry3_32f; + field_type4[5] = arry2_32f; + + /* Make the table */ + if (H5TBmake_table("Table Title",fid,"table",NFIELDS+1,(hsize_t)NRECORDS, + tbl_size, field_names4, tbl_offset, field_type4, + chunk_size, fill_data, compress, p_data)<0) + goto out; + /* Delete records */ + start = 3; + nrecords = 3; + if (H5TBdelete_record(fid, "table", start, nrecords)<0) + goto out;; + /* Get table info */ + if (H5TBget_table_info(fid,"table", &nfields_out, &nrecords_out)<0) + goto out; + /* check */ + if( (int)nfields_out != (int)NFIELDS+1) + goto out; + + if( (int)nrecords_out != (int)NRECORDS-3) + goto out; + + /* close type */ + H5Tclose(arry3_32f); + H5Tclose(arry2_32f); + + PASSED(); + } + /*------------------------------------------------------------------------- * * Functions tested: |