summaryrefslogtreecommitdiffstats
path: root/src/H5P.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/H5P.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/H5P.c')
-rw-r--r--src/H5P.c316
1 files changed, 176 insertions, 140 deletions
diff --git a/src/H5P.c b/src/H5P.c
index de523ce..441ab53 100644
--- a/src/H5P.c
+++ b/src/H5P.c
@@ -23,6 +23,7 @@ static char RcsId[] = "@(#)$Revision$";
#include <H5Dprivate.h> /* Datasets */
#include <H5Eprivate.h> /* Error handling */
#include <H5FDprivate.h> /* File drivers */
+#include <H5FLprivate.h> /* Free Lists */
#include <H5MMprivate.h> /* Memory management */
#include <H5Pprivate.h> /* Property lists */
@@ -36,6 +37,21 @@ static intn interface_initialize_g = 0;
#define INTERFACE_INIT H5P_init_interface
static herr_t H5P_init_interface(void);
+/* Declare a free list to manage the H5F_create_t struct */
+H5FL_DEFINE_STATIC(H5F_create_t);
+
+/* Declare a free list to manage the H5F_access_t struct */
+H5FL_DEFINE_STATIC(H5F_access_t);
+
+/* Declare a free list to manage the H5D_create_t struct */
+H5FL_DEFINE_STATIC(H5D_create_t);
+
+/* Declare a free list to manage the H5F_xfer_t struct */
+H5FL_DEFINE_STATIC(H5F_xfer_t);
+
+/* Declare a free list to manage the H5F_mprop_t struct */
+H5FL_DEFINE_STATIC(H5F_mprop_t);
+
/*--------------------------------------------------------------------------
NAME
H5P_init_interface -- Initialize interface-specific information
@@ -158,23 +174,23 @@ H5Pcreate(H5P_class_t type)
/* Allocate a new property list and initialize it with default values */
switch (type) {
- case H5P_FILE_CREATE:
- src = &H5F_create_dflt;
- break;
- case H5P_FILE_ACCESS:
- src = &H5F_access_dflt;
- break;
- case H5P_DATASET_CREATE:
- src = &H5D_create_dflt;
- break;
- case H5P_DATA_XFER:
- src = &H5F_xfer_dflt;
- break;
- case H5P_MOUNT:
- src = &H5F_mount_dflt;
- break;
- default:
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL,
+ case H5P_FILE_CREATE:
+ src = &H5F_create_dflt;
+ break;
+ case H5P_FILE_ACCESS:
+ src = &H5F_access_dflt;
+ break;
+ case H5P_DATASET_CREATE:
+ src = &H5D_create_dflt;
+ break;
+ case H5P_DATA_XFER:
+ src = &H5F_xfer_dflt;
+ break;
+ case H5P_MOUNT:
+ src = &H5F_mount_dflt;
+ break;
+ default:
+ HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL,
"unknown property list class");
}
@@ -309,45 +325,46 @@ H5P_close(H5P_class_t type, void *plist)
/* Some property lists may need to do special things */
switch (type) {
- case H5P_FILE_ACCESS:
- if (fa_list->driver_id>=0) {
- H5FD_fapl_free(fa_list->driver_id, fa_list->driver_info);
- H5I_dec_ref(fa_list->driver_id);
- fa_list->driver_info = NULL;
- fa_list->driver_id = -1;
- }
- break;
-
- case H5P_FILE_CREATE:
- /*nothing to do*/
- break;
-
- case H5P_DATASET_CREATE:
- H5O_reset(H5O_FILL, &(dc_list->fill));
- H5O_reset(H5O_EFL, &(dc_list->efl));
- H5O_reset(H5O_PLINE, &(dc_list->pline));
- break;
-
- case H5P_DATA_XFER:
- if (dx_list->driver_id>=0) {
- H5FD_dxpl_free(dx_list->driver_id, dx_list->driver_info);
- H5I_dec_ref(dx_list->driver_id);
- dx_list->driver_info = NULL;
- dx_list->driver_id = -1;
- }
- break;
-
- case H5P_MOUNT:
- /*nothing to do*/
- break;
-
- default:
- HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL,
- "unknown property list class");
+ case H5P_FILE_ACCESS:
+ if (fa_list->driver_id>=0) {
+ H5FD_fapl_free(fa_list->driver_id, fa_list->driver_info);
+ H5I_dec_ref(fa_list->driver_id);
+ fa_list->driver_info = NULL;
+ fa_list->driver_id = -1;
+ }
+ H5FL_FREE(H5F_access_t,plist);
+ break;
+
+ case H5P_FILE_CREATE:
+ H5FL_FREE(H5F_create_t,plist);
+ break;
+
+ case H5P_DATASET_CREATE:
+ H5O_reset(H5O_FILL, &(dc_list->fill));
+ H5O_reset(H5O_EFL, &(dc_list->efl));
+ H5O_reset(H5O_PLINE, &(dc_list->pline));
+ H5FL_FREE(H5D_create_t,plist);
+ break;
+
+ case H5P_DATA_XFER:
+ if (dx_list->driver_id>=0) {
+ H5FD_dxpl_free(dx_list->driver_id, dx_list->driver_info);
+ H5I_dec_ref(dx_list->driver_id);
+ dx_list->driver_info = NULL;
+ dx_list->driver_id = -1;
+ }
+ H5FL_FREE(H5F_xfer_t,plist);
+ break;
+
+ case H5P_MOUNT:
+ H5FL_FREE(H5F_mprop_t,plist);
+ break;
+
+ default:
+ HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL,
+ "unknown property list class");
}
- /* Free the property list struct and return */
- H5MM_xfree(plist);
FUNC_LEAVE(SUCCEED);
}
@@ -2614,96 +2631,115 @@ H5P_copy (H5P_class_t type, const void *src)
/* How big is the property list */
switch (type) {
- case H5P_FILE_CREATE:
- size = sizeof(H5F_create_t);
- break;
-
- case H5P_FILE_ACCESS:
- size = sizeof(H5F_access_t);
- break;
-
- case H5P_DATASET_CREATE:
- size = sizeof(H5D_create_t);
- break;
-
- case H5P_DATA_XFER:
- size = sizeof(H5F_xfer_t);
- break;
-
- case H5P_MOUNT:
- size = sizeof(H5F_mprop_t);
- break;
-
- default:
- HRETURN_ERROR(H5E_ARGS, H5E_BADRANGE, NULL,
- "unknown property list class");
- }
-
- /* Create the new property list */
- if (NULL==(dst = H5MM_malloc(size))) {
- HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
- "memory allocation failed");
- }
+ case H5P_FILE_CREATE:
+ /* Create the new property list */
+ if (NULL==(dst = H5FL_ALLOC(H5F_create_t,0))) {
+ HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
+ "memory allocation failed");
+ }
+ size = sizeof(H5F_create_t);
+ break;
+
+ case H5P_FILE_ACCESS:
+ /* Create the new property list */
+ if (NULL==(dst = H5FL_ALLOC(H5F_access_t,0))) {
+ HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
+ "memory allocation failed");
+ }
+ size = sizeof(H5F_access_t);
+ break;
+
+ case H5P_DATASET_CREATE:
+ /* Create the new property list */
+ if (NULL==(dst = H5FL_ALLOC(H5D_create_t,0))) {
+ HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
+ "memory allocation failed");
+ }
+ size = sizeof(H5D_create_t);
+ break;
+
+ case H5P_DATA_XFER:
+ /* Create the new property list */
+ if (NULL==(dst = H5FL_ALLOC(H5F_xfer_t,0))) {
+ HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
+ "memory allocation failed");
+ }
+ size = sizeof(H5F_xfer_t);
+ break;
+
+ case H5P_MOUNT:
+ /* Create the new property list */
+ if (NULL==(dst = H5FL_ALLOC(H5F_mprop_t,0))) {
+ HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
+ "memory allocation failed");
+ }
+ size = sizeof(H5F_mprop_t);
+ break;
+
+ default:
+ HRETURN_ERROR(H5E_ARGS, H5E_BADRANGE, NULL,
+ "unknown property list class");
+ }
+
+ /* Copy into new object */
HDmemcpy(dst, src, size);
/* Deep-copy pointers */
switch (type) {
- case H5P_FILE_CREATE:
- break;
-
- case H5P_FILE_ACCESS:
- fa_dst = (H5F_access_t*)dst;
-
- if (fa_dst->driver_id>=0) {
- H5I_inc_ref(fa_dst->driver_id);
- fa_dst->driver_info = H5FD_fapl_copy(fa_dst->driver_id,
- fa_dst->driver_info);
- }
- break;
-
- case H5P_DATASET_CREATE:
- dc_src = (const H5D_create_t*)src;
- dc_dst = (H5D_create_t*)dst;
-
- /* Copy the fill value */
- if (NULL==H5O_copy(H5O_FILL, &(dc_src->fill), &(dc_dst->fill))) {
- HRETURN_ERROR(H5E_PLIST, H5E_CANTINIT, NULL,
- "unabe to copy fill value message");
- }
-
- /* Copy the external file list */
- HDmemset(&(dc_dst->efl), 0, sizeof(dc_dst->efl));
- if (NULL==H5O_copy(H5O_EFL, &(dc_src->efl), &(dc_dst->efl))) {
- HRETURN_ERROR(H5E_PLIST, H5E_CANTINIT, NULL,
- "unable to copy external file list message");
- }
-
- /* Copy the filter pipeline */
- if (NULL==H5O_copy(H5O_PLINE, &(dc_src->pline), &(dc_dst->pline))) {
- HRETURN_ERROR(H5E_PLIST, H5E_CANTINIT, NULL,
- "unable to copy filter pipeline message");
- }
-
-
- break;
-
- case H5P_DATA_XFER:
- dx_dst = (H5F_xfer_t*)dst;
-
- if (dx_dst->driver_id>=0) {
- H5I_inc_ref(dx_dst->driver_id);
- dx_dst->driver_info = H5FD_dxpl_copy(dx_dst->driver_id,
- dx_dst->driver_info);
- }
- break;
-
- case H5P_MOUNT:
- /* Nothing to do */
- break;
-
- default:
- HRETURN_ERROR(H5E_ARGS, H5E_BADRANGE, NULL,
- "unknown property list class");
+ case H5P_FILE_CREATE:
+ break;
+
+ case H5P_FILE_ACCESS:
+ fa_dst = (H5F_access_t*)dst;
+
+ if (fa_dst->driver_id>=0) {
+ H5I_inc_ref(fa_dst->driver_id);
+ fa_dst->driver_info = H5FD_fapl_copy(fa_dst->driver_id,
+ fa_dst->driver_info);
+ }
+ break;
+
+ case H5P_DATASET_CREATE:
+ dc_src = (const H5D_create_t*)src;
+ dc_dst = (H5D_create_t*)dst;
+
+ /* Copy the fill value */
+ if (NULL==H5O_copy(H5O_FILL, &(dc_src->fill), &(dc_dst->fill))) {
+ HRETURN_ERROR(H5E_PLIST, H5E_CANTINIT, NULL,
+ "unabe to copy fill value message");
+ }
+
+ /* Copy the external file list */
+ HDmemset(&(dc_dst->efl), 0, sizeof(dc_dst->efl));
+ if (NULL==H5O_copy(H5O_EFL, &(dc_src->efl), &(dc_dst->efl))) {
+ HRETURN_ERROR(H5E_PLIST, H5E_CANTINIT, NULL,
+ "unable to copy external file list message");
+ }
+
+ /* Copy the filter pipeline */
+ if (NULL==H5O_copy(H5O_PLINE, &(dc_src->pline), &(dc_dst->pline))) {
+ HRETURN_ERROR(H5E_PLIST, H5E_CANTINIT, NULL,
+ "unable to copy filter pipeline message");
+ }
+ break;
+
+ case H5P_DATA_XFER:
+ dx_dst = (H5F_xfer_t*)dst;
+
+ if (dx_dst->driver_id>=0) {
+ H5I_inc_ref(dx_dst->driver_id);
+ dx_dst->driver_info = H5FD_dxpl_copy(dx_dst->driver_id,
+ dx_dst->driver_info);
+ }
+ break;
+
+ case H5P_MOUNT:
+ /* Nothing to do */
+ break;
+
+ default:
+ HRETURN_ERROR(H5E_ARGS, H5E_BADRANGE, NULL,
+ "unknown property list class");
}
FUNC_LEAVE (dst);