diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2000-11-28 20:11:06 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2000-11-28 20:11:06 (GMT) |
commit | 5f049dc50c9c66d2fafbcb5ccb34dbcf85668150 (patch) | |
tree | fb9ee67f1d6700be2c3530c4bf27a3e60258f7ce /tools | |
parent | ac955b2ccc313066ff83d6e1a9a8bbff596b963c (diff) | |
download | hdf5-5f049dc50c9c66d2fafbcb5ccb34dbcf85668150.zip hdf5-5f049dc50c9c66d2fafbcb5ccb34dbcf85668150.tar.gz hdf5-5f049dc50c9c66d2fafbcb5ccb34dbcf85668150.tar.bz2 |
[svn-r3014] Purpose:
Bug fix.
Description:
Data dumping routines weren't correctly handling scalar dataspaces when
dumping them. Under some circumstances, it would get into infinite loops.
Solution:
Small patches to avoid problems when the number of dimensions is zero.
Platforms tested:
FreeBSD 4.2 (hawkwind)
Diffstat (limited to 'tools')
-rw-r--r-- | tools/h5tools.c | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/tools/h5tools.c b/tools/h5tools.c index a7754fe..41532b6 100644 --- a/tools/h5tools.c +++ b/tools/h5tools.c @@ -1497,13 +1497,17 @@ h5dump_simple_dset(FILE *stream, const h5dump_t *info, hid_t dset, return -1; /* Assume entire data space to be printed */ - for (i = 0; i < (hsize_t)ctx.ndims; i++) - ctx.p_min_idx[i] = 0; + if(ctx.ndims>0) + for (i = 0; i < (hsize_t)ctx.ndims; i++) + ctx.p_min_idx[i] = 0; H5Sget_simple_extent_dims(f_space, total_size, NULL); - for (i = 0, p_nelmts = 1; i < (hsize_t)ctx.ndims; i++) - p_nelmts *= total_size[i]; + if(ctx.ndims>0) + for (i = 0, p_nelmts = 1; i < (hsize_t)ctx.ndims; i++) + p_nelmts *= total_size[i]; + else + p_nelmts = 1; if (p_nelmts == 0) return 0; /*nothing to print*/ @@ -1516,11 +1520,14 @@ h5dump_simple_dset(FILE *stream, const h5dump_t *info, hid_t dset, */ p_type_nbytes = H5Tget_size(p_type); - for (i = ctx.ndims, sm_nbytes = p_type_nbytes; i > 0; --i) { - sm_size[i - 1] = MIN(total_size[i - 1], H5DUMP_BUFSIZE / sm_nbytes); - sm_nbytes *= sm_size[i - 1]; - assert(sm_nbytes > 0); - } + if(ctx.ndims>0) + for (i = ctx.ndims, sm_nbytes = p_type_nbytes; i > 0; --i) { + sm_size[i - 1] = MIN(total_size[i - 1], H5DUMP_BUFSIZE / sm_nbytes); + sm_nbytes *= sm_size[i - 1]; + assert(sm_nbytes > 0); + } + else + sm_nbytes = p_type_nbytes; sm_buf = malloc(sm_nbytes); sm_nelmts = sm_nbytes / p_type_nbytes; |