diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2010-03-25 03:51:41 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2010-03-25 03:51:41 (GMT) |
commit | 42efc1c2b591e4cd45ec6cb3bdf32044343118d2 (patch) | |
tree | 0ab542871c32246199479e8933ff26286aaf629a /test/tvlstr.c | |
parent | 3360c3af0c100ac4d3a2fe2865f34661da862ec5 (diff) | |
download | hdf5-42efc1c2b591e4cd45ec6cb3bdf32044343118d2.zip hdf5-42efc1c2b591e4cd45ec6cb3bdf32044343118d2.tar.gz hdf5-42efc1c2b591e4cd45ec6cb3bdf32044343118d2.tar.bz2 |
[svn-r18451] Description:
Bring r18172:18446 from trunk to revise_chunks branch.
Tested on:
FreeBSD/32 6.3 (duty) in debug mode
FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode
Linux/32 2.6 (jam) w/PGI compilers, w/default API=1.8.x,
w/C++ & FORTRAN, w/threadsafe, in debug mode
Linux/64-amd64 2.6 (amani) w/Intel compilers, w/default API=1.6.x,
w/C++ & FORTRAN, in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, in production mode
Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in debug mode
Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in production mode
Diffstat (limited to 'test/tvlstr.c')
-rw-r--r-- | test/tvlstr.c | 82 |
1 files changed, 59 insertions, 23 deletions
diff --git a/test/tvlstr.c b/test/tvlstr.c index a411b86..fbced5f 100644 --- a/test/tvlstr.c +++ b/test/tvlstr.c @@ -573,7 +573,7 @@ static void test_write_vl_string_attribute(void) hid_t file, root, dataspace, att; hid_t type; herr_t ret; - char *string_att_check; + char *string_att_check = NULL; /* Open the file */ file = H5Fopen(DATAFILE, H5F_ACC_RDWR, H5P_DEFAULT); @@ -599,13 +599,21 @@ static void test_write_vl_string_attribute(void) ret = H5Awrite(att, type, &string_att); CHECK(ret, FAIL, "H5Awrite"); - ret = H5Aread(att, type, &string_att_check); - CHECK(ret, FAIL, "H5Aread"); + /* Allocate memory for read buffer */ + if(string_att) + string_att_check = (char*)HDmalloc((strlen(string_att) + 1) * sizeof(char)); + CHECK(string_att_check, NULL, "HDmalloc"); - if(HDstrcmp(string_att_check,string_att)!=0) - TestErrPrintf("VL string attributes don't match!, string_att=%s, string_att_check=%s\n",string_att,string_att_check); + if(string_att_check) { + ret = H5Aread(att, type, &string_att_check); + CHECK(ret, FAIL, "H5Aread"); - HDfree(string_att_check); + if(HDstrcmp(string_att_check,string_att)!=0) + TestErrPrintf("VL string attributes don't match!, string_att=%s, string_att_check=%s\n",string_att,string_att_check); + + HDfree(string_att_check); + string_att_check = NULL; + } ret = H5Aclose(att); CHECK(ret, FAIL, "HAclose"); @@ -620,13 +628,23 @@ static void test_write_vl_string_attribute(void) ret = H5Awrite(att, type, &string_att_write); CHECK(ret, FAIL, "H5Awrite"); - ret = H5Aread(att, type, &string_att_check); - CHECK(ret, FAIL, "H5Aread"); + /* Allocate memory for read buffer */ + if(string_att_write) + string_att_check = (char*)HDmalloc((strlen(string_att_write) + 1) * sizeof(char)); + CHECK(string_att_check, NULL, "HDmalloc"); + + if(string_att_check) { + ret = H5Aread(att, type, &string_att_check); + CHECK(ret, FAIL, "H5Aread"); - if(HDstrcmp(string_att_check,string_att_write)!=0) - TestErrPrintf("VL string attributes don't match!, string_att_write=%s, string_att_check=%s\n",string_att_write,string_att_check); + if(HDstrcmp(string_att_check,string_att_write)!=0) + TestErrPrintf("VL string attributes don't match!, string_att_write=%s, string_att_check=%s\n",string_att_write,string_att_check); + + /* The attribute string written is freed below, in the + *test_read_vl_string_attribute() test */ + HDfree(string_att_check); + } - HDfree(string_att_check); /* The attribute string written is freed below, in the test_read_vl_string_attribute() test */ /* HDfree(string_att_write); */ @@ -659,7 +677,7 @@ static void test_read_vl_string_attribute(void) hid_t file, root, att; hid_t type; herr_t ret; - char *string_att_check; + char *string_att_check = NULL; /* Open file */ file = H5Fopen(DATAFILE, H5F_ACC_RDONLY, H5P_DEFAULT); @@ -679,13 +697,21 @@ static void test_read_vl_string_attribute(void) att = H5Aopen(root, "test_scalar", H5P_DEFAULT); CHECK(att, FAIL, "H5Aopen"); - ret = H5Aread(att, type, &string_att_check); - CHECK(ret, FAIL, "H5Aread"); + /* Allocate memory for read buffer */ + if(string_att) + string_att_check = (char*)HDmalloc((strlen(string_att) + 1) * sizeof(char)); + CHECK(string_att_check, NULL, "HDmalloc"); - if(HDstrcmp(string_att_check,string_att)!=0) - TestErrPrintf("VL string attributes don't match!, string_att=%s, string_att_check=%s\n",string_att,string_att_check); + if(string_att_check) { + ret = H5Aread(att, type, &string_att_check); + CHECK(ret, FAIL, "H5Aread"); - HDfree(string_att_check); + if(HDstrcmp(string_att_check,string_att)!=0) + TestErrPrintf("VL string attributes don't match!, string_att=%s, string_att_check=%s\n",string_att,string_att_check); + + HDfree(string_att_check); + string_att_check = NULL; + } ret = H5Aclose(att); CHECK(ret, FAIL, "HAclose"); @@ -694,14 +720,24 @@ static void test_read_vl_string_attribute(void) att = H5Aopen(root, "test_scalar_large", H5P_DEFAULT); CHECK(att, FAIL, "H5Aopen"); - ret = H5Aread(att, type, &string_att_check); - CHECK(ret, FAIL, "H5Aread"); + /* Allocate memory for read buffer */ + if(string_att_write) + string_att_check = (char*)HDmalloc((strlen(string_att_write) + 1) * sizeof(char)); + CHECK(string_att_check, NULL, "HDmalloc"); + + if(string_att_check) { + ret = H5Aread(att, type, &string_att_check); + CHECK(ret, FAIL, "H5Aread"); - if(HDstrcmp(string_att_check,string_att_write)!=0) - TestErrPrintf("VL string attributes don't match!, string_att_write=%s, string_att_check=%s\n",string_att_write,string_att_check); + if(HDstrcmp(string_att_check,string_att_write)!=0) + TestErrPrintf("VL string attributes don't match!, string_att_write=%s, string_att_check=%s\n",string_att_write,string_att_check); + + HDfree(string_att_check); + } - HDfree(string_att_check); - HDfree(string_att_write); /* Free string allocated in test_write_vl_string_attribute */ + /* Free string allocated in test_write_vl_string_attribute */ + if(string_att_write) + HDfree(string_att_write); ret = H5Aclose(att); CHECK(ret, FAIL, "HAclose"); |