summaryrefslogtreecommitdiffstats
path: root/test/tvlstr.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2010-08-23 20:56:42 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2010-08-23 20:56:42 (GMT)
commit0f95a9d5ab47a609f50c7554e46f60b625df07e8 (patch)
tree2137e981bc20f6e3f40176487780a9032936d228 /test/tvlstr.c
parent65996f2921391c653d05ad92b7b62ba27f3c2bdd (diff)
downloadhdf5-0f95a9d5ab47a609f50c7554e46f60b625df07e8.zip
hdf5-0f95a9d5ab47a609f50c7554e46f60b625df07e8.tar.gz
hdf5-0f95a9d5ab47a609f50c7554e46f60b625df07e8.tar.bz2
[svn-r19278] Description:
More fixes to memory allocation, etc. exposed by valgrind. 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, w/threadsafe, in production mode Linux/PPC 2.6 (heiwa) w/C++ & FORTRAN, w/threadsafe, in debug mode Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN, in production mode Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in debug mode Mac OS X/32 10.6.4 (amazon) in debug mode Mac OS X/32 10.6.4 (amazon) w/C++ & FORTRAN, w/threadsafe, in production mode Mac OS X/32 10.6.4 (amazon) w/parallel, in debug mode
Diffstat (limited to 'test/tvlstr.c')
-rw-r--r--test/tvlstr.c75
1 files changed, 21 insertions, 54 deletions
diff --git a/test/tvlstr.c b/test/tvlstr.c
index fbced5f..87008aa 100644
--- a/test/tvlstr.c
+++ b/test/tvlstr.c
@@ -29,16 +29,9 @@
#define DATAFILE2 "tvlstr2.h5"
/* 1-D dataset with fixed dimensions */
-#define SPACE1_NAME "Space1"
#define SPACE1_RANK 1
#define SPACE1_DIM1 4
-/* 2-D dataset with fixed dimensions */
-#define SPACE2_NAME "Space2"
-#define SPACE2_RANK 2
-#define SPACE2_DIM1 10
-#define SPACE2_DIM2 10
-
#define VLSTR_TYPE "vl_string_type"
/* Definitions for the VL re-writing test */
@@ -599,21 +592,14 @@ static void test_write_vl_string_attribute(void)
ret = H5Awrite(att, type, &string_att);
CHECK(ret, FAIL, "H5Awrite");
- /* 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(string_att_check) {
- ret = H5Aread(att, type, &string_att_check);
- CHECK(ret, FAIL, "H5Aread");
+ ret = H5Aread(att, type, &string_att_check);
+ CHECK(ret, FAIL, "H5Aread");
- 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(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;
- }
+ HDfree(string_att_check);
+ string_att_check = NULL;
ret = H5Aclose(att);
CHECK(ret, FAIL, "HAclose");
@@ -628,22 +614,14 @@ static void test_write_vl_string_attribute(void)
ret = H5Awrite(att, type, &string_att_write);
CHECK(ret, FAIL, "H5Awrite");
- /* 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");
+ ret = H5Aread(att, type, &string_att_check);
+ CHECK(ret, FAIL, "H5Aread");
- 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);
+ string_att_check = NULL;
/* The attribute string written is freed below, in the test_read_vl_string_attribute() test */
/* HDfree(string_att_write); */
@@ -697,21 +675,14 @@ static void test_read_vl_string_attribute(void)
att = H5Aopen(root, "test_scalar", H5P_DEFAULT);
CHECK(att, FAIL, "H5Aopen");
- /* 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");
+ ret = H5Aread(att, type, &string_att_check);
+ CHECK(ret, FAIL, "H5Aread");
- if(string_att_check) {
- ret = H5Aread(att, type, &string_att_check);
- CHECK(ret, FAIL, "H5Aread");
+ 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(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;
- }
+ HDfree(string_att_check);
+ string_att_check = NULL;
ret = H5Aclose(att);
CHECK(ret, FAIL, "HAclose");
@@ -720,19 +691,15 @@ static void test_read_vl_string_attribute(void)
att = H5Aopen(root, "test_scalar_large", H5P_DEFAULT);
CHECK(att, FAIL, "H5Aopen");
- /* 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) {
+ if(string_att_write) {
ret = H5Aread(att, type, &string_att_check);
CHECK(ret, FAIL, "H5Aread");
- if(HDstrcmp(string_att_check,string_att_write)!=0)
+ 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);
+ string_att_check = NULL;
}
/* Free string allocated in test_write_vl_string_attribute */