summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/h5dump/h5dump.c6
-rw-r--r--tools/h5dump/h5dumpgentest.c93
-rw-r--r--tools/h5repack/h5repacktst.c33
-rw-r--r--tools/lib/h5diff_dset.c26
-rw-r--r--tools/lib/h5tools.c55
5 files changed, 142 insertions, 71 deletions
diff --git a/tools/h5dump/h5dump.c b/tools/h5dump/h5dump.c
index 43b2813..a1f78b1 100644
--- a/tools/h5dump/h5dump.c
+++ b/tools/h5dump/h5dump.c
@@ -5734,7 +5734,6 @@ xml_dump_group(hid_t gid, const char *name)
char type_name[1024], *tmp = NULL;
char *par = NULL;
int isRoot = 0;
- char *ptrstr;
char *t_objname;
char *par_name;
unsigned crt_order_flags;
@@ -5787,6 +5786,7 @@ xml_dump_group(hid_t gid, const char *name)
indent += COL;
H5Oget_info(gid, &oinfo);
+
if(oinfo.rc > 1) {
obj_t *found_obj; /* Found object */
@@ -5804,6 +5804,8 @@ xml_dump_group(hid_t gid, const char *name)
char *parentxid = malloc(100);
if(found_obj->displayed) {
+ char *ptrstr = malloc(100);
+
/* already seen: enter a groupptr */
if(isRoot) {
/* probably can't happen! */
@@ -5824,7 +5826,6 @@ xml_dump_group(hid_t gid, const char *name)
}
indentation(indent + COL);
- ptrstr = malloc(100);
t_objname = xml_escape_the_name(found_obj->objname);/* point to the NDT by name */
par_name = xml_escape_the_name(par);
xml_name_to_XID(found_obj->objname, ptrstr, 100, 1);
@@ -5835,6 +5836,7 @@ xml_dump_group(hid_t gid, const char *name)
ptrstr, t_objname, parentxid, par_name);
free(t_objname);
free(par_name);
+ free(ptrstr);
} else {
/* first time this group has been seen -- describe it */
diff --git a/tools/h5dump/h5dumpgentest.c b/tools/h5dump/h5dumpgentest.c
index b8ed41d..f4e0b7b 100644
--- a/tools/h5dump/h5dumpgentest.c
+++ b/tools/h5dump/h5dumpgentest.c
@@ -5797,12 +5797,12 @@ gent_binary(void)
static void
gent_bigdims(void)
{
- hid_t fid;
- hid_t did;
- hid_t f_sid;
- hid_t m_sid;
- hid_t tid;
- hid_t dcpl;
+ hid_t fid = -1;
+ hid_t did = -1;
+ hid_t f_sid = -1;
+ hid_t m_sid = -1;
+ hid_t tid = -1;
+ hid_t dcpl = -1;
hsize_t dims[1]={DIM_4GB}; /* dataset dimensions */
hsize_t chunk_dims[1]={1024}; /* chunk dimensions */
hsize_t hs_start[1];
@@ -5860,14 +5860,21 @@ gent_bigdims(void)
buf=NULL;
/* close */
+ if(H5Tclose(tid) < 0)
+ goto out;
+ tid = -1;
if(H5Sclose(f_sid) < 0)
goto out;
+ f_sid = -1;
if(H5Sclose(m_sid) < 0)
goto out;
+ m_sid = -1;
if(H5Pclose(dcpl) < 0)
goto out;
+ dcpl = -1;
if(H5Dclose(did) < 0)
goto out;
+ did = -1;
ret = H5Fclose(fid);
assert(ret >= 0);
@@ -5880,11 +5887,11 @@ out:
H5Pclose(dcpl);
H5Sclose(f_sid);
H5Sclose(m_sid);
+ H5Tclose(tid);
H5Dclose(did);
H5Fclose(fid);
} H5E_END_TRY;
return;
-
}
@@ -5931,10 +5938,10 @@ gent_hyperslab(void)
static void
gent_group_creation_order(void)
{
- hid_t fid; /* file ID */
- hid_t gid; /* group ID */
- hid_t gcpl_id; /* group creation property list ID */
- hid_t fcpl_id; /* file creation property list ID (to set root group order) */
+ hid_t fid = -1; /* file ID */
+ hid_t gid = -1; /* group ID */
+ hid_t gcpl_id = -1; /* group creation property list ID */
+ hid_t fcpl_id = -1; /* file creation property list ID (to set root group order) */
if((fcpl_id = H5Pcreate(H5P_FILE_CREATE)) < 0)
goto out;
@@ -5960,37 +5967,45 @@ gent_group_creation_order(void)
goto out;
if(H5Gclose(gid) < 0)
goto out;
+ gid = -1;
if((gid = H5Gcreate2(fid, "2/c", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
goto out;
if(H5Gclose(gid) < 0)
goto out;
+ gid = -1;
if((gid = H5Gcreate2(fid, "2/b", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
goto out;
if(H5Gclose(gid) < 0)
goto out;
+ gid = -1;
if((gid = H5Gcreate2(fid, "2/a", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
goto out;
if(H5Gclose(gid) < 0)
goto out;
+ gid = -1;
if((gid = H5Gcreate2(fid, "2/a/a2", H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0)
goto out;
if(H5Gclose(gid) < 0)
goto out;
+ gid = -1;
if((gid = H5Gcreate2(fid, "2/a/a1", H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0)
goto out;
if(H5Gclose(gid) < 0)
goto out;
+ gid = -1;
if((gid = H5Gcreate2(fid, "2/a/a2/a22", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
goto out;
if(H5Gclose(gid) < 0)
goto out;
+ gid = -1;
if((gid = H5Gcreate2(fid, "2/a/a2/a21", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
goto out;
if(H5Gclose(gid) < 0)
goto out;
+ gid = -1;
/*-------------------------------------------------------------------------
@@ -6005,45 +6020,56 @@ gent_group_creation_order(void)
goto out;
if(H5Gclose(gid) < 0)
goto out;
+ gid = -1;
if((gid = H5Gcreate2(fid, "1/c", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
goto out;
if(H5Gclose(gid) < 0)
goto out;
+ gid = -1;
if((gid = H5Gcreate2(fid, "1/b", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
goto out;
if(H5Gclose(gid) < 0)
goto out;
+ gid = -1;
if((gid = H5Gcreate2(fid, "1/a", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
goto out;
if(H5Gclose(gid) < 0)
goto out;
+ gid = -1;
if((gid = H5Gcreate2(fid, "1/a/a2", H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0)
goto out;
if(H5Gclose(gid) < 0)
goto out;
+ gid = -1;
if((gid = H5Gcreate2(fid, "1/a/a1", H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0)
goto out;
if(H5Gclose(gid) < 0)
goto out;
+ gid = -1;
if((gid = H5Gcreate2(fid, "1/a/a2/a22", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
goto out;
if(H5Gclose(gid) < 0)
goto out;
+ gid = -1;
if((gid = H5Gcreate2(fid, "1/a/a2/a21", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
goto out;
if(H5Gclose(gid) < 0)
goto out;
+ gid = -1;
if(H5Pclose(gcpl_id) < 0)
goto out;
+ gcpl_id = -1;
if(H5Pclose(fcpl_id) < 0)
goto out;
+ fcpl_id = -1;
if(H5Fclose(fid) < 0)
goto out;
+ fid = -1;
return;
@@ -6071,15 +6097,15 @@ out:
static void
gent_attr_creation_order(void)
{
- hid_t fid; /* file id */
- hid_t gid; /* group id */
- hid_t did; /* dataset id */
- hid_t sid; /* space id */
- hid_t aid; /* attribute id */
- hid_t tid; /* datatype id */
- hid_t gcpl_id; /* group creation property list ID */
- hid_t dcpl_id; /* dataset creation property list ID */
- hid_t tcpl_id; /* datatype creation property list ID */
+ hid_t fid = -1; /* file id */
+ hid_t gid = -1; /* group id */
+ hid_t did = -1; /* dataset id */
+ hid_t sid = -1; /* space id */
+ hid_t aid = -1; /* attribute id */
+ hid_t tid = -1; /* datatype id */
+ hid_t gcpl_id = -1; /* group creation property list ID */
+ hid_t dcpl_id = -1; /* dataset creation property list ID */
+ hid_t tcpl_id = -1; /* datatype creation property list ID */
int i;
const char *attr_name[3] = {"c", "b", "a" };
@@ -6132,10 +6158,12 @@ gent_attr_creation_order(void)
/* close attribute */
if(H5Aclose(aid) < 0)
goto out;
+ aid = -1;
} /* end for */
if(H5Dclose(did) < 0)
goto out;
+ did = -1;
/*-------------------------------------------------------------------------
@@ -6156,10 +6184,12 @@ gent_attr_creation_order(void)
/* close attribute */
if(H5Aclose(aid) < 0)
goto out;
+ aid = -1;
} /* end for */
if(H5Dclose(did) < 0)
goto out;
+ did = -1;
@@ -6180,11 +6210,12 @@ gent_attr_creation_order(void)
/* close attribute */
if(H5Aclose(aid) < 0)
goto out;
-
+ aid = -1;
} /* end for */
if(H5Gclose(gid) < 0)
goto out;
+ gid = -1;
/*-------------------------------------------------------------------------
* create a group without creation order tracked for attributes and atributes in it
@@ -6203,12 +6234,12 @@ gent_attr_creation_order(void)
/* close attribute */
if(H5Aclose(aid) < 0)
goto out;
-
+ aid = -1;
} /* end for */
if(H5Gclose(gid) < 0)
goto out;
-
+ gid = -1;
/*-------------------------------------------------------------------------
* create a named datatype with creation order tracked for attributes and atributes in it
@@ -6230,11 +6261,12 @@ gent_attr_creation_order(void)
/* close attribute */
if(H5Aclose(aid) < 0)
goto out;
-
+ aid = -1;
} /* end for */
if(H5Tclose(tid) < 0)
goto out;
+ tid = -1;
/*-------------------------------------------------------------------------
* create a named datatype without creation order tracked for attributes and atributes in it
@@ -6256,11 +6288,12 @@ gent_attr_creation_order(void)
/* close attribute */
if(H5Aclose(aid) < 0)
goto out;
-
+ aid = -1;
} /* end for */
if(H5Tclose(tid) < 0)
goto out;
+ tid = -1;
/*-------------------------------------------------------------------------
* add some attributes to the root group
@@ -6278,12 +6311,12 @@ gent_attr_creation_order(void)
/* close attribute */
if(H5Aclose(aid) < 0)
goto out;
-
+ aid = -1;
} /* end for */
if(H5Gclose(gid) < 0)
goto out;
-
+ gid = -1;
/*-------------------------------------------------------------------------
* close
@@ -6291,15 +6324,19 @@ gent_attr_creation_order(void)
*/
if(H5Sclose(sid) < 0)
goto out;
-
+ sid = -1;
if(H5Pclose(dcpl_id) < 0)
goto out;
+ dcpl_id = -1;
if(H5Pclose(gcpl_id) < 0)
goto out;
+ gcpl_id = -1;
if(H5Pclose(tcpl_id) < 0)
goto out;
+ tcpl_id = -1;
if(H5Fclose(fid) < 0)
goto out;
+ fid = -1;
diff --git a/tools/h5repack/h5repacktst.c b/tools/h5repack/h5repacktst.c
index 7ac339a..eaebbd6 100644
--- a/tools/h5repack/h5repacktst.c
+++ b/tools/h5repack/h5repacktst.c
@@ -4153,9 +4153,9 @@ int write_attr_in(hid_t loc_id,
GREEN
} e_t;
- hid_t aid;
- hid_t sid;
- hid_t tid;
+ hid_t aid = -1;
+ hid_t sid = -1;
+ hid_t tid = -1;
int val, i, j, k, n;
float f;
@@ -4237,6 +4237,7 @@ int write_attr_in(hid_t loc_id,
goto out;
if (H5Tclose(tid) < 0)
goto out;
+ tid = -1;
/*-------------------------------------------------------------------------
* H5T_BITFIELD
@@ -4266,6 +4267,7 @@ int write_attr_in(hid_t loc_id,
goto out;
if (H5Tclose(tid) < 0)
goto out;
+ tid = -1;
/*-------------------------------------------------------------------------
* H5T_OPAQUE
@@ -4292,6 +4294,7 @@ int write_attr_in(hid_t loc_id,
goto out;
if (H5Tclose(tid) < 0)
goto out;
+ tid = -1;
/*-------------------------------------------------------------------------
* H5T_COMPOUND
@@ -4329,6 +4332,7 @@ int write_attr_in(hid_t loc_id,
goto out;
if (H5Tclose(tid) < 0)
goto out;
+ tid = -1;
/*-------------------------------------------------------------------------
* H5T_REFERENCE
@@ -4377,6 +4381,7 @@ int write_attr_in(hid_t loc_id,
goto out;
if (H5Tclose(tid) < 0)
goto out;
+ tid = -1;
/*-------------------------------------------------------------------------
* H5T_VLEN
@@ -4421,10 +4426,13 @@ int write_attr_in(hid_t loc_id,
goto out;
if (H5Aclose(aid) < 0)
goto out;
+ aid = -1;
if (H5Tclose(tid) < 0)
goto out;
+ tid = -1;
if (H5Sclose(sid) < 0)
goto out;
+ sid = -1;
/*-------------------------------------------------------------------------
* H5T_ARRAY
@@ -4459,6 +4467,7 @@ int write_attr_in(hid_t loc_id,
goto out;
if (H5Tclose(tid) < 0)
goto out;
+ tid = -1;
/*-------------------------------------------------------------------------
* H5T_INTEGER and H5T_FLOAT
@@ -4536,6 +4545,7 @@ int write_attr_in(hid_t loc_id,
goto out;
if (H5Tclose(tid) < 0)
goto out;
+ tid = -1;
/*-------------------------------------------------------------------------
* H5T_BITFIELD
@@ -4568,6 +4578,7 @@ int write_attr_in(hid_t loc_id,
goto out;
if (H5Tclose(tid) < 0)
goto out;
+ tid = -1;
/*-------------------------------------------------------------------------
* H5T_OPAQUE
@@ -4595,6 +4606,7 @@ int write_attr_in(hid_t loc_id,
goto out;
if (H5Tclose(tid) < 0)
goto out;
+ tid = -1;
/*-------------------------------------------------------------------------
* H5T_COMPOUND
@@ -4630,6 +4642,7 @@ int write_attr_in(hid_t loc_id,
goto out;
if (H5Tclose(tid) < 0)
goto out;
+ tid = -1;
/*-------------------------------------------------------------------------
* H5T_REFERENCE
@@ -4684,6 +4697,7 @@ int write_attr_in(hid_t loc_id,
goto out;
if (H5Tclose(tid) < 0)
goto out;
+ tid = -1;
/*-------------------------------------------------------------------------
* H5T_VLEN
@@ -4733,10 +4747,13 @@ int write_attr_in(hid_t loc_id,
goto out;
if (H5Aclose(aid) < 0)
goto out;
+ aid = -1;
if (H5Tclose(tid) < 0)
goto out;
+ tid = -1;
if (H5Sclose(sid) < 0)
goto out;
+ sid = -1;
/*-------------------------------------------------------------------------
* H5T_ARRAY
@@ -4779,6 +4796,7 @@ int write_attr_in(hid_t loc_id,
goto out;
if (H5Tclose(tid) < 0)
goto out;
+ tid = -1;
/*-------------------------------------------------------------------------
* H5T_INTEGER and H5T_FLOAT
@@ -4898,6 +4916,7 @@ int write_attr_in(hid_t loc_id,
goto out;
if (H5Tclose(tid) < 0)
goto out;
+ tid = -1;
/*-------------------------------------------------------------------------
* H5T_BITFIELD
@@ -4952,6 +4971,7 @@ int write_attr_in(hid_t loc_id,
goto out;
if (H5Tclose(tid) < 0)
goto out;
+ tid = -1;
/*-------------------------------------------------------------------------
* H5T_OPAQUE
@@ -4965,6 +4985,7 @@ int write_attr_in(hid_t loc_id,
goto out;
if (H5Tclose(tid) < 0)
goto out;
+ tid = -1;
/*-------------------------------------------------------------------------
* H5T_COMPOUND
@@ -5055,6 +5076,7 @@ int write_attr_in(hid_t loc_id,
goto out;
if (H5Tclose(tid) < 0)
goto out;
+ tid = -1;
/*-------------------------------------------------------------------------
* H5T_REFERENCE
@@ -5139,6 +5161,7 @@ int write_attr_in(hid_t loc_id,
goto out;
if (H5Tclose(tid) < 0)
goto out;
+ tid = -1;
/*-------------------------------------------------------------------------
* H5T_VLEN
@@ -5193,10 +5216,13 @@ int write_attr_in(hid_t loc_id,
goto out;
if (H5Aclose(aid) < 0)
goto out;
+ aid = -1;
if (H5Tclose(tid) < 0)
goto out;
+ tid = -1;
if (H5Sclose(sid) < 0)
goto out;
+ sid = -1;
/*-------------------------------------------------------------------------
* H5T_ARRAY
@@ -5230,6 +5256,7 @@ int write_attr_in(hid_t loc_id,
goto out;
if (H5Tclose(tid) < 0)
goto out;
+ tid = -1;
/*-------------------------------------------------------------------------
* H5T_INTEGER and H5T_FLOAT
diff --git a/tools/lib/h5diff_dset.c b/tools/lib/h5diff_dset.c
index 7f2a80a..ad9331d 100644
--- a/tools/lib/h5diff_dset.c
+++ b/tools/lib/h5diff_dset.c
@@ -462,8 +462,17 @@ hsize_t diff_datasetid( hid_t did1,
assert(sm_nbytes > 0);
}
+ /* malloc return code should be verified.
+ * If fail, need to handle the error.
+ * This else branch should be recoded as a separate function.
+ * Note that there are many "goto error" within this branch
+ * that fails to address freeing other objects created here.
+ * E.g., sm_space.
+ */
sm_buf1 = malloc((size_t)sm_nbytes);
+ assert(sm_buf1);
sm_buf2 = malloc((size_t)sm_nbytes);
+ assert(sm_buf2);
sm_nelmts = sm_nbytes / p_type_nbytes;
sm_space = H5Screate_simple(1, &sm_nelmts, NULL);
@@ -537,18 +546,11 @@ hsize_t diff_datasetid( hid_t did1,
H5Sclose(sm_space);
/* free */
- if (sm_buf1!=NULL)
- {
- free(sm_buf1);
- sm_buf1=NULL;
- }
- if (sm_buf2!=NULL)
- {
- free(sm_buf2);
- sm_buf2=NULL;
- }
-
- } /* hyperslab read */
+ HDfree(sm_buf1);
+ sm_buf1 = NULL;
+ HDfree(sm_buf2);
+ sm_buf2 = NULL;
+ } /* hyperslab read */
}/*can_compare*/
/*-------------------------------------------------------------------------
diff --git a/tools/lib/h5tools.c b/tools/lib/h5tools.c
index 3b2984b..80016b2 100644
--- a/tools/lib/h5tools.c
+++ b/tools/lib/h5tools.c
@@ -1307,17 +1307,17 @@ h5tools_print_region_data_blocks(hid_t region_space, hid_t region_id,
hsize_t curr_pos;
int jndx;
int type_size;
- hid_t mem_space;
+ hid_t mem_space = -1;
void *region_buf = NULL;
int blkndx;
- hid_t sid1;
+ hid_t sid1 = -1;
/* Get the dataspace of the dataset */
if((sid1 = H5Dget_space(region_id)) < 0)
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dget_space failed");
/* Allocate space for the dimension array */
- if((dims1 = (hsize_t *) malloc(sizeof(hsize_t) * ndims)) == NULL)
+ if((dims1 = (hsize_t *) HDmalloc(sizeof(hsize_t) * ndims)) == NULL)
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "Could not allocate buffer for dims");
/* find the dimensions of each data space from the block coordinates */
@@ -1334,15 +1334,15 @@ h5tools_print_region_data_blocks(hid_t region_space, hid_t region_id,
if((type_size = H5Tget_size(type_id)) == 0)
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tget_size failed");
- if((region_buf = malloc(type_size * numelem)) == NULL)
+ if((region_buf = HDmalloc(type_size * numelem)) == NULL)
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "Could not allocate region buffer");
/* Select (x , x , ..., x ) x (y , y , ..., y ) hyperslab for reading memory dataset */
/* 1 2 n 1 2 n */
- if((start = (hsize_t *) malloc(sizeof(hsize_t) * ndims)) == NULL)
+ if((start = (hsize_t *) HDmalloc(sizeof(hsize_t) * ndims)) == NULL)
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "Could not allocate buffer for start");
- if((count = (hsize_t *) malloc(sizeof(hsize_t) * ndims)) == NULL)
+ if((count = (hsize_t *) HDmalloc(sizeof(hsize_t) * ndims)) == NULL)
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "Could not allocate buffer for count");
curr_pos = 0;
@@ -1408,10 +1408,10 @@ h5tools_print_region_data_blocks(hid_t region_space, hid_t region_id,
} /* end for (blkndx = 0; blkndx < nblocks; blkndx++) */
done:
- free(start);
- free(count);
- free(region_buf);
- free(dims1);
+ HDfree(start);
+ HDfree(count);
+ HDfree(region_buf);
+ HDfree(dims1);
if(H5Sclose(mem_space) < 0)
HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Sclose failed");
@@ -1648,18 +1648,17 @@ h5tools_print_region_data_points(hid_t region_space, hid_t region_id,
int indx;
int jndx;
int type_size;
- hid_t mem_space;
- hid_t dtype;
+ hid_t mem_space = -1;
void *region_buf = NULL;
if((type_size = H5Tget_size(type_id)) == 0)
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tget_size failed");
- if((region_buf = malloc(type_size * npoints)) == NULL)
+ if((region_buf = HDmalloc(type_size * npoints)) == NULL)
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "Could not allocate buffer for region");
/* Allocate space for the dimension array */
- if((dims1 = (hsize_t *) malloc(sizeof(hsize_t) * ndims)) == NULL)
+ if((dims1 = (hsize_t *) HDmalloc(sizeof(hsize_t) * ndims)) == NULL)
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "Could not allocate buffer for dims");
dims1[0] = npoints;
@@ -1723,8 +1722,8 @@ h5tools_print_region_data_points(hid_t region_space, hid_t region_id,
} /* end for (jndx = 0; jndx < npoints; jndx++, region_elmtno++) */
done:
- free(region_buf);
- free(dims1);
+ HDfree(region_buf);
+ HDfree(dims1);
if(H5Sclose(mem_space) < 0)
HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Sclose failed");
@@ -1972,7 +1971,7 @@ h5tools_print_simple_subset(FILE *stream, const h5tool_format_t *info, h5tools_c
hsize_t sm_nbytes; /* bytes per stripmine */
hsize_t sm_nelmts; /* elements per stripmine*/
unsigned char *sm_buf = NULL; /* buffer for raw data */
- hid_t sm_space; /* stripmine data space */
+ hid_t sm_space = -1; /* stripmine data space */
hsize_t size_row_block; /* size for blocks along rows */
hsize_t row_counter = 0;
@@ -2025,7 +2024,7 @@ h5tools_print_simple_subset(FILE *stream, const h5tool_format_t *info, h5tools_c
}
assert(sm_nbytes == (hsize_t) ((size_t) sm_nbytes)); /*check for overflow*/
- if((sm_buf = malloc((size_t) sm_nelmts * p_type_nbytes)) == NULL)
+ if((sm_buf = HDmalloc((size_t) sm_nelmts * p_type_nbytes)) == NULL)
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "Could not allocate buffer for strip-mine");
if((sm_space = H5Screate_simple(1, &sm_nelmts, NULL)) < 0)
@@ -2070,7 +2069,7 @@ h5tools_print_simple_subset(FILE *stream, const h5tool_format_t *info, h5tools_c
done:
if(H5Sclose(sm_space) < 0)
HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Sclose failed");
- free(sm_buf);
+ HDfree(sm_buf);
}
else
H5E_THROW(SUCCEED, H5E_tools_min_id_g, "nothing to print");
@@ -3380,14 +3379,18 @@ h5tools_print_enum(h5tools_str_t *buffer, hid_t type)
CATCH
- /* Release resources */
- for (i = 0; i < nmembs; i++)
- free(name[i]);
+ if(name) {
+ /* Release resources */
+ for (i = 0; i < nmembs; i++)
+ if(name[i])
+ free(name[i]);
+ free(name);
+ } /* end if */
- free(name);
- free(value);
-
- if(H5Tclose(super) < 0)
+ if(value)
+ free(value);
+
+ if(super >= 0 && H5Tclose(super) < 0)
H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Tclose failed");
if (0 == nmembs)