summaryrefslogtreecommitdiffstats
path: root/src/H5T.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/H5T.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/H5T.c')
-rw-r--r--src/H5T.c72
1 files changed, 38 insertions, 34 deletions
diff --git a/src/H5T.c b/src/H5T.c
index 39459f5..d6d9a86 100644
--- a/src/H5T.c
+++ b/src/H5T.c
@@ -15,6 +15,7 @@ static char RcsId[] = "@(#)$Revision$";
#include <H5Dprivate.h> /*datasets (for H5Tcopy) */
#include <H5Iprivate.h> /*ID functions */
#include <H5Eprivate.h> /*error handling */
+#include <H5FLprivate.h> /*Free Lists */
#include <H5Gprivate.h> /*groups */
#include <H5HGprivate.h> /*global heap */
#include <H5MMprivate.h> /*memory management */
@@ -196,8 +197,12 @@ static struct {
/* The overflow handler */
H5T_overflow_t H5T_overflow_g = NULL;
+/* Local static functions */
static herr_t H5T_print_stats(H5T_path_t *path, intn *nprint/*in,out*/);
+/* Declare the free list for H5T_t's */
+H5FL_DEFINE(H5T_t);
+
/*-------------------------------------------------------------------------
* Function: H5T_init
@@ -458,7 +463,7 @@ H5T_init_interface(void)
dt->u.atomic.prec = 64;
/* Opaque data */
- if (NULL==(dt = H5MM_calloc(sizeof(H5T_t)))) {
+ if (NULL==(dt = H5FL_ALLOC(H5T_t,1))) {
HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
"memory allocation failed");
}
@@ -840,7 +845,7 @@ H5T_init_interface(void)
*/
/* One-byte character string */
- if (NULL==(dt = H5MM_calloc(sizeof(H5T_t)))) {
+ if (NULL==(dt = H5FL_ALLOC(H5T_t,1))) {
HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
"memory allocation failed");
}
@@ -866,7 +871,7 @@ H5T_init_interface(void)
*/
/* One-byte character string */
- if (NULL==(dt = H5MM_calloc(sizeof(H5T_t)))) {
+ if (NULL==(dt = H5FL_ALLOC(H5T_t,1))) {
HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
"memory allocation failed");
}
@@ -892,7 +897,7 @@ H5T_init_interface(void)
*/
/* Object pointer (i.e. object header address in file) */
- if (NULL==(dt = H5MM_calloc(sizeof(H5T_t)))) {
+ if (NULL==(dt = H5FL_ALLOC(H5T_t,1))) {
HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
"memory allocation failed");
}
@@ -912,7 +917,7 @@ H5T_init_interface(void)
}
/* Dataset Region pointer (i.e. selection inside a dataset) */
- if (NULL==(dt = H5MM_calloc(sizeof(H5T_t)))) {
+ if (NULL==(dt = H5FL_ALLOC(H5T_t,1))) {
HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
"memory allocation failed");
}
@@ -3620,7 +3625,7 @@ H5Tenum_create(hid_t parent_id)
}
/* Build new type */
- if (NULL==(dt=H5MM_calloc(sizeof(H5T_t)))) {
+ if (NULL==(dt = H5FL_ALLOC(H5T_t,1))) {
HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL,
"memory allocation failed");
}
@@ -3926,7 +3931,7 @@ H5Tvlen_create(hid_t base_id)
}
/* Build new type */
- if (NULL==(dt=H5MM_calloc(sizeof(H5T_t)))) {
+ if (NULL==(dt = H5FL_ALLOC(H5T_t,1))) {
HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL,
"memory allocation failed");
}
@@ -4584,7 +4589,7 @@ H5T_create(H5T_class_t type, size_t size)
case H5T_OPAQUE:
case H5T_COMPOUND:
- if (NULL==(dt = H5MM_calloc(sizeof(H5T_t)))) {
+ if (NULL==(dt = H5FL_ALLOC(H5T_t,1))) {
HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
"memory allocation failed");
}
@@ -4606,14 +4611,14 @@ H5T_create(H5T_class_t type, size_t size)
HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL,
"no applicable native integer type");
}
- if (NULL==(dt = H5MM_calloc(sizeof(H5T_t)))) {
+ if (NULL==(dt = H5FL_ALLOC(H5T_t,1))) {
HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL,
"memory allocation failed");
}
dt->type = type;
if (NULL==(dt->parent=H5T_copy(H5I_object(subtype),
H5T_COPY_ALL))) {
- H5MM_xfree(dt);
+ H5FL_FREE(H5T_t,dt);
HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL,
"unable to copy base data type");
}
@@ -4801,7 +4806,7 @@ H5T_copy(const H5T_t *old_dt, H5T_copy_t method)
assert(old_dt);
/* copy */
- if (NULL==(new_dt = H5MM_calloc(sizeof(H5T_t)))) {
+ if (NULL==(new_dt = H5FL_ALLOC(H5T_t,0))) {
HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
"memory allocation failed");
}
@@ -4841,7 +4846,7 @@ H5T_copy(const H5T_t *old_dt, H5T_copy_t method)
*/
if (H5F_addr_defined(new_dt->ent.header)) {
if (H5O_open (&(new_dt->ent))<0) {
- H5MM_xfree (new_dt);
+ H5FL_FREE (H5T_t,new_dt);
HRETURN_ERROR (H5E_DATATYPE, H5E_CANTOPENOBJ, NULL,
"unable to reopen named data type");
}
@@ -5099,33 +5104,32 @@ H5T_close(H5T_t *dt)
/* Close the datatype */
switch (dt->type) {
- case H5T_COMPOUND:
- for (i=0; i<dt->u.compnd.nmembs; i++) {
- H5MM_xfree(dt->u.compnd.memb[i].name);
- H5T_close(dt->u.compnd.memb[i].type);
- }
- H5MM_xfree(dt->u.compnd.memb);
- H5MM_xfree(dt);
- break;
+ case H5T_COMPOUND:
+ for (i=0; i<dt->u.compnd.nmembs; i++) {
+ H5MM_xfree(dt->u.compnd.memb[i].name);
+ H5T_close(dt->u.compnd.memb[i].type);
+ }
+ H5MM_xfree(dt->u.compnd.memb);
+ break;
- case H5T_ENUM:
- for (i=0; i<dt->u.enumer.nmembs; i++) {
- H5MM_xfree(dt->u.enumer.name[i]);
- }
- H5MM_xfree(dt->u.enumer.name);
- H5MM_xfree(dt->u.enumer.value);
- H5MM_xfree(dt);
- break;
+ case H5T_ENUM:
+ for (i=0; i<dt->u.enumer.nmembs; i++)
+ H5MM_xfree(dt->u.enumer.name[i]);
+ H5MM_xfree(dt->u.enumer.name);
+ H5MM_xfree(dt->u.enumer.value);
+ break;
- case H5T_OPAQUE:
- H5MM_xfree(dt->u.opaque.tag);
- H5MM_xfree(dt);
- break;
+ case H5T_OPAQUE:
+ H5MM_xfree(dt->u.opaque.tag);
+ break;
- default:
- H5MM_xfree(dt);
+ default:
+ break;
}
+ /* Free the datatype struct */
+ H5FL_FREE(H5T_t,dt);
+
/* Close the parent */
if (parent && H5T_close(parent)<0) {
HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL,