summaryrefslogtreecommitdiffstats
path: root/src/H5Oattr.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2004-11-17 16:53:38 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2004-11-17 16:53:38 (GMT)
commit1878ad9c2cc038e1739887b12a26512daf76eefc (patch)
tree948052b3e450ede9f30c2c4db7ba6e6f0657bc53 /src/H5Oattr.c
parent94b852d15a0e2a52251071929e451ea7af414108 (diff)
downloadhdf5-1878ad9c2cc038e1739887b12a26512daf76eefc.zip
hdf5-1878ad9c2cc038e1739887b12a26512daf76eefc.tar.gz
hdf5-1878ad9c2cc038e1739887b12a26512daf76eefc.tar.bz2
[svn-r9537] Purpose:
Code cleanup & optimizations Description: Clean up some of the code in attributes to avoid allocating memory and performing type conversions when the conversion is a noop. Avoid memory allocations of attribute data structures by switching to use library's free list memory allocator routines. Avoid memory allocations of object header continuation data structures by switching to use library's free list memory allocator routines. Rearrange threaded, balanced binary tree macros slightly to avoid some overhead. 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.c25
1 files changed, 8 insertions, 17 deletions
diff --git a/src/H5Oattr.c b/src/H5Oattr.c
index 1493403..79262b4 100644
--- a/src/H5Oattr.c
+++ b/src/H5Oattr.c
@@ -67,6 +67,9 @@ const H5O_class_t H5O_ATTR[1] = {{
/* Flags for attribute flag encoding */
#define H5O_ATTR_FLAG_TYPE_SHARED 0x01
+/* Declare extern the free list for H5A_t's */
+H5FL_EXTERN(H5A_t);
+
/* Declare external the free list for H5S_t's */
H5FL_EXTERN(H5S_t);
@@ -118,7 +121,7 @@ H5O_attr_decode(H5F_t *f, hid_t dxpl_id, const uint8_t *p, H5O_shared_t UNUSED *
assert(f);
assert(p);
- if (NULL==(attr = H5MM_calloc(sizeof(H5A_t))))
+ if (NULL==(attr = H5FL_CALLOC(H5A_t)))
HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
/* Version number */
@@ -141,9 +144,8 @@ H5O_attr_decode(H5F_t *f, hid_t dxpl_id, const uint8_t *p, H5O_shared_t UNUSED *
UINT16DECODE(p, attr->ds_size);
/* Decode and store the name */
- if (NULL==(attr->name=H5MM_malloc(name_len)))
+ if (NULL==(attr->name=H5MM_strdup((const char *)p)))
HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
- HDmemcpy(attr->name,p,name_len);
if(version < H5O_ATTR_VERSION_NEW)
p += H5O_ALIGN(name_len); /* advance the memory pointer */
else
@@ -378,14 +380,8 @@ H5O_attr_copy(const void *_src, void *_dst)
assert(src);
/* copy */
- if (NULL == (dst = H5A_copy(src)))
+ if (NULL == (dst = H5A_copy(_dst,src)))
HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, NULL, "can't copy attribute");
- /* was result already allocated? */
- if (_dst) {
- *((H5A_t *) _dst) = *dst;
- H5MM_xfree(dst);
- dst = (H5A_t *) _dst;
- }
/* Set return value */
ret_value=dst;
@@ -491,13 +487,8 @@ H5O_attr_reset(void *_mesg)
FUNC_ENTER_NOAPI_NOINIT(H5O_attr_reset);
- if (attr) {
- if (NULL==(tmp = H5MM_malloc(sizeof(H5A_t))))
- HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed");
- HDmemcpy(tmp,attr,sizeof(H5A_t));
- H5A_close(tmp);
- HDmemset(attr, 0, sizeof(H5A_t));
- }
+ if (attr)
+ H5A_free(attr);
done:
FUNC_LEAVE_NOAPI(ret_value);