summaryrefslogtreecommitdiffstats
path: root/src/H5A.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2004-11-19 14:57:25 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2004-11-19 14:57:25 (GMT)
commitafebb37a42312abd87076a3505b33e84b333e468 (patch)
tree559133a642c5f1eb32f8c25ae95f527bcfede6e1 /src/H5A.c
parent6ec311b1d32001ec035902ca2c8420ecc216e14d (diff)
downloadhdf5-afebb37a42312abd87076a3505b33e84b333e468.zip
hdf5-afebb37a42312abd87076a3505b33e84b333e468.tar.gz
hdf5-afebb37a42312abd87076a3505b33e84b333e468.tar.bz2
[svn-r9552] Purpose:
Code optimization Description: Avoid making as many copies of attribute information. Also, be smarter about which properties we've seen before when copying and closing property lists. Fix memory leak of attribute data structures. Platforms tested: FreeBSD 4.10 (sleipnir) w/parallel Solaris 2.7 (arabica) Too minor to require h5committest
Diffstat (limited to 'src/H5A.c')
-rw-r--r--src/H5A.c35
1 files changed, 15 insertions, 20 deletions
diff --git a/src/H5A.c b/src/H5A.c
index e264026..1874187 100644
--- a/src/H5A.c
+++ b/src/H5A.c
@@ -362,8 +362,7 @@ H5A_get_index(H5G_entry_t *ent, const char *name, hid_t dxpl_id)
if(HDstrcmp(found_attr.name,name)==0) {
if(H5O_reset (H5O_ATTR_ID, &found_attr)<0)
HGOTO_ERROR(H5E_ATTR, H5E_CANTFREE, FAIL, "can't release attribute info")
- ret_value = i;
- break;
+ HGOTO_DONE(i);
}
if(H5O_reset (H5O_ATTR_ID, &found_attr)<0)
HGOTO_ERROR(H5E_ATTR, H5E_CANTFREE, FAIL, "can't release attribute info")
@@ -522,7 +521,7 @@ H5A_open(H5G_entry_t *ent, unsigned idx, hid_t dxpl_id)
/* Read in attribute with H5O_read() */
H5_CHECK_OVERFLOW(idx,unsigned,int);
- if (NULL==(attr=H5O_read(ent, H5O_ATTR_ID, (int)idx, attr, dxpl_id)))
+ if (NULL==(attr=H5O_read(ent, H5O_ATTR_ID, (int)idx, NULL, dxpl_id)))
HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "unable to load attribute info from dataset header")
attr->initialized=1;
@@ -1228,7 +1227,7 @@ static herr_t
H5A_rename(H5G_entry_t *ent, const char *old_name, const char *new_name, hid_t dxpl_id)
{
int seq, idx=FAIL; /* Index of attribute being querried */
- H5A_t *found_attr; /* Attribute with OLD_NAME */
+ H5A_t found_attr; /* Attribute with OLD_NAME */
herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT(H5A_rename)
@@ -1238,45 +1237,41 @@ H5A_rename(H5G_entry_t *ent, const char *old_name, const char *new_name, hid_t d
assert(old_name);
assert(new_name);
- /* Build the attribute information */
- if((found_attr = H5FL_CALLOC(H5A_t))==NULL)
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for attribute info")
-
/* Read in the existing attributes to check for duplicates */
seq=0;
- while(H5O_read(ent, H5O_ATTR_ID, seq, found_attr, dxpl_id)!=NULL) {
+ while(H5O_read(ent, H5O_ATTR_ID, seq, &found_attr, dxpl_id)!=NULL) {
/*
* Compare found attribute name.
*/
- if(HDstrcmp(found_attr->name,old_name)==0) {
+ if(HDstrcmp(found_attr.name,old_name)==0) {
idx = seq;
break;
}
- if(H5O_reset (H5O_ATTR_ID, found_attr)<0)
+ if(H5O_reset (H5O_ATTR_ID, &found_attr)<0)
HGOTO_ERROR(H5E_ATTR, H5E_CANTFREE, FAIL, "can't release attribute info")
seq++;
}
-
+ H5E_clear_stack(NULL);
if(idx<0)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "attribute cannot be found")
/* Copy the attribute name. */
- if(found_attr->name)
- HDfree(found_attr->name);
- found_attr->name = HDstrdup(new_name);
- if(!found_attr->name)
+ if(found_attr.name)
+ HDfree(found_attr.name);
+ found_attr.name = HDstrdup(new_name);
+ if(!found_attr.name)
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "String copy failed")
/* Indicate entry is not opened and the attribute doesn't need fill-values. */
- found_attr->ent_opened=FALSE;
- found_attr->initialized=TRUE;
+ found_attr.ent_opened=FALSE;
+ found_attr.initialized=TRUE;
/* Modify the attribute message */
- if (H5O_modify(ent, H5O_ATTR_ID, idx, 0, 1, found_attr, dxpl_id) < 0)
+ if (H5O_modify(ent, H5O_ATTR_ID, idx, 0, 1, &found_attr, dxpl_id) < 0)
HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "unable to update attribute header messages")
/* Close the attribute */
- if(H5A_close(found_attr)<0)
+ if(H5A_free(&found_attr)<0)
HGOTO_ERROR(H5E_ATTR, H5E_CANTRELEASE, FAIL, "unable to close renamed attribute")
done: