diff options
Diffstat (limited to 'tools/lib')
-rw-r--r-- | tools/lib/h5tools.c | 52 |
1 files changed, 19 insertions, 33 deletions
diff --git a/tools/lib/h5tools.c b/tools/lib/h5tools.c index 66c0e64..0d9bc15 100644 --- a/tools/lib/h5tools.c +++ b/tools/lib/h5tools.c @@ -30,10 +30,6 @@ #include "h5tools_utils.h" #include "H5private.h" -#define SANITY_CHECK - -#define ALIGN(A,Z) ((((A) + (Z) - 1) / (Z)) * (Z)) - /* global variables */ hid_t H5tools_ERR_STACK_g = 0; hid_t H5tools_ERR_CLS_g = -1; @@ -1122,7 +1118,6 @@ render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem, hsize_t while(block_index > 0) { size_t bytes_in = 0; /* # of bytes to write */ size_t bytes_wrote = 0; /* # of bytes written */ - size_t item_size = size; /* size of items in bytes */ if(block_index > sizeof(size_t)) bytes_in = sizeof(size_t); @@ -1168,16 +1163,21 @@ render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem, hsize_t break; case H5T_COMPOUND: { - unsigned j; - hid_t memb; + int snmembs; unsigned nmembs; - size_t offset; - nmembs = H5Tget_nmembers(tid); + if((snmembs = H5Tget_nmembers(tid)) < 0) + H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Tget_nmembers of compound failed"); + nmembs = (unsigned)snmembs; for (block_index = 0; block_index < block_nelmts; block_index++) { + unsigned j; + mem = ((unsigned char*)_mem) + block_index * size; for (j = 0; j < nmembs; j++) { + hid_t memb; + size_t offset; + offset = H5Tget_member_offset(tid, j); memb = H5Tget_member_type(tid, j); @@ -1192,7 +1192,7 @@ render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem, hsize_t case H5T_ARRAY: { int k, ndims; - hsize_t i, dims[H5S_MAX_RANK], temp_nelmts, nelmts; + hsize_t dims[H5S_MAX_RANK], temp_nelmts, nelmts; hid_t memb; /* get the array's base datatype for each element */ @@ -1219,7 +1219,6 @@ render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem, hsize_t break; case H5T_VLEN: { - unsigned int i; hsize_t nelmts; hid_t memb; @@ -1305,10 +1304,9 @@ render_bin_output_region_data_blocks(hid_t region_id, FILE *stream, hsize_t *start = NULL; hsize_t *count = NULL; hsize_t numelem; - hsize_t numindex; hsize_t total_size[H5S_MAX_RANK]; int jndx; - int type_size; + size_t type_size; hid_t mem_space = -1; void *region_buf = NULL; int blkndx; @@ -1399,15 +1397,17 @@ render_bin_output_region_blocks(hid_t region_space, hid_t region_id, FILE *stream, hid_t container) { HERR_INIT(hbool_t, TRUE) - hssize_t nblocks; + hssize_t snblocks; + hsize_t nblocks; hsize_t alloc_size; - hsize_t *ptdata = NULL; + hsize_t *ptdata; int ndims; hid_t dtype; hid_t type_id; - if((nblocks = H5Sget_select_hyper_nblocks(region_space)) <= 0) + if((snblocks = H5Sget_select_hyper_nblocks(region_space)) <= 0) H5E_THROW(FALSE, H5E_tools_min_id_g, "H5Sget_select_hyper_nblocks failed"); + nblocks = (hsize_t)snblocks; /* Print block information */ if((ndims = H5Sget_simple_extent_ndims(region_space)) < 0) @@ -1463,13 +1463,12 @@ render_bin_output_region_blocks(hid_t region_space, hid_t region_id, * hssize_t npoints is the number of points in the region *------------------------------------------------------------------------- */ -int +static int render_bin_output_region_data_points(hid_t region_space, hid_t region_id, FILE *stream, hid_t container, - int ndims, hid_t type_id, hssize_t npoints, hsize_t *ptdata) + int ndims, hid_t type_id, hssize_t npoints) { hsize_t *dims1 = NULL; - int jndx; int type_size; hid_t mem_space = -1; void *region_buf = NULL; @@ -1525,8 +1524,6 @@ render_bin_output_region_points(hid_t region_space, hid_t region_id, { HERR_INIT(hbool_t, TRUE) hssize_t npoints; - hsize_t alloc_size; - hsize_t *ptdata; int ndims; hid_t dtype; hid_t type_id; @@ -1538,15 +1535,6 @@ render_bin_output_region_points(hid_t region_space, hid_t region_id, if((ndims = H5Sget_simple_extent_ndims(region_space)) < 0) H5E_THROW(FALSE, H5E_tools_min_id_g, "H5Sget_simple_extent_ndims failed"); - alloc_size = npoints * ndims * sizeof(ptdata[0]); - HDassert(alloc_size == (hsize_t) ((size_t) alloc_size)); /*check for overflow*/ - if(NULL == (ptdata = (hsize_t *)HDmalloc((size_t) alloc_size))) - HGOTO_ERROR(FALSE, H5E_tools_min_id_g, "Could not allocate buffer for ptdata"); - - H5_CHECK_OVERFLOW(npoints, hssize_t, hsize_t); - if(H5Sget_select_elem_pointlist(region_space, (hsize_t) 0, (hsize_t) npoints, ptdata) < 0) - HGOTO_ERROR(FALSE, H5E_tools_min_id_g, "H5Sget_select_elem_pointlist failed"); - if((dtype = H5Dget_type(region_id)) < 0) HGOTO_ERROR(FALSE, H5E_tools_min_id_g, "H5Dget_type failed"); @@ -1554,11 +1542,9 @@ render_bin_output_region_points(hid_t region_space, hid_t region_id, HGOTO_ERROR(FALSE, H5E_tools_min_id_g, "H5Tget_native_type failed"); render_bin_output_region_data_points(region_space, region_id, - stream, container, ndims, type_id, npoints, ptdata); + stream, container, ndims, type_id, npoints); done: - HDfree(ptdata); - if(H5Tclose(type_id) < 0) HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tclose failed"); |