summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2010-02-20 04:29:08 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2010-02-20 04:29:08 (GMT)
commit2bcb812832616669fc2b34dba25e32f6304b5c46 (patch)
tree86fe443eb4f925bf5afb6662c1007b10d3b6435f /src
parent0c39a78927ae1e4b7471f96743a8cf5dd30350b0 (diff)
downloadhdf5-2bcb812832616669fc2b34dba25e32f6304b5c46.zip
hdf5-2bcb812832616669fc2b34dba25e32f6304b5c46.tar.gz
hdf5-2bcb812832616669fc2b34dba25e32f6304b5c46.tar.bz2
[svn-r18302] Description:
Tweak allocation of attribute tables created from densely stored attributes to allow for better cleanup on errors (like when the type of corruption from Bz#1755 is encountered). Also, add some code to h5dump to display an error message when the attribute iteration for an object fails. Tested on: FreeBSD/32 6.3 (duty) in debug mode FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode Linux/32 2.6 (jam) w/PGI compilers, w/default API=1.8.x, w/C++ & FORTRAN, w/threadsafe, in debug mode Linux/64-amd64 2.6 (amani) w/Intel compilers, w/default API=1.6.x, w/C++ & FORTRAN, in production mode Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN, w/szip filter, in production mode Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN, in production mode Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in debug mode Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in production mode Mac OS X/32 10.6.2 (amazon) in debug mode Mac OS X/32 10.6.2 (amazon) w/C++ & FORTRAN, w/threadsafe, in production mode
Diffstat (limited to 'src')
-rw-r--r--src/H5Aint.c23
1 files changed, 9 insertions, 14 deletions
diff --git a/src/H5Aint.c b/src/H5Aint.c
index 2915502..63f7e60 100644
--- a/src/H5Aint.c
+++ b/src/H5Aint.c
@@ -269,6 +269,10 @@ H5A_dense_build_table_cb(const H5A_t *attr, void *_udata)
HDassert(udata);
HDassert(udata->curr_attr < udata->atable->nattrs);
+ /* Allocate attribute for entry in the table */
+ if(NULL == (udata->atable->attrs[udata->curr_attr] = H5FL_CALLOC(H5A_t)))
+ HGOTO_ERROR(H5E_ATTR, H5E_CANTALLOC, H5_ITER_ERROR, "can't allocate attribute")
+
/* Copy attribute information. Share the attribute object in copying. */
if(NULL == H5A_copy(udata->atable->attrs[udata->curr_attr], attr))
HGOTO_ERROR(H5E_ATTR, H5E_CANTCOPY, H5_ITER_ERROR, "can't copy attribute")
@@ -333,17 +337,11 @@ H5A_dense_build_table(H5F_t *f, hid_t dxpl_id, const H5O_ainfo_t *ainfo,
if(atable->nattrs > 0) {
H5A_dense_bt_ud_t udata; /* User data for iteration callback */
H5A_attr_iter_op_t attr_op; /* Attribute operator */
- unsigned i;
/* Allocate the table to store the attributes */
- if((atable->attrs = (H5A_t **)H5FL_SEQ_MALLOC(H5A_t_ptr, atable->nattrs)) == NULL)
+ if((atable->attrs = (H5A_t **)H5FL_SEQ_CALLOC(H5A_t_ptr, atable->nattrs)) == NULL)
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed")
- /* Allocate pointers for each entry in the table */
- for(i=0; i<atable->nattrs; i++)
- if((atable->attrs[i] = (H5A_t *)H5FL_CALLOC(H5A_t)) == NULL)
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed")
-
/* Set up user data for iteration */
udata.atable = atable;
udata.curr_attr = 0;
@@ -638,15 +636,11 @@ done:
* Programmer: Quincey Koziol
* Dec 11, 2006
*
- * Modification: Raymond Lu
- * 4 June 2008
- * Changed from H5A_free to H5A_close to release attributes.
*-------------------------------------------------------------------------
*/
herr_t
H5A_attr_release_table(H5A_attr_table_t *atable)
{
- size_t u; /* Local index variable */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT(H5A_attr_release_table)
@@ -656,11 +650,12 @@ H5A_attr_release_table(H5A_attr_table_t *atable)
/* Release attribute info, if any. */
if(atable->nattrs > 0) {
+ size_t u; /* Local index variable */
+
/* Free attribute message information */
- for(u = 0; u < atable->nattrs; u++) {
- if(H5A_close((atable->attrs[u])) < 0)
+ for(u = 0; u < atable->nattrs; u++)
+ if(atable->attrs[u] && H5A_close(atable->attrs[u]) < 0)
HGOTO_ERROR(H5E_ATTR, H5E_CANTFREE, FAIL, "unable to release attribute")
- }
} /* end if */
else
HDassert(atable->attrs == NULL);