summaryrefslogtreecommitdiffstats
path: root/tools/h5dump/h5dump.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2009-08-10 17:08:27 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2009-08-10 17:08:27 (GMT)
commit9d27b9765ad7d5ec04762895752bc77b8ac1ec3d (patch)
treea0e442dbb7b27f963a9ba8240db1605ca6de6615 /tools/h5dump/h5dump.c
parent61c693615a1f4f90f7654f639170eed2f3c85262 (diff)
downloadhdf5-9d27b9765ad7d5ec04762895752bc77b8ac1ec3d.zip
hdf5-9d27b9765ad7d5ec04762895752bc77b8ac1ec3d.tar.gz
hdf5-9d27b9765ad7d5ec04762895752bc77b8ac1ec3d.tar.bz2
[svn-r17313] Description:
Bring back various minor code cleanups from the file free space branch Tested on: FreeBSD/32 6.3 (duty) in debug mode FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode Linux/32 2.6 (kagiso) w/PGI compilers, w/C++ & FORTRAN, w/threadsafe, in debug mode Linux/64-amd64 2.6 (smirom) w/Intel compilers w/default API=1.6.x, w/C++ & FORTRAN, in production mode Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN, w/szip filter, in production mode Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN, in production mode Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in production mode Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in production mode Mac OS X/32 10.5.8 (amazon) in debug mode Mac OS X/32 10.5.8 (amazon) w/C++ & FORTRAN, w/threadsafe, in production mode
Diffstat (limited to 'tools/h5dump/h5dump.c')
-rw-r--r--tools/h5dump/h5dump.c26
1 files changed, 12 insertions, 14 deletions
diff --git a/tools/h5dump/h5dump.c b/tools/h5dump/h5dump.c
index a8b6832..beacdbb 100644
--- a/tools/h5dump/h5dump.c
+++ b/tools/h5dump/h5dump.c
@@ -731,10 +731,11 @@ table_list_add(hid_t oid, unsigned long file_no)
{
size_t idx; /* Index of table to use */
find_objs_t info;
- void *tmp_ptr;
/* Allocate space if necessary */
if(table_list.nused == table_list.nalloc) {
+ void *tmp_ptr;
+
table_list.nalloc = MAX(1, table_list.nalloc * 2);
if(NULL == (tmp_ptr = HDrealloc(table_list.tables, table_list.nalloc * sizeof(table_list.tables[0]))))
return -1;
@@ -1441,7 +1442,7 @@ dump_selected_attr(hid_t loc_id, const char *name)
int j;
j = (int)HDstrlen(name) - 1;
- obj_name = HDmalloc((size_t)j + 2);
+ obj_name = (char *)HDmalloc((size_t)j + 2);
/* find the last / */
while(name[j] != '/' && j >= 0)
@@ -1533,7 +1534,7 @@ dump_all_cb(hid_t group, const char *name, const H5L_info_t *linfo, void UNUSED
herr_t ret = SUCCEED;
/* Build the object's path name */
- obj_path = HDmalloc(HDstrlen(prefix) + HDstrlen(name) + 2);
+ obj_path = (char *)HDmalloc(HDstrlen(prefix) + HDstrlen(name) + 2);
HDassert(obj_path);
HDstrcpy(obj_path, prefix);
HDstrcat(obj_path, "/");
@@ -1692,7 +1693,7 @@ dump_all_cb(hid_t group, const char *name, const H5L_info_t *linfo, void UNUSED
switch(linfo->type) {
case H5L_TYPE_SOFT:
indentation(indent);
- targbuf = HDmalloc(linfo->u.val_size);
+ targbuf = (char *)HDmalloc(linfo->u.val_size);
HDassert(targbuf);
if(!doxml) {
@@ -1722,7 +1723,7 @@ dump_all_cb(hid_t group, const char *name, const H5L_info_t *linfo, void UNUSED
char *t_link_path;
int res;
- t_link_path = HDmalloc(HDstrlen(prefix) + linfo->u.val_size + 1);
+ t_link_path = (char *)HDmalloc(HDstrlen(prefix) + linfo->u.val_size + 1);
if(targbuf[0] == '/')
HDstrcpy(t_link_path, targbuf);
else {
@@ -1785,7 +1786,7 @@ dump_all_cb(hid_t group, const char *name, const H5L_info_t *linfo, void UNUSED
break;
case H5L_TYPE_EXTERNAL:
- targbuf = HDmalloc(linfo->u.val_size);
+ targbuf = (char *)HDmalloc(linfo->u.val_size);
HDassert(targbuf);
indentation(indent);
@@ -2057,7 +2058,7 @@ dump_group(hid_t gid, const char *name)
}
- tmp = HDmalloc(HDstrlen(prefix) + HDstrlen(name) + 2);
+ tmp = (char *)HDmalloc(HDstrlen(prefix) + HDstrlen(name) + 2);
HDstrcpy(tmp, prefix);
indentation(indent);
begin_obj(dump_header_format->groupbegin, name, dump_header_format->groupblockbegin);
@@ -2714,9 +2715,7 @@ dump_dcpl(hid_t dcpl_id,hid_t type_id, hid_t obj_id)
hsize_t dims[H5S_MAX_RANK];
int ndims = H5Sget_simple_extent_dims( sid, dims, NULL);
hsize_t nelmts = 1;
- hsize_t size;
double ratio = 0;
- hssize_t a, b;
int ok = 0;
/* only print the compression ratio for these filters */
@@ -2739,19 +2738,18 @@ dump_dcpl(hid_t dcpl_id,hid_t type_id, hid_t obj_id)
if (ndims && ok )
{
+ hsize_t uncomp_size;
for (i = 0; i < ndims; i++)
{
nelmts *= dims[i];
}
- size = nelmts * datum_size;
-
- a = size; b = storage_size;
+ uncomp_size = nelmts * datum_size;
/* compression ratio = uncompressed size / compressed size */
- if (b!=0)
- ratio = (double) a / (double) b;
+ if (storage_size != 0)
+ ratio = (double) uncomp_size / (double) storage_size;
HDfprintf(stdout, "SIZE %Hu (%.3f:1 COMPRESSION)\n ", storage_size, ratio);