summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>1998-07-07 22:14:28 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>1998-07-07 22:14:28 (GMT)
commit5f85a202e2d211420352267fd0d3c4f3797e0ac1 (patch)
treed3197ad9d1a783053e1fa6655f3c7ec06507524d
parent3748f79ca2f867ecd82dd159822918ad99059320 (diff)
downloadhdf5-5f85a202e2d211420352267fd0d3c4f3797e0ac1.zip
hdf5-5f85a202e2d211420352267fd0d3c4f3797e0ac1.tar.gz
hdf5-5f85a202e2d211420352267fd0d3c4f3797e0ac1.tar.bz2
[svn-r464] Plugged several memory leaks in the hyperslab selection iterators.
-rw-r--r--src/H5Shyper.c45
-rw-r--r--src/H5Sprivate.h4
-rw-r--r--src/H5Spublic.h2
-rw-r--r--src/H5Sselect.c50
4 files changed, 94 insertions, 7 deletions
diff --git a/src/H5Shyper.c b/src/H5Shyper.c
index 2d7a4b4..0ea8eb9 100644
--- a/src/H5Shyper.c
+++ b/src/H5Shyper.c
@@ -536,7 +536,7 @@ H5S_hyper_fwrite (intn dim, H5S_hyper_fhyper_info_t *fhyper_info)
}
/* Advance the pointer in the buffer */
- fhyper_info->src=((uint8 *)fhyper_info->src)+((regions[i].end-regions[i].start)+1)*fhyper_info->elmt_size;
+ fhyper_info->src=((const uint8 *)fhyper_info->src)+((regions[i].end-regions[i].start)+1)*fhyper_info->elmt_size;
/* Increment the number of elements read */
num_written+=(regions[i].end-regions[i].start)+1;
@@ -816,7 +816,10 @@ H5S_hyper_mgath (const void *_buf, size_t elmt_size,
H5S_hyper_bound_t **lo_bounds; /* Lower (closest to the origin) bound array for each dimension */
H5S_hyper_bound_t **hi_bounds; /* Upper (farthest from the origin) bound array for each dimension */
H5S_hyper_fhyper_info_t fhyper_info; /* Block of parameters to pass into recursive calls */
- intn i,j; /* Counters */
+ intn i;
+#ifdef QAK
+ intn j; /* Counters */
+#endif /* QAK */
size_t num_read; /* number of elements read into buffer */
FUNC_ENTER (H5S_hyper_mgath, 0);
@@ -977,7 +980,7 @@ printf("%s: check 3.0\n",FUNC);
}
/* Advance the pointer in the buffer */
- fhyper_info->src=((uint8 *)fhyper_info->src)+((regions[i].end-regions[i].start)+1)*fhyper_info->elmt_size;
+ fhyper_info->src=((const uint8 *)fhyper_info->src)+((regions[i].end-regions[i].start)+1)*fhyper_info->elmt_size;
/* Increment the number of elements read */
num_read+=(regions[i].end-regions[i].start)+1;
@@ -1176,7 +1179,9 @@ H5S_hyper_add (H5S_t *space, const hssize_t *start, const hsize_t *size)
size_t elem_count; /* Number of elements in hyperslab selection */
intn i; /* Counters */
herr_t ret_value=FAIL;
+#ifdef QAK
extern int qak_debug;
+#endif /* QAK */
FUNC_ENTER (H5S_hyper_add, FAIL);
@@ -1185,7 +1190,9 @@ extern int qak_debug;
assert (start);
assert (size);
+#ifdef QAK
qak_debug=1;
+#endif /* QAK */
#ifdef QAK
printf("%s: check 1.0\n",FUNC);
@@ -1395,3 +1402,35 @@ H5S_point_npoints (const H5S_t *space)
FUNC_LEAVE (space->select.num_elem);
} /* H5S_point_npoints() */
+
+/*--------------------------------------------------------------------------
+ NAME
+ H5S_hyper_sel_iter_release
+ PURPOSE
+ Release hyperslab selection iterator information for a dataspace
+ USAGE
+ herr_t H5S_hyper_sel_iter_release(sel_iter)
+ H5S_t *space; IN: Pointer to dataspace iterator is for
+ H5S_sel_iter_t *sel_iter; IN: Pointer to selection iterator
+ RETURNS
+ SUCCEED/FAIL
+ DESCRIPTION
+ Releases all information for a dataspace hyperslab selection iterator
+ GLOBAL VARIABLES
+ COMMENTS, BUGS, ASSUMPTIONS
+ EXAMPLES
+ REVISION LOG
+--------------------------------------------------------------------------*/
+herr_t
+H5S_hyper_sel_iter_release (H5S_sel_iter_t *sel_iter)
+{
+ FUNC_ENTER (H5S_hyper_sel_iter_release, FAIL);
+
+ /* Check args */
+ assert (sel_iter);
+
+ if(sel_iter->hyp.pos!=NULL)
+ H5MM_xfree(sel_iter->hyp.pos);
+
+ FUNC_LEAVE (SUCCEED);
+} /* H5S_hyper_sel_iter_release() */
diff --git a/src/H5Sprivate.h b/src/H5Sprivate.h
index fc7546f..2d5a7b3 100644
--- a/src/H5Sprivate.h
+++ b/src/H5Sprivate.h
@@ -204,7 +204,7 @@ H5S_t *H5S_create (H5S_class_t type);
H5S_t *H5S_copy (const H5S_t *src);
herr_t H5S_close_simple (H5S_simple_t *simple);
herr_t H5S_close (H5S_t *ds);
-hsize_t H5S_get_npoints (const H5S_t *ds);
+hsize_t H5S_extent_npoints (const H5S_t *ds);
hsize_t H5S_get_npoints_max(const H5S_t *ds);
intn H5S_get_ndims (const H5S_t *ds);
intn H5S_get_dims (const H5S_t *ds, hsize_t dims[]/*out*/,
@@ -221,6 +221,7 @@ herr_t H5S_release_simple(H5S_simple_t *simple);
herr_t H5S_extent_copy(H5S_extent_t *dst, const H5S_extent_t *src);
herr_t H5S_select_copy (H5S_t *dst, const H5S_t *src);
herr_t H5S_select_release (H5S_t *space);
+herr_t H5S_sel_iter_release (const H5S_t *space,H5S_sel_iter_t *sel_iter);
hsize_t H5S_select_npoints (const H5S_t *space);
intn H5S_extend (H5S_t *space, const hsize_t *size);
@@ -328,6 +329,7 @@ herr_t H5S_hyper_mscat (const void *_tconv_buf, size_t elmt_size,
size_t nelmts, void *_buf/*out*/);
herr_t H5S_hyper_add (H5S_t *space, const hssize_t *start, const hsize_t *size);
herr_t H5S_hyper_release (H5S_t *space);
+herr_t H5S_hyper_sel_iter_release (H5S_sel_iter_t *sel_iter);
hsize_t H5S_hyper_npoints (const H5S_t *space);
#endif
diff --git a/src/H5Spublic.h b/src/H5Spublic.h
index b08b489..3a1b437 100644
--- a/src/H5Spublic.h
+++ b/src/H5Spublic.h
@@ -48,7 +48,7 @@ hid_t H5Screate_simple (int rank, const hsize_t dims[], const hsize_t maxdims[])
herr_t H5Sset_extent_simple (hid_t sid, int rank, const hsize_t *dims, const hsize_t *max);
hid_t H5Scopy (hid_t space_id);
herr_t H5Sclose (hid_t space_id);
-hsize_t H5Sget_npoints (hid_t space_id);
+hsize_t H5Sextent_npoints (hid_t space_id);
int H5Sget_ndims (hid_t space_id);
int H5Sget_dims (hid_t space_id, hsize_t dims[], hsize_t maxdims[]);
hbool_t H5Sis_simple (hid_t space_id);
diff --git a/src/H5Sselect.c b/src/H5Sselect.c
index b089a43..e04654c 100644
--- a/src/H5Sselect.c
+++ b/src/H5Sselect.c
@@ -123,7 +123,7 @@ herr_t H5S_select_copy (H5S_t *dst, const H5S_t *src)
herr_t
H5S_select_release (H5S_t *space)
{
- herr_t ret_value; /* Counters */
+ herr_t ret_value; /* return value */
FUNC_ENTER (H5S_select_release, FAIL);
@@ -147,7 +147,7 @@ H5S_select_release (H5S_t *space)
break;
} /* end switch() */
- FUNC_LEAVE (SUCCEED);
+ FUNC_LEAVE (ret_value);
} /* H5S_select_release() */
/*--------------------------------------------------------------------------
@@ -386,3 +386,49 @@ hsize_t H5S_select_npoints (const H5S_t *space)
FUNC_LEAVE (ret_value);
} /* H5Sselect_npoints() */
+
+/*--------------------------------------------------------------------------
+ NAME
+ H5S_sel_iter_release
+ PURPOSE
+ Release selection iterator information for a dataspace
+ USAGE
+ herr_t H5S_sel_iter_release(sel_iter)
+ const H5S_t *space; IN: Pointer to dataspace iterator is for
+ H5S_sel_iter_t *sel_iter; IN: Pointer to selection iterator
+ RETURNS
+ SUCCEED/FAIL
+ DESCRIPTION
+ Releases all information for a dataspace selection iterator
+ GLOBAL VARIABLES
+ COMMENTS, BUGS, ASSUMPTIONS
+ EXAMPLES
+ REVISION LOG
+--------------------------------------------------------------------------*/
+herr_t
+H5S_sel_iter_release (const H5S_t *space, H5S_sel_iter_t *sel_iter)
+{
+ herr_t ret_value; /* Return value */
+
+ FUNC_ENTER (H5S_sel_iter_release, FAIL);
+
+ /* Check args */
+ assert (sel_iter);
+
+ switch(space->select.type) {
+ case H5S_SEL_POINTS: /* Sequence of points selected */
+ case H5S_SEL_ALL: /* Entire extent selected */
+ /* no action needed */
+ ret_value=SUCCEED;
+ break;
+
+ case H5S_SEL_HYPERSLABS: /* Hyperslab selection defined */
+ ret_value=H5S_hyper_sel_iter_release(sel_iter);
+ break;
+
+ case H5S_SEL_NONE: /* Nothing selected */
+ break;
+ } /* end switch() */
+
+ FUNC_LEAVE (ret_value);
+} /* H5S_sel_iter_release() */