summaryrefslogtreecommitdiffstats
path: root/src/H5Ocont.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/H5Ocont.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/H5Ocont.c')
-rw-r--r--src/H5Ocont.c37
1 files changed, 35 insertions, 2 deletions
diff --git a/src/H5Ocont.c b/src/H5Ocont.c
index 12e5ee7..79da2f7 100644
--- a/src/H5Ocont.c
+++ b/src/H5Ocont.c
@@ -32,6 +32,7 @@
#include "H5private.h"
#include "H5Eprivate.h"
+#include "H5FLprivate.h" /* Free Lists */
#include "H5MMprivate.h"
#include "H5Opkg.h" /* Object header functions */
@@ -40,6 +41,7 @@
/* PRIVATE PROTOTYPES */
static void *H5O_cont_decode(H5F_t *f, hid_t dxpl_id, const uint8_t *p, H5O_shared_t *sh);
static herr_t H5O_cont_encode(H5F_t *f, uint8_t *p, const void *_mesg);
+static herr_t H5O_cont_free (void *mesg);
static herr_t H5O_cont_debug(H5F_t *f, hid_t dxpl_id, const void *_mesg, FILE * stream,
int indent, int fwidth);
@@ -53,7 +55,7 @@ const H5O_class_t H5O_CONT[1] = {{
NULL, /*no copy method */
NULL, /*no size method */
NULL, /*reset method */
- NULL, /* free method */
+ H5O_cont_free, /* free method */
NULL, /* file delete method */
NULL, /* link method */
NULL, /*get share method */
@@ -61,6 +63,9 @@ const H5O_class_t H5O_CONT[1] = {{
H5O_cont_debug, /*debugging */
}};
+/* Declare the free list for H5O_cont_t's */
+H5FL_DEFINE(H5O_cont_t);
+
/*-------------------------------------------------------------------------
* Function: H5O_cont_decode
@@ -93,10 +98,11 @@ H5O_cont_decode(H5F_t *f, hid_t UNUSED dxpl_id, const uint8_t *p, H5O_shared_t U
assert (!sh);
/* decode */
- if (NULL==(cont = H5MM_calloc(sizeof(H5O_cont_t))))
+ if (NULL==(cont = H5FL_MALLOC(H5O_cont_t)))
HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
H5F_addr_decode(f, &p, &(cont->addr));
H5F_DECODE_LENGTH(f, p, cont->size);
+ cont->chunkno=0;
/* Set return value */
ret_value=cont;
@@ -142,6 +148,33 @@ H5O_cont_encode(H5F_t *f, uint8_t *p, const void *_mesg)
/*-------------------------------------------------------------------------
+ * Function: H5O_cont_free
+ *
+ * Purpose: Free's the message
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: Quincey Koziol
+ * Monday, November 15, 2004
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+H5O_cont_free (void *mesg)
+{
+ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_cont_free);
+
+ assert (mesg);
+
+ H5FL_FREE(H5O_cont_t,mesg);
+
+ FUNC_LEAVE_NOAPI(SUCCEED);
+} /* end H5O_cont_free() */
+
+
+/*-------------------------------------------------------------------------
* Function: H5O_cont_debug
*
* Purpose: Prints debugging info.