summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2003-10-09 16:51:52 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2003-10-09 16:51:52 (GMT)
commit49727974f39bf0ac2b9d4292cfd1cdbacb77328b (patch)
tree20476cf126e080abb1eeea68c554ad7c80bf552d /src
parent6bc068e998d67e3825f559b4c3bb767140527d96 (diff)
downloadhdf5-49727974f39bf0ac2b9d4292cfd1cdbacb77328b.zip
hdf5-49727974f39bf0ac2b9d4292cfd1cdbacb77328b.tar.gz
hdf5-49727974f39bf0ac2b9d4292cfd1cdbacb77328b.tar.bz2
[svn-r7579] Purpose:
Bug fix Description: The VL type conversion routine attempt to align it's destination buffer to an offer that will work for both hvl_t and char * types, but the algorithm used fails to work correctly on Cray machines. Solution: Give up on attempting to align the buffer when it's allocated on the stack. Just dynamically allocate it instead. Platforms tested: FreeBSD 4.9 (sleipnir) Cray SV1 (wind)
Diffstat (limited to 'src')
-rw-r--r--src/H5Tconv.c23
1 files changed, 13 insertions, 10 deletions
diff --git a/src/H5Tconv.c b/src/H5Tconv.c
index c9329bd..0580c2d 100644
--- a/src/H5Tconv.c
+++ b/src/H5Tconv.c
@@ -2126,7 +2126,8 @@ H5T_conv_vlen(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, hsize_t nelmts,
size_t conv_buf_size=0; /*size of conversion buffer in bytes */
void *tmp_buf=NULL; /*temporary background buffer */
size_t tmp_buf_size=0; /*size of temporary bkg buffer */
- uint8_t dbuf[64],*dbuf_ptr; /*temp destination buffer */
+ void *dbuf=NULL; /*temp destination buffer */
+ size_t dbuf_size=0; /*size of destination buffer */
int direction; /*direction of traversal */
int nested=0; /*flag of nested VL case */
hsize_t elmtno; /*element number counter */
@@ -2205,18 +2206,17 @@ H5T_conv_vlen(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, hsize_t nelmts,
dst_delta = direction * (buf_stride ? buf_stride : dst->size);
bkg_delta = direction * (bkg_stride ? bkg_stride : dst->size);
- /* Set the dbuf_ptr correctly, based on the alignment of the dbuf */
- /* (Have to use the maximum alignment of hvl_t and 'char *' types */
- /* since this routine is used for both variable-length sequences */
- /* and variable-length strings) */
- dbuf_ptr=dbuf+(((size_t)dbuf)%MAX(H5T_HVL_COMP_ALIGN_g,H5T_POINTER_COMP_ALIGN_g));
+ /* Dynamically allocate the destination buffer */
+ dbuf_size=MAX(sizeof(hvl_t),sizeof(char *));
+ if ((dbuf=H5FL_BLK_MALLOC(vlen_seq,dbuf_size))==NULL)
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for type conversion");
/*
* If the source and destination buffers overlap then use a
* temporary buffer for the destination.
*/
if (direction>0) {
- dptr = &dbuf_ptr;
+ dptr = (uint8_t **)&dbuf;
} else {
dptr = &dp;
}
@@ -2340,7 +2340,7 @@ H5T_conv_vlen(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, hsize_t nelmts,
* then we should copy the value to the true destination
* buffer.
*/
- if (d==dbuf_ptr) HDmemcpy (dp, d, dst->size);
+ if (d==dbuf) HDmemcpy (dp, d, dst->size);
sp += src_delta;
dp += dst_delta;
if(bg_ptr!=NULL)
@@ -2348,10 +2348,10 @@ H5T_conv_vlen(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, hsize_t nelmts,
/* switch destination pointer around when the olap gets to 0 */
if(--olap==0) {
- if(dptr==&dbuf_ptr)
+ if(dptr==(uint8_t **)&dbuf)
dptr=&dp;
else
- dptr=&dbuf_ptr;
+ dptr=(uint8_t **)&dbuf;
} /* end if */
}
@@ -2373,6 +2373,9 @@ done:
/* Release the background buffer, if we have one */
if(tmp_buf!=NULL)
H5FL_BLK_FREE(vlen_seq,tmp_buf);
+ /* Release the destination buffer, if we have one */
+ if(dbuf!=NULL)
+ H5FL_BLK_FREE(vlen_seq,dbuf);
FUNC_LEAVE_NOAPI(ret_value);
}