[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
This commit is contained in:
Raymond Lu 2002-07-10 13:12:03 -05:00
parent 613d55cd11
commit 57c1e06103

View File

@ -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)