diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2000-04-04 21:00:31 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2000-04-04 21:00:31 (GMT) |
commit | 02e4ee5edf5d1c8fe285497def5cd7b7afbf77e4 (patch) | |
tree | 4b36327c0da85d62ea116da32d0f114700d0f6c9 /src/H5Ocomp.c | |
parent | 7170bbbc96f2b29f42be53f8271fc359f617e09c (diff) | |
download | hdf5-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/H5Ocomp.c')
-rw-r--r-- | src/H5Ocomp.c | 59 |
1 files changed, 46 insertions, 13 deletions
diff --git a/src/H5Ocomp.c b/src/H5Ocomp.c index f812253..4f1a3e0 100644 --- a/src/H5Ocomp.c +++ b/src/H5Ocomp.c @@ -9,6 +9,7 @@ */ #include <H5private.h> #include <H5Eprivate.h> +#include <H5FLprivate.h> /*Free Lists */ #include <H5MMprivate.h> #include <H5Oprivate.h> @@ -24,6 +25,7 @@ static void *H5O_pline_decode (H5F_t *f, const uint8_t *p, H5O_shared_t *sh); static void *H5O_pline_copy (const void *_mesg, void *_dest); static size_t H5O_pline_size (H5F_t *f, const void *_mesg); static herr_t H5O_pline_reset (void *_mesg); +static herr_t H5O_pline_free (void *_mesg); static herr_t H5O_pline_debug (H5F_t *f, const void *_mesg, FILE * stream, intn indent, intn fwidth); @@ -37,12 +39,16 @@ const H5O_class_t H5O_PLINE[1] = {{ H5O_pline_copy, /* copy the native value */ H5O_pline_size, /* size of raw message */ H5O_pline_reset, /* reset method */ + H5O_pline_free, /* free method */ NULL, /* get share method */ NULL, /* set share method */ H5O_pline_debug, /* debug the message */ }}; +/* Declare a free list to manage the H5O_pline_t struct */ +H5FL_DEFINE(H5O_pline_t); + /*------------------------------------------------------------------------- * Function: H5O_pline_decode @@ -75,7 +81,7 @@ H5O_pline_decode(H5F_t UNUSED *f, const uint8_t *p, assert(p); /* Decode */ - if (NULL==(pline = H5MM_calloc(sizeof *pline))) { + if (NULL==(pline = H5FL_ALLOC(H5O_pline_t,1))) { HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); } @@ -137,14 +143,14 @@ H5O_pline_decode(H5F_t UNUSED *f, const uint8_t *p, done: if (NULL==ret_value && pline) { - if (pline->filter) { - for (i=0; i<pline->nfilters; i++) { - H5MM_xfree(pline->filter[i].name); - H5MM_xfree(pline->filter[i].cd_values); - } - H5MM_xfree(pline->filter); - } - H5MM_xfree(pline); + if (pline->filter) { + for (i=0; i<pline->nfilters; i++) { + H5MM_xfree(pline->filter[i].name); + H5MM_xfree(pline->filter[i].cd_values); + } + H5MM_xfree(pline->filter); + } + H5FL_FREE(H5O_pline_t,pline); } FUNC_LEAVE(ret_value); } @@ -249,7 +255,7 @@ H5O_pline_copy (const void *_src, void *_dst/*out*/) FUNC_ENTER (H5O_pline_copy, NULL); - if (!dst && NULL==(dst = H5MM_malloc (sizeof *dst))) { + if (!dst && NULL==(dst = H5FL_ALLOC (H5O_pline_t,0))) { HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); } @@ -293,7 +299,7 @@ H5O_pline_copy (const void *_src, void *_dst/*out*/) } H5MM_xfree(dst->filter); } - if (!_dst) H5MM_xfree(dst); + if (!_dst) H5FL_FREE(H5O_pline_t,dst); } FUNC_LEAVE (ret_value); @@ -379,8 +385,8 @@ H5O_pline_reset (void *mesg) assert (pline); for (i=0; i<pline->nfilters; i++) { - H5MM_xfree(pline->filter[i].name); - H5MM_xfree(pline->filter[i].cd_values); + H5MM_xfree(pline->filter[i].name); + H5MM_xfree(pline->filter[i].cd_values); } H5MM_xfree(pline->filter); HDmemset(pline, 0, sizeof *pline); @@ -390,6 +396,33 @@ H5O_pline_reset (void *mesg) /*------------------------------------------------------------------------- + * Function: H5O_pline_free + * + * Purpose: Free's the message + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * Saturday, March 11, 2000 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static herr_t +H5O_pline_free (void *mesg) +{ + FUNC_ENTER (H5O_pline_free, FAIL); + + assert (mesg); + + H5FL_FREE(H5O_pline_t,mesg); + + FUNC_LEAVE (SUCCEED); +} + + +/*------------------------------------------------------------------------- * Function: H5O_pline_debug * * Purpose: Prints debugging information for filter pipeline message MESG |