summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2002-07-12 18:49:39 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2002-07-12 18:49:39 (GMT)
commitb40a61794072394a12edadd43309b5a12d885ac4 (patch)
tree84a80f271dfbdd3732c660dc3abfe824e80ab81b
parent5607e34da0650f919ed7cb6a3b9dcb7a6c27f02d (diff)
downloadhdf5-b40a61794072394a12edadd43309b5a12d885ac4.zip
hdf5-b40a61794072394a12edadd43309b5a12d885ac4.tar.gz
hdf5-b40a61794072394a12edadd43309b5a12d885ac4.tar.bz2
[svn-r5785] Purpose:
Code update Description: Re-arrange to disable free-list code in a more transparent way. Platforms tested: FreeBSD 4.6 (sleipnir)
-rw-r--r--src/H5FL.c51
-rw-r--r--src/H5FLprivate.h37
2 files changed, 37 insertions, 51 deletions
diff --git a/src/H5FL.c b/src/H5FL.c
index bcd6b3f..cf14880 100644
--- a/src/H5FL.c
+++ b/src/H5FL.c
@@ -86,14 +86,6 @@ typedef struct H5FL_blk_gc_list_t {
/* The head of the list of PQs to garbage collect */
static H5FL_blk_gc_list_t H5FL_blk_gc_head={0,NULL};
-/* Macros for turning off free lists in the library */
-/* #define NO_FREE_LISTS */
-#ifdef NO_FREE_LISTS
-#define NO_REG_FREE_LISTS
-#define NO_ARR_FREE_LISTS
-#define NO_BLK_FREE_LISTS
-#endif /* NO_FREE_LISTS */
-
/* Forward declarations of local static functions */
static herr_t H5FL_reg_gc(void);
static herr_t H5FL_reg_gc_list(H5FL_reg_head_t *head);
@@ -220,9 +212,6 @@ H5FL_reg_free(H5FL_reg_head_t *head, void *obj)
HDmemset(obj,255,head->size);
#endif /* H5FL_DEBUG */
-#ifdef NO_REG_FREE_LISTS
- H5MM_xfree(obj);
-#else /* NO_REG_FREE_LISTS */
/* Make certain that the free list is initialized */
assert(head->init);
@@ -251,8 +240,6 @@ H5FL_reg_free(H5FL_reg_head_t *head, void *obj)
if(H5FL_reg_gc_head.mem_freed>H5FL_reg_glb_mem_lim)
H5FL_reg_gc();
-#endif /* NO_REG_FREE_LISTS */
-
FUNC_LEAVE(NULL);
} /* end H5FL_reg_free() */
@@ -282,12 +269,6 @@ H5FL_reg_alloc(H5FL_reg_head_t *head, unsigned clear)
/* Double check parameters */
assert(head);
-#ifdef NO_REG_FREE_LISTS
- if(clear)
- ret_value=H5MM_calloc(head->size);
- else
- ret_value=H5MM_malloc(head->size);
-#else /* NO_REG_FREE_LISTS */
/* Make certain the list is initialized first */
if(!head->init)
H5FL_reg_init(head);
@@ -321,7 +302,6 @@ H5FL_reg_alloc(H5FL_reg_head_t *head, unsigned clear)
if(clear) {
HDmemset(ret_value,0,head->size);
} /* end if */
-#endif /* NO_REG_FREE_LISTS */
FUNC_LEAVE (ret_value);
} /* end H5FL_reg_alloc() */
@@ -677,12 +657,6 @@ H5FL_blk_alloc(H5FL_blk_head_t *head, size_t size, unsigned clear)
/* Double check parameters */
assert(head);
-#ifdef NO_BLK_FREE_LISTS
- if(clear)
- ret_value=H5MM_calloc(size);
- else
- ret_value=H5MM_malloc(size);
-#else /* NO_BLK_FREE_LISTS */
/* Make certain the list is initialized first */
if(!head->init)
H5FL_blk_init(head);
@@ -728,7 +702,6 @@ H5FL_blk_alloc(H5FL_blk_head_t *head, size_t size, unsigned clear)
if(clear) {
HDmemset(ret_value,0,size);
} /* end if */
-#endif /* NO_BLK_FREE_LISTS */
done:
FUNC_LEAVE(ret_value);
@@ -766,9 +739,6 @@ H5FL_blk_free(H5FL_blk_head_t *head, void *block)
assert(head);
assert(block);
-#ifdef NO_BLK_FREE_LISTS
- H5MM_xfree(block);
-#else /* NO_BLK_FREE_LISTS */
/* Get the pointer to the native block info header in front of the native block to free */
temp=(H5FL_blk_list_t *)((unsigned char *)block-sizeof(H5FL_blk_list_t));
@@ -803,8 +773,6 @@ H5FL_blk_free(H5FL_blk_head_t *head, void *block)
if(H5FL_blk_gc_head.mem_freed>H5FL_blk_glb_mem_lim)
H5FL_blk_gc();
-#endif /* NO_BLK_FREE_LISTS */
-
FUNC_LEAVE(NULL);
} /* end H5FL_blk_free() */
@@ -838,9 +806,6 @@ H5FL_blk_realloc(H5FL_blk_head_t *head, void *block, size_t new_size)
/* Double check parameters */
assert(head);
-#ifdef NO_BLK_FREE_LISTS
- ret_value=H5MM_realloc(block,new_size);
-#else /* NO_BLK_FREE_LISTS */
/* Check if we are actually re-allocating a block */
if(block!=NULL) {
/* Get the pointer to the chunk info header in front of the chunk to free */
@@ -860,7 +825,6 @@ H5FL_blk_realloc(H5FL_blk_head_t *head, void *block, size_t new_size)
/* Not re-allocating, just allocate a fresh block */
else
ret_value=H5FL_blk_alloc(head,new_size,0);
-#endif /* NO_BLK_FREE_LISTS */
done:
FUNC_LEAVE(ret_value);
@@ -1113,9 +1077,6 @@ H5FL_arr_free(H5FL_arr_head_t *head, void *obj)
FUNC_ENTER_NOAPI(H5FL_arr_free, NULL);
-#ifdef NO_ARR_FREE_LISTS
- H5MM_xfree(obj);
-#else /* NO_ARR_FREE_LISTS */
/* The H5MM_xfree code allows obj to null */
if (!obj)
HRETURN (NULL);
@@ -1167,7 +1128,6 @@ H5FL_arr_free(H5FL_arr_head_t *head, void *obj)
else {
H5FL_blk_free(&(head->u.queue),obj);
} /* end else */
-#endif /* NO_ARR_FREE_LISTS */
FUNC_LEAVE(NULL);
} /* end H5FL_arr_free() */
@@ -1200,12 +1160,6 @@ H5FL_arr_alloc(H5FL_arr_head_t *head, size_t elem, unsigned clear)
/* Double check parameters */
assert(head);
-#ifdef NO_ARR_FREE_LISTS
- if(clear)
- ret_value=H5MM_calloc(elem*head->size);
- else
- ret_value=H5MM_malloc(elem*head->size);
-#else /* NO_ARR_FREE_LISTS */
/* Make certain the list is initialized first */
if(!head->init)
H5FL_arr_init(head);
@@ -1260,7 +1214,6 @@ H5FL_arr_alloc(H5FL_arr_head_t *head, size_t elem, unsigned clear)
else {
ret_value=H5FL_blk_alloc(&(head->u.queue),mem_size,clear);
} /* end else */
-#endif /* NO_ARR_FREE_LISTS */
FUNC_LEAVE (ret_value);
} /* end H5FL_arr_alloc() */
@@ -1293,9 +1246,6 @@ H5FL_arr_realloc(H5FL_arr_head_t *head, void * obj, size_t new_elem)
/* Double check parameters */
assert(head);
-#ifdef NO_ARR_FREE_LISTS
- ret_value=H5MM_realloc(obj,new_elem*head->size);
-#else /* NO_ARR_FREE_LISTS */
/* Check if we are really allocating the object */
if(obj==NULL) {
ret_value=H5FL_arr_alloc(head,new_elem,0);
@@ -1326,7 +1276,6 @@ H5FL_arr_realloc(H5FL_arr_head_t *head, void * obj, size_t new_elem)
ret_value=H5FL_blk_realloc(&(head->u.queue),obj,head->size*new_elem);
} /* end else */
} /* end else */
-#endif /* NO_ARR_FREE_LISTS */
FUNC_LEAVE (ret_value);
} /* end H5FL_arr_realloc() */
diff --git a/src/H5FLprivate.h b/src/H5FLprivate.h
index e531d0c..805895b 100644
--- a/src/H5FLprivate.h
+++ b/src/H5FLprivate.h
@@ -24,6 +24,14 @@
/* Private headers needed by this file */
+/* Macros for turning off free lists in the library */
+#define H5_NO_FREE_LISTS
+#ifdef H5_NO_FREE_LISTS
+#define H5_NO_REG_FREE_LISTS
+#define H5_NO_ARR_FREE_LISTS
+#define H5_NO_BLK_FREE_LISTS
+#endif /* H5_NO_FREE_LISTS */
+
/*
* Private datatypes.
*/
@@ -47,6 +55,7 @@ typedef struct H5FL_reg_head_t {
/*
* Macros for defining & using free lists for a type
*/
+#ifndef H5_NO_REG_FREE_LISTS
/* Declare a free list to manage objects of type 't' */
#define H5FL_DEFINE(t) H5FL_reg_head_t t##_free_list={0,0,0,0,#t,sizeof(t),NULL}
@@ -66,6 +75,14 @@ typedef struct H5FL_reg_head_t {
* only support fixed sized types, like structs, etc..
*/
+#else /* H5_NO_REG_FREE_LISTS */
+#define H5FL_DEFINE(t) int t##_reg_free_list_placeholder
+#define H5FL_EXTERN(t) extern int t##_reg_free_list_placeholder
+#define H5FL_DEFINE_STATIC(t) static H5FL_DEFINE(t)
+#define H5FL_ALLOC(t,clr) (clr ? H5MM_calloc(sizeof(t)) : H5MM_malloc(sizeof(t)))
+#define H5FL_FREE(t,obj) H5MM_xfree(obj)
+#endif /* H5_NO_REG_FREE_LISTS */
+
/* Data structure to store information about each block allocated */
typedef union H5FL_blk_list_t {
size_t size; /* Size of the page */
@@ -95,6 +112,7 @@ typedef struct H5FL_blk_head_t {
/*
* Macros for defining & using priority queues
*/
+#ifndef H5_NO_BLK_FREE_LISTS
/* Declare a free list to manage objects of type 't' */
#define H5FL_BLK_DEFINE(t) H5FL_blk_head_t t##_pq={0,0,0,0,#t,NULL}
@@ -113,6 +131,15 @@ typedef struct H5FL_blk_head_t {
/* Re-allocate a block of type 't' */
#define H5FL_BLK_REALLOC(t,blk,new_size) H5FL_blk_realloc(&(t##_pq),blk,new_size)
+#else /* H5_NO_BLK_FREE_LISTS */
+#define H5FL_BLK_DEFINE(t) int t##_blk_free_list_placeholder
+#define H5FL_BLK_EXTERN(t) extern int t##_blk_free_list_placeholder
+#define H5FL_BLK_DEFINE_STATIC(t) static H5FL_BLK_DEFINE(t)
+#define H5FL_BLK_ALLOC(t,size,clr) (clr ? H5MM_calloc(size) : H5MM_malloc(size))
+#define H5FL_BLK_FREE(t,blk) H5MM_xfree(blk)
+#define H5FL_BLK_REALLOC(t,blk,new_size) H5MM_realloc(blk,new_size)
+#endif /* H5_NO_BLK_FREE_LISTS */
+
/* Data structure to store each array in free list */
typedef union H5FL_arr_node_t {
union H5FL_arr_node_t *next; /* Pointer to next block in free list */
@@ -139,6 +166,7 @@ typedef struct H5FL_arr_head_t {
/*
* Macros for defining & using free lists for an array of a type
*/
+#ifndef H5_NO_ARR_FREE_LISTS
/* Declare a free list to manage arrays of type 't' */
#define H5FL_ARR_DEFINE(t,m) H5FL_arr_head_t t##_arr_free_list={0,0,NULL,0,#t"_arr",m+1,sizeof(t),{NULL}}
@@ -157,6 +185,15 @@ typedef struct H5FL_arr_head_t {
/* Re-allocate an array of type 't' */
#define H5FL_ARR_REALLOC(t,obj,new_elem) H5FL_arr_realloc(&(t##_arr_free_list),obj,new_elem)
+#else /* H5_NO_ARR_FREE_LISTS */
+#define H5FL_ARR_DEFINE(t,m) int t##_arr_free_list_placeholder
+#define H5FL_ARR_EXTERN(t) extern int t##_arr_free_list_placeholder
+#define H5FL_ARR_DEFINE_STATIC(t,m) static H5FL_ARR_DEFINE(t,m)
+#define H5FL_ARR_ALLOC(t,elem,clr) (clr ? H5MM_calloc(elem*sizeof(t)) : H5MM_malloc(elem*sizeof(t)))
+#define H5FL_ARR_FREE(t,obj) H5MM_xfree(obj)
+#define H5FL_ARR_REALLOC(t,obj,new_elem) H5MM_realloc(obj,new_elem*sizeof(t))
+#endif /* H5_NO_ARR_FREE_LISTS */
+
/*
* Library prototypes.
*/