diff options
author | Raymond Lu <songyulu@hdfgroup.org> | 2009-04-24 21:13:20 (GMT) |
---|---|---|
committer | Raymond Lu <songyulu@hdfgroup.org> | 2009-04-24 21:13:20 (GMT) |
commit | cdcd4a73058091fa1c5035bd81d1b057f1ab19d4 (patch) | |
tree | d63b77c9b836bc370f302d44ce8f1864aada003d | |
parent | 8dd1e72365158f9b82c624fa7fdd6340849111ab (diff) | |
download | hdf5-cdcd4a73058091fa1c5035bd81d1b057f1ab19d4.zip hdf5-cdcd4a73058091fa1c5035bd81d1b057f1ab19d4.tar.gz hdf5-cdcd4a73058091fa1c5035bd81d1b057f1ab19d4.tar.bz2 |
[svn-r16859] I fixed some memory leak of H5LTdtype_to_text in the HL library. I fixed some test
verification, too.
Tested on jam - simple change.
-rw-r--r-- | hl/src/H5LT.c | 12 | ||||
-rw-r--r-- | hl/test/test_lite.c | 19 |
2 files changed, 22 insertions, 9 deletions
diff --git a/hl/src/H5LT.c b/hl/src/H5LT.c index 7c073d6..e797d14 100644 --- a/hl/src/H5LT.c +++ b/hl/src/H5LT.c @@ -1792,6 +1792,7 @@ herr_t H5LTdtype_to_text(hid_t dtype, char *str, H5LT_lang_t lang_type, size_t * if((ret = H5LT_dtype_to_text(dtype, &text_str, lang_type, &str_len, 1)) < 0) goto out; *len = strlen(text_str) + 1; + free(text_str); } else if(len && str) { if((ret = H5LT_dtype_to_text(dtype, &str, lang_type, len, 0)) < 0) goto out; @@ -2076,6 +2077,9 @@ next: break; } case H5T_OPAQUE: + { + char *tag; + /* Print lead-in */ sprintf(*dt_str, "H5T_OPAQUE {\n"); indent += COL; @@ -2085,7 +2089,12 @@ next: strcat(*dt_str, tmp_str); indentation(indent + COL, *dt_str); - sprintf(tmp_str, "OPQ_TAG \"%s\";\n", H5Tget_tag(dtype)); + tag = H5Tget_tag(dtype); + if(tag) { + sprintf(tmp_str, "OPQ_TAG \"%s\";\n", tag); + free(tag); + } else + sprintf(tmp_str, "OPQ_TAG \"\";\n"); strcat(*dt_str, tmp_str); /* Print closing */ @@ -2094,6 +2103,7 @@ next: strcat(*dt_str, "}"); break; + } case H5T_ENUM: { hid_t super; diff --git a/hl/test/test_lite.c b/hl/test/test_lite.c index 6de2e31..8c9fb30 100644 --- a/hl/test/test_lite.c +++ b/hl/test/test_lite.c @@ -1317,10 +1317,12 @@ static int test_enums(void) dt_str = (char*)calloc(str_len, sizeof(char)); if(H5LTdtype_to_text(dtype, dt_str, H5LT_DDL, &str_len)<0) goto out; - /*if(strcmp(dt_str, "H5T_ENUM {\n H5T_STD_I32LE;\n \"RED\" 5;\n \"GREEN\" 6;\n \"BLUE\" 7;\n \"WHITE\" 8;\n }")) { - printf("dt=\n%s\n", dt_str); - goto out; - }*/ + if(strcmp(dt_str, "H5T_ENUM {\n H5T_STD_I32LE;\n \"RED\" 5;\n \"GREEN\" 6;\n \"BLUE\" 7;\n \"WHITE\" 8;\n }")) { + + printf("dt=\n%s\n", dt_str); + goto out; + } + free(dt_str); if(H5Tclose(dtype)<0) @@ -1427,10 +1429,11 @@ static int test_arrays(void) dt_str = (char*)calloc(str_len, sizeof(char)); if(H5LTdtype_to_text(dtype, dt_str, H5LT_DDL, &str_len)<0) goto out; - /*if(strcmp(dt_str, "H5T_ARRAY { [5][7][13] H5T_ARRAY { [17][19] H5T_COMPOUND { H5T_STD_I8BE \"arr_compound_1\"; H5T_STD_I32BE \"arr_compound_2\"; } } }")) { - printf("dt=\n%s\n", dt_str); - goto out; - }*/ + if(strcmp(dt_str, "H5T_ARRAY {\n [5][7][13] H5T_ARRAY {\n [17][19] H5T_COMPOUND {\n H5T_STD_I8BE \"arr_compound_1\" : 0;\n H5T_STD_I32BE \"arr_compound_2\" : 1;\n }\n }\n }")) { + printf("dt=\n%s\n", dt_str); + goto out; + } + free(dt_str); if(H5Tclose(dtype)<0) |