diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2007-01-06 20:54:19 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2007-01-06 20:54:19 (GMT) |
commit | 327ea3a76678ed2f92b0eb72df36c1d02651c2be (patch) | |
tree | 14b77bf71608596fc45fea60445e7d4c1559a247 /src/H5Oattribute.c | |
parent | d6c27d4b4d82d794e860770f5903e84511596d19 (diff) | |
download | hdf5-327ea3a76678ed2f92b0eb72df36c1d02651c2be.zip hdf5-327ea3a76678ed2f92b0eb72df36c1d02651c2be.tar.gz hdf5-327ea3a76678ed2f92b0eb72df36c1d02651c2be.tar.bz2 |
[svn-r13116] Description:
Add support for deleting all the attributes on an object, when they
are dense and possibly shared.
Also, add some testing routines, for better error detection.
Should fix daily test failures also...
Tested on:
FreeBSD/32 6.1 (duty)
Diffstat (limited to 'src/H5Oattribute.c')
-rw-r--r-- | src/H5Oattribute.c | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/src/H5Oattribute.c b/src/H5Oattribute.c index b3b19d4..287f5c6 100644 --- a/src/H5Oattribute.c +++ b/src/H5Oattribute.c @@ -1142,10 +1142,6 @@ H5O_attr_remove_cb(H5O_t *oh, H5O_mesg_t *mesg/*in,out*/, if(NULL == H5O_shared_read(udata->f, udata->dxpl_id, (const H5O_shared_t *)mesg->native, H5O_MSG_ATTR, &shared_attr)) HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, H5_ITER_ERROR, "unable to read shared attribute") -/* XXX: fix me */ -HDfprintf(stderr, "%s: removing a shared attribute not supported yet!\n", FUNC); -HGOTO_ERROR(H5E_ATTR, H5E_UNSUPPORTED, FAIL, "deleting a shared attribute not supported yet") -#ifdef NOT_YET /* Check for correct attribute message to modify */ if(HDstrcmp(shared_attr.name, udata->name) == 0) /* Indicate that this message is the attribute to be deleted */ @@ -1153,7 +1149,6 @@ HGOTO_ERROR(H5E_ATTR, H5E_UNSUPPORTED, FAIL, "deleting a shared attribute not su /* Release copy of shared attribute */ H5O_attr_reset(&shared_attr); -#endif /* NOT_YET */ } /* end if */ else { /* Check for correct attribute message to modify */ @@ -1275,15 +1270,22 @@ H5O_attr_remove(const H5O_loc_t *loc, const char *name, hid_t dxpl_id) /* If ok, insert attributes as object header messages */ if(can_convert) { - /* Insert attribute messages into object header */ - /* (Set the "shared" message flag for all attributes added - - * attributes that are actually shared will be converted - * to shared messages and attributes that are not shared - * will have the flag turned off -QAK) - */ - for(u = 0; u < oh->nattrs; u++) - if(H5O_msg_append_real(loc->file, dxpl_id, oh, H5O_MSG_ATTR, H5O_MSG_FLAG_SHARED, H5O_UPDATE_TIME, &(atable.attrs[u]), &oh_flags) < 0) + /* Iterate over attributes, to put them into header */ + for(u = 0; u < oh->nattrs; u++) { + htri_t shared_mesg; /* Should this message be stored in the Shared Message table? */ + unsigned mesg_flags = 0; /* Message flags for attribute */ + + /* Should this message be written as a SOHM? */ + if((shared_mesg = H5SM_try_share(loc->file, dxpl_id, H5O_ATTR_ID, &(atable.attrs[u]))) > 0) + /* Mark the message as shared */ + mesg_flags |= H5O_MSG_FLAG_SHARED; + else if(shared_mesg < 0) + HGOTO_ERROR(H5E_OHDR, H5E_WRITEERROR, FAIL, "error determining if message should be shared") + + /* Insert attribute message into object header */ + if(H5O_msg_append_real(loc->file, dxpl_id, oh, H5O_MSG_ATTR, mesg_flags, H5O_UPDATE_TIME, &(atable.attrs[u]), &oh_flags) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "can't create message") + } /* end for */ /* Remove the dense storage */ if(H5A_dense_delete(loc->file, dxpl_id, oh) < 0) |