summaryrefslogtreecommitdiffstats
path: root/src/H5Tconv.c
diff options
context:
space:
mode:
authorRaymond Lu <songyulu@hdfgroup.org>2002-07-10 18:12:03 (GMT)
committerRaymond Lu <songyulu@hdfgroup.org>2002-07-10 18:12:03 (GMT)
commit57c1e0610331836af2ea13d4ec78d71a93bf2c08 (patch)
tree1bde38b6cbe2d14e29f6bf2424bdb4f7c7ec5422 /src/H5Tconv.c
parent613d55cd118292b0837c2e8437b6e92c7a4b9a2e (diff)
downloadhdf5-57c1e0610331836af2ea13d4ec78d71a93bf2c08.zip
hdf5-57c1e0610331836af2ea13d4ec78d71a93bf2c08.tar.gz
hdf5-57c1e0610331836af2ea13d4ec78d71a93bf2c08.tar.bz2
[svn-r5776]
Purpose: Bug fix. Description: For nested VL datatype, the heap object of VL elements lower than top level weren't freed. Solution: Read in the content of heap object for VL elements and free them in function H5T_conv_vlen. Platforms tested: eirene
Diffstat (limited to 'src/H5Tconv.c')
-rw-r--r--src/H5Tconv.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/H5Tconv.c b/src/H5Tconv.c
index b155384..0ddfedb 100644
--- a/src/H5Tconv.c
+++ b/src/H5Tconv.c
@@ -2179,8 +2179,10 @@ H5T_conv_vlen(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, hsize_t nelmts,
uint8_t **dptr; /*pointer to correct destination pointer*/
uint8_t *bg_ptr=NULL; /*background buf traversal pointer */
uint8_t *bg=NULL;
+ H5HG_t bg_hobjid;
size_t src_delta, dst_delta, bkg_delta;/*source & destination stride*/
hssize_t seq_len; /*the number of elements in the current sequence*/
+ hsize_t bg_seq_len=0;
size_t src_base_size, dst_base_size;/*source & destination base size*/
size_t src_size, dst_size; /*source & destination total size in bytes*/
void *conv_buf=NULL; /*temporary conversion buffer */
@@ -2301,7 +2303,7 @@ H5T_conv_vlen(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, hsize_t nelmts,
}
/* Check if we need a temporary buffer for this conversion */
- if(tpath->cdata.need_bkg) {
+ if(tpath->cdata.need_bkg||H5T_detect_class(dst->parent,H5T_VLEN)) {
/* Set up initial background buffer */
tmp_buf_size=MAX(src_base_size,dst_base_size);
if ((tmp_buf=H5FL_BLK_ALLOC(vlen_seq,tmp_buf_size,1))==NULL)
@@ -2337,7 +2339,8 @@ H5T_conv_vlen(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, hsize_t nelmts,
/* Check if temporary buffer is large enough, resize if necessary */
/* (Chain off the conversion buffer size) */
- if(tpath->cdata.need_bkg && tmp_buf_size<conv_buf_size) {
+ if((tpath->cdata.need_bkg||H5T_detect_class(dst->parent,
+ H5T_VLEN)) && tmp_buf_size<conv_buf_size) {
/* Set up initial background buffer */
tmp_buf_size=conv_buf_size;
if((tmp_buf=H5FL_BLK_REALLOC(vlen_seq,tmp_buf,tmp_buf_size))==NULL)
@@ -2345,6 +2348,20 @@ H5T_conv_vlen(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, hsize_t nelmts,
HDmemset(tmp_buf,0,tmp_buf_size);
} /* end if */
+ /* If we are writing and there is a nested VL type, read
+ * the sequence into the background buffer */
+ if(dst->u.vlen.f!=NULL && H5T_detect_class(dst->parent,H5T_VLEN) && bg!=NULL) {
+ UINT32DECODE(bg, bg_seq_len);
+ if(bg_seq_len>0) {
+ H5F_addr_decode(dst->u.vlen.f, (const uint8_t **)&bg,
+ &(bg_hobjid.addr));
+ INT32DECODE(bg, bg_hobjid.idx);
+ if(H5HG_read(dst->u.vlen.f,&bg_hobjid,tmp_buf)==NULL)
+ HRETURN_ERROR (H5E_DATATYPE, H5E_READERROR, FAIL,
+ "can't read VL sequence into background buffer");
+ } /* end if */
+ } /* end if */
+
/* Convert VL sequence */
H5_CHECK_OVERFLOW(seq_len,hssize_t,hsize_t);
if (H5T_convert(tpath, tsrc_id, tdst_id, (hsize_t)seq_len, 0, bkg_stride, conv_buf, tmp_buf, dset_xfer_plist)<0)