summaryrefslogtreecommitdiffstats
path: root/src/H5D.c
diff options
context:
space:
mode:
authorRaymond Lu <songyulu@hdfgroup.org>2002-07-03 21:06:55 (GMT)
committerRaymond Lu <songyulu@hdfgroup.org>2002-07-03 21:06:55 (GMT)
commitd934f081d22b04fd6576b21008d2bb7bf0182a72 (patch)
treeae921a04a2c507d88449e722310178034139b08c /src/H5D.c
parente858a1310df466b41c2e743915d8b57f999aa4ad (diff)
downloadhdf5-d934f081d22b04fd6576b21008d2bb7bf0182a72.zip
hdf5-d934f081d22b04fd6576b21008d2bb7bf0182a72.tar.gz
hdf5-d934f081d22b04fd6576b21008d2bb7bf0182a72.tar.bz2
[svn-r5764]
Purpose: Bug Fix. Description: VL type memory leak when data is overwritten. Solution: Free heap objects holding old data. Platforms tested: Linux 2.2(eirene), IRIX 6.5(paz).
Diffstat (limited to 'src/H5D.c')
-rw-r--r--src/H5D.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/H5D.c b/src/H5D.c
index 1bd7081..d125bd5 100644
--- a/src/H5D.c
+++ b/src/H5D.c
@@ -1545,7 +1545,13 @@ H5D_create(H5G_entry_t *loc, const char *name, const H5T_t *type,
if(IS_H5FD_MPIO(f) && dcpl_pline.nfilters > 0)
HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, NULL, "Parallel I/O does not support filters yet");
#endif /*H5_HAVE_PARALLEL*/
-
+
+ if(H5P_get(plist, H5D_CRT_FILL_TIME_NAME, &fill_time) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't retrieve fill time");
+
+ if(fill_time==H5D_FILL_TIME_NEVER && H5T_detect_class(type, H5T_VLEN))
+ HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, NULL, "Dataset doesn't support VL datatype when fill value is not defined");
+
/* Initialize the dataset object */
if(NULL == (new_dset = H5D_new(dcpl_id)))
HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
@@ -2876,6 +2882,10 @@ H5D_write(H5D_t *dataset, const H5T_t *mem_type, const H5S_t *mem_space,
if(H5P_get(dx_plist, H5D_XFER_BKGR_BUF_TYPE_NAME, &need_bkg)<0)
HGOTO_ERROR (H5E_PLIST, H5E_CANTGET, FAIL, "Can't retrieve background buffer type");
need_bkg = MAX (tpath->cdata.need_bkg, need_bkg);
+ } else if(H5T_detect_class(dataset->type, H5T_VLEN)) {
+ /* Old data is retrieved into background buffer for VL datatype. The
+ * data is used later for freeing heap objects. */
+ need_bkg = H5T_BKG_YES;
} else {
need_bkg = H5T_BKG_NO; /*never needed even if app says yes*/
} /* end else */
@@ -2887,7 +2897,7 @@ H5D_write(H5D_t *dataset, const H5T_t *mem_type, const H5S_t *mem_space,
if (need_bkg && NULL==(bkg_buf=H5P_peek_voidp(dx_plist,H5D_XFER_BKGR_BUF_NAME))) {
/* Allocate background buffer */
H5_CHECK_OVERFLOW((request_nelmts*dst_type_size),hsize_t,size_t);
- if((bkg_buf=H5FL_BLK_ALLOC(bkgr_conv,(size_t)(request_nelmts*dst_type_size),0))==NULL)
+ if((bkg_buf=H5FL_BLK_ALLOC(bkgr_conv,(size_t)(request_nelmts*dst_type_size),1))==NULL)
HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for background conversion");
} /* end if */