summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2003-10-09 16:52:12 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2003-10-09 16:52:12 (GMT)
commit8da2fafcec195f762a87e096330242c6bad064da (patch)
treeb86796e7f39d5e24c9d65f88beb01d28edb1670c /src
parentdc4212e15c46716ad05739e7d40d61b95b94c9a2 (diff)
downloadhdf5-8da2fafcec195f762a87e096330242c6bad064da.zip
hdf5-8da2fafcec195f762a87e096330242c6bad064da.tar.gz
hdf5-8da2fafcec195f762a87e096330242c6bad064da.tar.bz2
[svn-r7580] 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 08a181e..9c5045a 100644
--- a/src/H5Tconv.c
+++ b/src/H5Tconv.c
@@ -2154,7 +2154,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 */
@@ -2233,18 +2234,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;
}
@@ -2368,7 +2368,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)
@@ -2376,10 +2376,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 */
}
@@ -2401,6 +2401,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);
}