diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2010-02-20 04:36:27 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2010-02-20 04:36:27 (GMT) |
commit | e51e5cea3f3a6d412202f39b2834901ee375caa1 (patch) | |
tree | fac34f56c495b7af8cb2702cea0f8db8954395ac /src | |
parent | 8a9eb9fdcdbb01f18d40ad100ce38ba1d5515a26 (diff) | |
download | hdf5-e51e5cea3f3a6d412202f39b2834901ee375caa1.zip hdf5-e51e5cea3f3a6d412202f39b2834901ee375caa1.tar.gz hdf5-e51e5cea3f3a6d412202f39b2834901ee375caa1.tar.bz2 |
[svn-r18303] Description:
Bring r18302 from trunk to 1.8 branch:
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:
Mac OS X/32 10.6.2 (amazon) w/debug & production
(h5committested on trunk)
Diffstat (limited to 'src')
-rw-r--r-- | src/H5Aint.c | 23 |
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); |