diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2010-08-25 20:27:07 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2010-08-25 20:27:07 (GMT) |
commit | 52839cdf69f02c99a4a25f65ec9c21f698ad81a6 (patch) | |
tree | f0a55b3d0865894532eb34d3927a43e38cfd58d2 | |
parent | d9e64dce7fefd8ff746a2ea9aa03607b67f62e12 (diff) | |
download | hdf5-52839cdf69f02c99a4a25f65ec9c21f698ad81a6.zip hdf5-52839cdf69f02c99a4a25f65ec9c21f698ad81a6.tar.gz hdf5-52839cdf69f02c99a4a25f65ec9c21f698ad81a6.tar.bz2 |
[svn-r19297] Description:
Whack a few more memory errors exposed by valgrind.
Make the debugging dump output a little bit prettier.
Tested on:
Mac OS X/32 10.6.4 (amazon) w/debug
(h5committest forthcoming)
-rw-r--r-- | src/H5Dfill.c | 6 | ||||
-rw-r--r-- | src/H5dbg.c | 9 | ||||
-rw-r--r-- | src/H5private.h | 4 | ||||
-rw-r--r-- | test/dtransform.c | 2 | ||||
-rw-r--r-- | test/enum.c | 2 | ||||
-rw-r--r-- | test/freespace.c | 63 | ||||
-rw-r--r-- | test/set_extent.c | 4 |
7 files changed, 77 insertions, 13 deletions
diff --git a/src/H5Dfill.c b/src/H5Dfill.c index 4474661..1999dda 100644 --- a/src/H5Dfill.c +++ b/src/H5Dfill.c @@ -609,12 +609,14 @@ H5D_fill_refill_vl(H5D_fill_buf_info_t *fb_info, size_t nelmts, hid_t dxpl_id) done: if(buf) { /* Free dynamically allocated VL elements in fill buffer */ - if(fb_info->fill->type) + if(fb_info->fill->type) { if(H5T_vlen_reclaim_elmt(buf, fb_info->fill->type, dxpl_id) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "can't reclaim vlen element") - else + } /* end if */ + else { if(H5T_vlen_reclaim_elmt(buf, fb_info->mem_type, dxpl_id) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "can't reclaim vlen element") + } /* end else */ /* Free temporary fill buffer */ if(fb_info->fill_free_func) diff --git a/src/H5dbg.c b/src/H5dbg.c index 196ed5b..632ac08 100644 --- a/src/H5dbg.c +++ b/src/H5dbg.c @@ -78,8 +78,8 @@ *------------------------------------------------------------------------- */ herr_t -H5_buffer_dump(FILE *stream, int indent, uint8_t *buf, - uint8_t *marker, size_t buf_offset, size_t buf_size) +H5_buffer_dump(FILE *stream, int indent, const uint8_t *buf, + const uint8_t *marker, size_t buf_offset, size_t buf_size) { size_t u, v; /* Local index variable */ @@ -102,7 +102,7 @@ H5_buffer_dump(FILE *stream, int indent, uint8_t *buf, for(u = 0; u < buf_size; u += 16) { uint8_t c; - HDfprintf(stream, "%*s %8d: ", indent, "", u); + HDfprintf(stream, "%*s %8d: ", indent, "", u + buf_offset); /* Print the hex values */ for(v = 0; v < 16; v++) { @@ -119,6 +119,7 @@ H5_buffer_dump(FILE *stream, int indent, uint8_t *buf, if(7 == v) HDfputc(' ', stream); } /* end for */ + HDfputc(' ', stream); /* Print the character values */ for(v = 0; v < 16; v++) { @@ -133,6 +134,8 @@ H5_buffer_dump(FILE *stream, int indent, uint8_t *buf, HDfputc('.', stream); } /* end else */ } /* end if */ + if(7 == v) + HDfputc(' ', stream); } /* end for */ HDfputc('\n', stream); diff --git a/src/H5private.h b/src/H5private.h index e8e87e2..3875fb3 100644 --- a/src/H5private.h +++ b/src/H5private.h @@ -2342,8 +2342,8 @@ H5_DLL uint32_t H5_hash_string(const char *str); H5_DLL herr_t H5_build_extpath(const char *, char ** /*out*/ ); /* Functions for debugging */ -H5_DLL herr_t H5_buffer_dump(FILE *stream, int indent, uint8_t *buf, - uint8_t *marker, size_t buf_offset, size_t buf_size); +H5_DLL herr_t H5_buffer_dump(FILE *stream, int indent, const uint8_t *buf, + const uint8_t *marker, size_t buf_offset, size_t buf_size); #endif /* _H5private_H */ diff --git a/test/dtransform.c b/test/dtransform.c index 9af1dfb..5d5cefe 100644 --- a/test/dtransform.c +++ b/test/dtransform.c @@ -616,7 +616,7 @@ test_getset(const hid_t dxpl_id_c_to_f) TESTING("H5Pget_data_transform, after resetting transform property") - if(NULL == (ptrgetTest = (char *)HDcalloc(1, HDstrlen(simple) + 1))) + if(NULL == (ptrgetTest = (char *)HDcalloc((size_t)1, HDstrlen(simple) + 1))) TEST_ERROR if(H5Pget_data_transform(dxpl_id_c_to_f, ptrgetTest, HDstrlen(simple) + 1) < 0) TEST_ERROR diff --git a/test/enum.c b/test/enum.c index 4599a7c..c627af1 100644 --- a/test/enum.c +++ b/test/enum.c @@ -71,7 +71,7 @@ test_named(hid_t file) if(H5Tclose(type) < 0) FAIL_STACK_ERROR /* A smaller type */ - if((type = H5Tcreate(H5T_ENUM, 1)) < 0) FAIL_STACK_ERROR + if((type = H5Tcreate(H5T_ENUM, (size_t)1)) < 0) FAIL_STACK_ERROR if(H5Tenum_insert(type, "RED", CPTR(val8, E1_RED )) < 0) FAIL_STACK_ERROR if(H5Tenum_insert(type, "GREEN", CPTR(val8, E1_GREEN)) < 0) FAIL_STACK_ERROR if(H5Tenum_insert(type, "BLUE", CPTR(val8, E1_BLUE )) < 0) FAIL_STACK_ERROR diff --git a/test/freespace.c b/test/freespace.c index 0f6514c..b4a774f 100644 --- a/test/freespace.c +++ b/test/freespace.c @@ -593,7 +593,7 @@ test_fs_sect_add(hid_t fapl) H5FS_create_t cparam; /* creation parameters */ frspace_state_t state; /* State of free space*/ - TEST_free_section_t *sect_node; + TEST_free_section_t *sect_node = NULL; unsigned init_flags=0; h5_stat_size_t file_size=0, tmp_file_size=0, fr_meta_size=0; unsigned can_shrink=FALSE; @@ -858,6 +858,11 @@ test_fs_sect_add(hid_t fapl) if(H5FS_sect_remove(f, H5P_DATASET_XFER_DEFAULT, frsp, (H5FS_section_info_t *)sect_node) < 0) FAIL_STACK_ERROR + /* Free the section node(s) */ + if(TEST_sect_free((H5FS_section_info_t *)sect_node) < 0) + TEST_ERROR + sect_node = NULL; + /* Close the free space manager */ if(H5FS_close(f, H5P_DATASET_XFER_DEFAULT, frsp) < 0) FAIL_STACK_ERROR @@ -878,6 +883,8 @@ test_fs_sect_add(hid_t fapl) error: H5E_BEGIN_TRY { + if(sect_node) + TEST_sect_free((H5FS_section_info_t *)sect_node); if(frsp) H5FS_close(f, H5P_DATASET_XFER_DEFAULT, frsp); H5Fclose(file); @@ -918,7 +925,7 @@ test_fs_sect_find(hid_t fapl) H5FS_create_t cparam; /* creation parameters */ frspace_state_t state; /* State of free space*/ - TEST_free_section_t *sect_node1, *sect_node2, *sect_node3, *sect_node4; + TEST_free_section_t *sect_node1 = NULL, *sect_node2, *sect_node3 = NULL, *sect_node4 = NULL; TEST_free_section_t *node; htri_t node_found = FALSE; unsigned init_flags=0; @@ -1077,6 +1084,17 @@ test_fs_sect_find(hid_t fapl) if(H5FS_sect_remove(f, H5P_DATASET_XFER_DEFAULT, frsp, (H5FS_section_info_t *)sect_node4) < 0) FAIL_STACK_ERROR + /* Free the section node(s) */ + if(TEST_sect_free((H5FS_section_info_t *)sect_node1) < 0) + TEST_ERROR + sect_node1 = NULL; + if(TEST_sect_free((H5FS_section_info_t *)sect_node3) < 0) + TEST_ERROR + sect_node3 = NULL; + if(TEST_sect_free((H5FS_section_info_t *)sect_node4) < 0) + TEST_ERROR + sect_node4 = NULL; + /* Close the free space manager */ if(H5FS_close(f, H5P_DATASET_XFER_DEFAULT, frsp) < 0) FAIL_STACK_ERROR @@ -1145,11 +1163,17 @@ test_fs_sect_find(hid_t fapl) if(TEST_sect_free((H5FS_section_info_t *)node) < 0) TEST_ERROR + node = NULL; /* remove sections A */ if(H5FS_sect_remove(f, H5P_DATASET_XFER_DEFAULT, frsp, (H5FS_section_info_t *)sect_node1) < 0) FAIL_STACK_ERROR + /* Free the section node(s) */ + if(TEST_sect_free((H5FS_section_info_t *)sect_node1) < 0) + TEST_ERROR + sect_node1 = NULL; + /* Close the free space manager */ if(H5FS_close(f, H5P_DATASET_XFER_DEFAULT, frsp) < 0) FAIL_STACK_ERROR @@ -1199,6 +1223,11 @@ test_fs_sect_find(hid_t fapl) if(H5FS_sect_remove(f, H5P_DATASET_XFER_DEFAULT, frsp, (H5FS_section_info_t *)sect_node1) < 0) FAIL_STACK_ERROR + /* Free the section node(s) */ + if(TEST_sect_free((H5FS_section_info_t *)sect_node1) < 0) + TEST_ERROR + sect_node1 = NULL; + /* Close the free space manager */ if(H5FS_close(f, H5P_DATASET_XFER_DEFAULT, frsp) < 0) FAIL_STACK_ERROR @@ -1219,6 +1248,12 @@ test_fs_sect_find(hid_t fapl) error: H5E_BEGIN_TRY { + if(sect_node1) + TEST_sect_free((H5FS_section_info_t *)sect_node1); + if(sect_node3) + TEST_sect_free((H5FS_section_info_t *)sect_node3); + if(sect_node4) + TEST_sect_free((H5FS_section_info_t *)sect_node4); if(frsp) H5FS_close(f, H5P_DATASET_XFER_DEFAULT, frsp); H5Fclose(file); @@ -1484,6 +1519,12 @@ test_fs_sect_merge(hid_t fapl) if(H5FS_sect_remove(f, H5P_DATASET_XFER_DEFAULT, frsp, (H5FS_section_info_t *)sect_node2) < 0) FAIL_STACK_ERROR + /* Free the section node(s) */ + if(TEST_sect_free((H5FS_section_info_t *)sect_node1) < 0) + TEST_ERROR + if(TEST_sect_free((H5FS_section_info_t *)sect_node2) < 0) + TEST_ERROR + /* Close the free space manager */ if(H5FS_close(f, H5P_DATASET_XFER_DEFAULT, frsp) < 0) FAIL_STACK_ERROR @@ -1672,6 +1713,10 @@ test_fs_sect_merge(hid_t fapl) error: H5E_BEGIN_TRY { + if(sect_node1) + TEST_sect_free((H5FS_section_info_t *)sect_node1); + if(sect_node2) + TEST_sect_free((H5FS_section_info_t *)sect_node2); if(frsp) H5FS_close(f, H5P_DATASET_XFER_DEFAULT, frsp); H5Fclose(file); @@ -2152,6 +2197,11 @@ test_fs_sect_change_class(hid_t fapl) if(H5FS_sect_remove(f, H5P_DATASET_XFER_DEFAULT, frsp, (H5FS_section_info_t *)sect_node2) < 0) FAIL_STACK_ERROR + /* Free the section node(s) */ + if(TEST_sect_free((H5FS_section_info_t *)sect_node2) < 0) + TEST_ERROR + sect_node2 = NULL; + /* Close the free space manager */ if(H5FS_close(f, H5P_DATASET_XFER_DEFAULT, frsp) < 0) FAIL_STACK_ERROR @@ -2269,6 +2319,11 @@ test_fs_sect_change_class(hid_t fapl) if(H5FS_sect_remove(f, H5P_DATASET_XFER_DEFAULT, frsp, (H5FS_section_info_t *)sect_node1) < 0) FAIL_STACK_ERROR + /* Free the section node(s) */ + if(TEST_sect_free((H5FS_section_info_t *)sect_node1) < 0) + TEST_ERROR + sect_node1 = NULL; + /* Close the free space manager */ if(H5FS_close(f, H5P_DATASET_XFER_DEFAULT, frsp) < 0) FAIL_STACK_ERROR @@ -2289,6 +2344,10 @@ test_fs_sect_change_class(hid_t fapl) error: H5E_BEGIN_TRY { + if(sect_node1) + TEST_sect_free((H5FS_section_info_t *)sect_node1); + if(sect_node2) + TEST_sect_free((H5FS_section_info_t *)sect_node2); if(frsp) H5FS_close(f, H5P_DATASET_XFER_DEFAULT, frsp); H5Fclose(file); diff --git a/test/set_extent.c b/test/set_extent.c index 0582c41..191962d 100644 --- a/test/set_extent.c +++ b/test/set_extent.c @@ -130,10 +130,10 @@ int main( void ) if((fapl2 = H5Pcopy(fapl)) < 0) TEST_ERROR /* Set chunk cache so only part of the chunks can be cached on fapl */ - if(H5Pset_cache(fapl, 0, 8, 256 * sizeof(int), 0.75) < 0) TEST_ERROR + if(H5Pset_cache(fapl, 0, (size_t)8, 256 * sizeof(int), 0.75) < 0) TEST_ERROR /* Disable chunk caching on fapl2 */ - if(H5Pset_cache(fapl2, 0, 0, 0, 0.) < 0) TEST_ERROR + if(H5Pset_cache(fapl2, 0, (size_t)0, (size_t)0, 0.) < 0) TEST_ERROR /* Set the "use the latest version of the format" bounds for creating objects in the file */ if(H5Pset_libver_bounds(fapl2, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) TEST_ERROR |