summaryrefslogtreecommitdiffstats
path: root/src/H5Omtime.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2000-04-04 21:00:31 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2000-04-04 21:00:31 (GMT)
commit02e4ee5edf5d1c8fe285497def5cd7b7afbf77e4 (patch)
tree4b36327c0da85d62ea116da32d0f114700d0f6c9 /src/H5Omtime.c
parent7170bbbc96f2b29f42be53f8271fc359f617e09c (diff)
downloadhdf5-02e4ee5edf5d1c8fe285497def5cd7b7afbf77e4.zip
hdf5-02e4ee5edf5d1c8fe285497def5cd7b7afbf77e4.tar.gz
hdf5-02e4ee5edf5d1c8fe285497def5cd7b7afbf77e4.tar.bz2
[svn-r2073] Added free-list code to the library and took out the older "temporary buffer"
code, since the functionality was superceded. See the followup document for details on the free-list code.
Diffstat (limited to 'src/H5Omtime.c')
-rw-r--r--src/H5Omtime.c39
1 files changed, 36 insertions, 3 deletions
diff --git a/src/H5Omtime.c b/src/H5Omtime.c
index e16b283..fc57f58 100644
--- a/src/H5Omtime.c
+++ b/src/H5Omtime.c
@@ -9,6 +9,7 @@
*/
#include <H5private.h>
#include <H5Eprivate.h>
+#include <H5FLprivate.h> /*Free Lists */
#include <H5MMprivate.h>
#include <H5Oprivate.h>
@@ -18,6 +19,7 @@ static void *H5O_mtime_decode(H5F_t *f, const uint8_t *p, H5O_shared_t *sh);
static herr_t H5O_mtime_encode(H5F_t *f, uint8_t *p, const void *_mesg);
static void *H5O_mtime_copy(const void *_mesg, void *_dest);
static size_t H5O_mtime_size(H5F_t *f, const void *_mesg);
+static herr_t H5O_mtime_free (void *_mesg);
static herr_t H5O_mtime_debug(H5F_t *f, const void *_mesg, FILE *stream,
intn indent, intn fwidth);
@@ -31,6 +33,7 @@ const H5O_class_t H5O_MTIME[1] = {{
H5O_mtime_copy, /*copy the native value */
H5O_mtime_size, /*raw message size */
NULL, /*free internal memory */
+ H5O_mtime_free, /* free method */
NULL, /*get share method */
NULL, /*set share method */
H5O_mtime_debug, /*debug the message */
@@ -40,6 +43,9 @@ const H5O_class_t H5O_MTIME[1] = {{
static intn interface_initialize_g = 0;
#define INTERFACE_INIT NULL
+/* Declare a free list to manage the time_t struct */
+H5FL_DEFINE(time_t);
+
/*-------------------------------------------------------------------------
* Function: H5O_mtime_decode
@@ -149,7 +155,7 @@ H5O_mtime_decode(H5F_t UNUSED *f, const uint8_t *p,
#endif
/* The return value */
- if (NULL==(mesg = H5MM_calloc(sizeof(time_t)))) {
+ if (NULL==(mesg = H5FL_ALLOC(time_t,1))) {
HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
"memory allocation failed");
}
@@ -226,8 +232,8 @@ H5O_mtime_copy(const void *_mesg, void *_dest)
/* check args */
assert(mesg);
- if (!dest && NULL==(dest = H5MM_calloc(sizeof(time_t)))) {
- HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
+ if (!dest && NULL==(dest = H5FL_ALLOC(time_t,0))) {
+ HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
"memory allocation failed");
}
@@ -271,6 +277,33 @@ H5O_mtime_size(H5F_t UNUSED *f, const void UNUSED *mesg)
/*-------------------------------------------------------------------------
+ * Function: H5O_mtime_free
+ *
+ * Purpose: Free's the message
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: Quincey Koziol
+ * Thursday, March 30, 2000
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+H5O_mtime_free (void *mesg)
+{
+ FUNC_ENTER (H5O_mtime_free, FAIL);
+
+ assert (mesg);
+
+ H5FL_FREE(time_t,mesg);
+
+ FUNC_LEAVE (SUCCEED);
+}
+
+
+/*-------------------------------------------------------------------------
* Function: H5O_mtime_debug
*
* Purpose: Prints debugging info for the message.