ret = H5Awrite(att, type, &string_att);
CHECK(ret, FAIL, "H5Awrite");
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);
HDfree(string_att_check);
H5free_memory(string_att_check);
CHECK(ret, FAIL, "HAclose");
/* Test creating a "large" sized string attribute */
att = H5Acreate2(root, "test_scalar_large", type, dataspace, H5P_DEFAULT, H5P_DEFAULT);
CHECK(att, FAIL, "H5Acreate2");
string_att_write = (char*)HDcalloc((size_t)8192, sizeof(char));
ret = H5Awrite(att, type, &string_att_write);
CHECK(ret, FAIL, "H5Awrite");
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);
HDfree(string_att_check);
H5free_memory(string_att_check);
/* The attribute string written is freed below, in the test_read_vl_string_attribute() test */
/* HDfree(string_att_write); */
CHECK(ret, FAIL, "HAclose");
CHECK(ret, FAIL, "H5Gclose");
/* Test reading "normal" sized string attribute */
att = H5Aopen(root, "test_scalar", H5P_DEFAULT);
CHECK(att, FAIL, "H5Aopen");
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);
HDfree(string_att_check);
H5free_memory(string_att_check);
CHECK(ret, FAIL, "HAclose");
/* Test reading "large" sized string attribute */
att = H5Aopen(root, "test_scalar_large", H5P_DEFAULT);
CHECK(att, FAIL, "H5Aopen");
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);
HDfree(string_att_check);
H5free_memory(string_att_check);
/* Free string allocated in test_write_vl_string_attribute */
HDfree(string_att_write);
CHECK(ret, FAIL, "HAclose");
ret = H5Dread(dset, type, space, space, H5P_DEFAULT, &data_read);
CHECK(ret, FAIL, "H5Dread");
CHECK(ret, FAIL, "H5Dclose");
if(HDstrcmp(data, data_read))
TestErrPrintf("Expected %s for dataset %s but read %s\n", data, name, data_read);
ret = H5Dvlen_reclaim(type, space, H5P_DEFAULT, &data_read);
CHECK(ret, FAIL, "H5Dvlen_reclaim");
/****************************************************************
** test_vl_rewrite(): Test basic VL string code.
** Tests I/O on VL strings when lots of objects in the file
** have been linked/unlinked.
****************************************************************/
static void test_vl_rewrite(void)