summaryrefslogtreecommitdiffstats
path: root/src/H5Oattribute.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/H5Oattribute.c')
-rw-r--r--src/H5Oattribute.c23
1 files changed, 13 insertions, 10 deletions
diff --git a/src/H5Oattribute.c b/src/H5Oattribute.c
index 9f0f189..f155c94 100644
--- a/src/H5Oattribute.c
+++ b/src/H5Oattribute.c
@@ -849,16 +849,19 @@ H5O_attr_write_cb(H5O_t *oh, H5O_mesg_t *mesg/*in,out*/,
if(NULL == (chk_proxy = H5O_chunk_protect(udata->f, udata->dxpl_id, oh, mesg->chunkno)))
HGOTO_ERROR(H5E_ATTR, H5E_CANTPROTECT, H5_ITER_ERROR, "unable to load object header chunk")
- /* Allocate storage for the message's data, if necessary */
- if(NULL == ((H5A_t *)mesg->native)->shared->data)
- if(NULL == (((H5A_t *)mesg->native)->shared->data = H5FL_BLK_MALLOC(attr_buf, udata->attr->shared->data_size)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, H5_ITER_ERROR, "memory allocation failed")
-
- /* Copy the data into the header message */
- /* (Needs to occur before updating the shared message, or the hash
- * value on the old & new messages will be the same)
- */
- HDmemcpy(((H5A_t *)mesg->native)->shared->data, udata->attr->shared->data, udata->attr->shared->data_size);
+ /* Because the attribute structure is shared now. The only situation that requires
+ * copying the data is when the metadata cache evicts and reloads this attribute.
+ * The shared attribute structure will be different in that situation. SLU-2010/7/29 */
+ if(((H5A_t *)mesg->native)->shared != udata->attr->shared) {
+ /* Sanity check */
+ HDassert(((H5A_t *)mesg->native)->shared->data);
+ HDassert(udata->attr->shared->data);
+ HDassert(((H5A_t *)mesg->native)->shared->data != udata->attr->shared->data);
+
+ /* (Needs to occur before updating the shared message, or the hash
+ * value on the old & new messages will be the same) */
+ HDmemcpy(((H5A_t *)mesg->native)->shared->data, udata->attr->shared->data, udata->attr->shared->data_size);
+ } /* end if */
/* Mark the message as modified */
mesg->dirty = TRUE;