summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2002-04-17 18:49:49 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2002-04-17 18:49:49 (GMT)
commit4433c857661d50e748788afcbd862a12133ce756 (patch)
tree29b6d55263e14006c1471e174fc1e79f5a2680b6 /src
parent67d22cb484f9d81cdef578deceb4a8ee5046a88b (diff)
downloadhdf5-4433c857661d50e748788afcbd862a12133ce756.zip
hdf5-4433c857661d50e748788afcbd862a12133ce756.tar.gz
hdf5-4433c857661d50e748788afcbd862a12133ce756.tar.bz2
[svn-r5195] Purpose:
Code cleanup Description: Got rid of the "H5T_BKG_TEMP" setting that was used internally to the library, since temporary background buffers are now handled by the individual conversion routines instead of in a global background buffer. No APIs were changed or affected by this. Platforms tested: FreeBSD 4.5 (sleipnir)
Diffstat (limited to 'src')
-rw-r--r--src/H5D.c15
-rw-r--r--src/H5Ofill.c15
-rw-r--r--src/H5P.c5
-rw-r--r--src/H5Tconv.c41
-rw-r--r--src/H5Tpublic.h3
5 files changed, 15 insertions, 64 deletions
diff --git a/src/H5D.c b/src/H5D.c
index 26cc9e3..94a00e5 100644
--- a/src/H5D.c
+++ b/src/H5D.c
@@ -2547,7 +2547,7 @@ printf("%s: check 2.0, src_type_size=%d, dst_type_size=%d, target_size=%d, min_e
#endif /* QAK */
#endif /* QAK */
- if (H5T_BKG_YES==need_bkg) {
+ if (need_bkg) {
#ifdef H5S_DEBUG
H5_timer_begin(&timer);
#endif
@@ -2560,10 +2560,7 @@ printf("%s: check 2.0, src_type_size=%d, dst_type_size=%d, target_size=%d, min_e
#endif
if (n!=smine_nelmts)
HGOTO_ERROR (H5E_IO, H5E_READERROR, FAIL, "mem gather failed");
- } else if (need_bkg) {
- assert((request_nelmts*dst_type_size)==(hsize_t)((size_t)(request_nelmts*dst_type_size))); /*check for overflow*/
- HDmemset(bkg_buf, 0, (size_t)(request_nelmts*dst_type_size));
- }
+ } /* end if */
#ifdef QAK
printf("%s: check 7.0\n",FUNC);
@@ -3058,7 +3055,7 @@ printf("%s: check 2.0, src_type_size=%d, dst_type_size=%d, target_size=%d\n",FUN
printf("%s: check 6.0, tconv_buf=%p, *tconv_buf=%p\n",FUNC,tconv_buf,*(char **)tconv_buf);
#endif
- if (H5T_BKG_YES==need_bkg) {
+ if (need_bkg) {
#ifdef QAK
printf("%s: check 6.1, need_bkg=%d\n",FUNC,(int)need_bkg);
#endif
@@ -3077,12 +3074,6 @@ printf("%s: check 2.0, src_type_size=%d, dst_type_size=%d, target_size=%d\n",FUN
#endif
if (n!=smine_nelmts)
HGOTO_ERROR (H5E_IO, H5E_WRITEERROR, FAIL, "file gather failed");
- } else if (need_bkg) {
-#ifdef QAK
- printf("%s: check 6.2, need_bkg=%d\n",FUNC,(int)need_bkg);
-#endif
- H5_CHECK_OVERFLOW(request_nelmts*dst_type_size,hsize_t,size_t);
- HDmemset(bkg_buf, 0, (size_t)(request_nelmts*dst_type_size));
} /* end if */
/*
diff --git a/src/H5Ofill.c b/src/H5Ofill.c
index 567b7ca..4342f13 100644
--- a/src/H5Ofill.c
+++ b/src/H5Ofill.c
@@ -698,17 +698,12 @@ H5O_fill_convert(void *_fill, H5T_t *dset_type)
}
HDmemcpy(buf, fill->buf, H5T_get_size(fill->type));
}
- if (tpath->cdata.need_bkg>=H5T_BKG_TEMP &&
- NULL==(bkg=H5MM_malloc(H5T_get_size(dset_type)))) {
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL,
- "memory allocation failed for type conversion");
- }
+ if (tpath->cdata.need_bkg && NULL==(bkg=H5MM_malloc(H5T_get_size(dset_type))))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for type conversion");
/* Do the conversion */
- if (H5T_convert(tpath, src_id, dst_id, (hsize_t)1, 0, 0, buf, bkg, H5P_DEFAULT)<0) {
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL,
- "data type conversion failed");
- }
+ if (H5T_convert(tpath, src_id, dst_id, (hsize_t)1, 0, 0, buf, bkg, H5P_DEFAULT)<0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "data type conversion failed");
/* Update the fill message */
if (buf!=fill->buf) {
@@ -724,6 +719,6 @@ H5O_fill_convert(void *_fill, H5T_t *dset_type)
if (src_id>=0) H5I_dec_ref(src_id);
if (dst_id>=0) H5I_dec_ref(dst_id);
if (buf!=fill->buf) H5MM_xfree(buf);
- H5MM_xfree(bkg);
+ if (bkg) H5MM_xfree(bkg);
FUNC_LEAVE(ret_value);
}
diff --git a/src/H5P.c b/src/H5P.c
index 3098419..dae7f19 100644
--- a/src/H5P.c
+++ b/src/H5P.c
@@ -3364,13 +3364,12 @@ H5Pget_fill_value(hid_t plist_id, hid_t type_id, void *value/*out*/)
*/
if (H5T_get_size(type)>=H5T_get_size(fill.type)) {
buf = value;
- if (tpath->cdata.need_bkg>=H5T_BKG_TEMP &&
- NULL==(bkg=H5MM_malloc(H5T_get_size(type))))
+ if (tpath->cdata.need_bkg && NULL==(bkg=H5MM_malloc(H5T_get_size(type))))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for type conversion");
} else {
if (NULL==(buf=H5MM_malloc(H5T_get_size(fill.type))))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for type conversion");
- if (tpath->cdata.need_bkg>=H5T_BKG_TEMP)
+ if (tpath->cdata.need_bkg)
bkg = value;
}
HDmemcpy(buf, fill.buf, H5T_get_size(fill.type));
diff --git a/src/H5Tconv.c b/src/H5Tconv.c
index 00cde28..bb2edd6 100644
--- a/src/H5Tconv.c
+++ b/src/H5Tconv.c
@@ -1173,40 +1173,6 @@ H5T_conv_b_b(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, hsize_t nelmts,
/*-------------------------------------------------------------------------
- * Function: H5T_conv_need_bkg
- *
- * Purpose: Check whether the source or destination datatypes require a
- * background buffer for the conversion.
- *
- * Currently, only compound datatypes require a background buffer.
- *
- * Return: Non-negative on success/Negative on failure
- *
- * Programmer: Quincey Koziol
- * Wednesday, November 29, 2000
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
-static herr_t
-H5T_conv_need_bkg (H5T_t *src, H5T_t *dst, H5T_cdata_t *cdata)
-{
- FUNC_ENTER (H5T_conv_need_bkg, FAIL);
-
- assert(src);
- assert(dst);
- assert(cdata);
-
- /* Compound datatypes need a buffer */
- if (H5T_detect_class(src,H5T_COMPOUND)==TRUE || H5T_detect_class(dst,H5T_COMPOUND)==TRUE)
- cdata->need_bkg = H5T_BKG_YES;
-
- FUNC_LEAVE (SUCCEED);
-}
-
-
-/*-------------------------------------------------------------------------
* Function: H5T_conv_struct_init
*
* Purpose: Initialize the `priv' field of `cdata' with conversion
@@ -1326,7 +1292,8 @@ H5T_conv_struct_init (H5T_t *src, H5T_t *dst, H5T_cdata_t *cdata)
}
/* Check if we need a background buffer */
- H5T_conv_need_bkg (src, dst, cdata);
+ if (H5T_detect_class(src,H5T_COMPOUND)==TRUE || H5T_detect_class(dst,H5T_COMPOUND)==TRUE)
+ cdata->need_bkg = H5T_BKG_YES;
cdata->recalc = FALSE;
FUNC_LEAVE (SUCCEED);
@@ -1438,7 +1405,7 @@ H5T_conv_struct(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, hsize_t nelmts,
HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
}
assert (priv);
- assert (bkg && cdata->need_bkg>=H5T_BKG_TEMP);
+ assert (bkg && cdata->need_bkg);
if (cdata->recalc && H5T_conv_struct_init (src, dst, cdata)<0) {
HRETURN_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL,
@@ -1735,7 +1702,7 @@ H5T_conv_struct_opt(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
priv = (H5T_conv_struct_t *)(cdata->priv);
src2dst = priv->src2dst;
assert(priv);
- assert(bkg && cdata->need_bkg>=H5T_BKG_TEMP);
+ assert(bkg && cdata->need_bkg);
/*
* Insure that members are sorted.
diff --git a/src/H5Tpublic.h b/src/H5Tpublic.h
index 63451d1..b6f9c58 100644
--- a/src/H5Tpublic.h
+++ b/src/H5Tpublic.h
@@ -139,8 +139,7 @@ typedef enum H5T_cmd_t {
/* How is the `bkg' buffer used by the conversion function? */
typedef enum H5T_bkg_t {
H5T_BKG_NO = 0, /*background buffer is not needed, send NULL */
- H5T_BKG_TEMP = 1, /*bkg buffer used as temp storage only */
- H5T_BKG_YES = 2 /*init bkg buf with data before conversion */
+ H5T_BKG_YES = 1 /*init bkg buf with data before conversion */
} H5T_bkg_t;
/* Type conversion client data */