summaryrefslogtreecommitdiffstats
path: root/src/H5Oattr.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2004-11-19 14:57:30 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2004-11-19 14:57:30 (GMT)
commit3a0a5df0d2c92306e863abac1bd544a44f57da77 (patch)
treee2079647dc57e7d1d35cb4dddba9709467894b5f /src/H5Oattr.c
parent8bf670baf64e0e6038e43c7f4473b84a758dcc2c (diff)
downloadhdf5-3a0a5df0d2c92306e863abac1bd544a44f57da77.zip
hdf5-3a0a5df0d2c92306e863abac1bd544a44f57da77.tar.gz
hdf5-3a0a5df0d2c92306e863abac1bd544a44f57da77.tar.bz2
[svn-r9553] 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/H5Oattr.c')
-rw-r--r--src/H5Oattr.c38
1 files changed, 30 insertions, 8 deletions
diff --git a/src/H5Oattr.c b/src/H5Oattr.c
index e647743..bb22f70 100644
--- a/src/H5Oattr.c
+++ b/src/H5Oattr.c
@@ -35,6 +35,7 @@ static void *H5O_attr_decode (H5F_t *f, hid_t dxpl_id, const uint8_t *p, H5O_sha
static void *H5O_attr_copy (const void *_mesg, void *_dest);
static size_t H5O_attr_size (H5F_t *f, const void *_mesg);
static herr_t H5O_attr_reset (void *_mesg);
+static herr_t H5O_attr_free (void *mesg);
static herr_t H5O_attr_delete (H5F_t *f, hid_t dxpl_id, const void *_mesg);
static herr_t H5O_attr_link(H5F_t *f, hid_t dxpl_id, const void *_mesg);
static herr_t H5O_attr_debug (H5F_t *f, hid_t dxpl_id, const void *_mesg,
@@ -50,7 +51,7 @@ const H5O_class_t H5O_ATTR[1] = {{
H5O_attr_copy, /* copy the native value */
H5O_attr_size, /* size of raw message */
H5O_attr_reset, /* reset method */
- NULL, /* free method */
+ H5O_attr_free, /* free method */
H5O_attr_delete, /* file delete method */
H5O_attr_link, /* link method */
NULL, /* get share method */
@@ -375,7 +376,6 @@ static void *
H5O_attr_copy(const void *_src, void *_dst)
{
const H5A_t *src = (const H5A_t *) _src;
- H5A_t *dst = NULL;
void *ret_value; /* Return value */
FUNC_ENTER_NOAPI_NOINIT(H5O_attr_copy);
@@ -384,12 +384,9 @@ H5O_attr_copy(const void *_src, void *_dst)
assert(src);
/* copy */
- if (NULL == (dst = H5A_copy(_dst,src)))
+ if (NULL == (ret_value = H5A_copy(_dst,src)))
HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, NULL, "can't copy attribute");
- /* Set return value */
- ret_value=dst;
-
done:
FUNC_LEAVE_NOAPI(ret_value);
}
@@ -486,7 +483,6 @@ static herr_t
H5O_attr_reset(void *_mesg)
{
H5A_t *attr = (H5A_t *) _mesg;
- H5A_t *tmp = NULL;
herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT(H5O_attr_reset);
@@ -494,12 +490,38 @@ H5O_attr_reset(void *_mesg)
if (attr)
H5A_free(attr);
-done:
FUNC_LEAVE_NOAPI(ret_value);
}
/*-------------------------------------------------------------------------
+ * Function: H5O_attr_free
+ *
+ * Purpose: Free's the message
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: Quincey Koziol
+ * Thursday, November 18, 2004
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+H5O_attr_free (void *mesg)
+{
+ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_attr_free);
+
+ assert (mesg);
+
+ H5FL_FREE(H5A_t,mesg);
+
+ FUNC_LEAVE_NOAPI(SUCCEED);
+} /* end H5O_attr_free() */
+
+
+/*-------------------------------------------------------------------------
* Function: H5O_attr_delete
*
* Purpose: Free file space referenced by message