summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2006-06-19 10:06:10 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2006-06-19 10:06:10 (GMT)
commit9db9e82cd1c4e35c6e64fbb2da5eb1db95a0fb55 (patch)
treedf8aaa72b1094bcfacc740a8d33b255c84e1d34e /test
parent54e2de04d3b7a0359c80cc995f94b63123f4a4da (diff)
downloadhdf5-9db9e82cd1c4e35c6e64fbb2da5eb1db95a0fb55.zip
hdf5-9db9e82cd1c4e35c6e64fbb2da5eb1db95a0fb55.tar.gz
hdf5-9db9e82cd1c4e35c6e64fbb2da5eb1db95a0fb55.tar.bz2
[svn-r12424] Purpose:
Code checkpoint Description: Add in more new features for the fractal heap code, mostly bringing in more ability for deleting objects (which isn't completely working yet). Also, checkpoint free space manager code, which is essentially complete (although it needs some more work after the metadata cache has some additional features) Platforms tested: FreeBSD 4.11 (sleipnir) Linux 2.4 (chicago) h5committest
Diffstat (limited to 'test')
-rw-r--r--test/fheap.c5124
1 files changed, 3802 insertions, 1322 deletions
diff --git a/test/fheap.c b/test/fheap.c
index 1f1a000..6cff879 100644
--- a/test/fheap.c
+++ b/test/fheap.c
@@ -47,21 +47,19 @@
/* #define ALL_INSERT_TESTS */
/* Heap metadata macros */
-#define DBLOCK_OVERHEAD(fh) H5HF_get_dblock_overhead(fh) /* # of bytes in direct block overhead */
-#define HEAP_ID_LEN 12 /* # of bytes to use for heap ID */
-#define DBLOCK_SIZE(fh, r) H5HF_get_dblock_size_test(fh, r)
-#define DBLOCK_FREE(fh, r) H5HF_get_dblock_free_test(fh, r)
+#define HEAP_ID_LEN 6 /* # of bytes to use for heap ID */
+#define HEAP_MAX_ROOT_ROWS(fh) H5HF_get_max_root_rows(fh) /* Max. # of rows in root indirect block */
+#define DTABLE_WIDTH(fh) H5HF_get_dtable_width_test(fh) /* Width of doubling table for heap */
+#define DTABLE_MAX_DROWS(fh) H5HF_get_dtable_max_drows_test(fh) /* Max. # of direct block rows in any indirect block */
+#define IBLOCK_MAX_DROWS(fh, pos) H5HF_get_iblock_max_drows_test(fh, pos) /* Max. # of direct block rows in a indirect block */
+#define DBLOCK_SIZE(fh, r) H5HF_get_dblock_size_test(fh, r) /* Size of a direct block in a given row */
+#define DBLOCK_FREE(fh, r) H5HF_get_dblock_free_test(fh, r) /* Free space in a direct block of a given row */
const char *FILENAME[] = {
"fheap",
NULL
};
-/* Testing parameters */
-typedef struct fheap_test_param_t {
- hbool_t reopen_heap; /* Whether to re-open the heap during the test */
-} fheap_test_param_t;
-
/* Types of tests to perform */
typedef enum {
FHEAP_TEST_NORMAL, /* "Normal" test, with no testing parameters set */
@@ -69,12 +67,57 @@ typedef enum {
FHEAP_TEST_NTESTS /* The number of test types, must be last */
} fheap_test_type_t;
+/* Order to delete objects */
+typedef enum {
+ HEAP_DEL_FORWARD, /* Delete objects from 0 -> nobjs */
+ HEAP_DEL_REVERSE, /* Delete objects from nobjs -> 0 */
+ HEAP_DEL_NDIRS /* The number of different deletion orders, must be last */
+} fheap_test_del_dir_t;
+
+/* Order to delete objects */
+typedef enum {
+ HEAP_DEL_DRAIN_ALL, /* Don't drain half of objects first */
+ HEAP_DEL_DRAIN_HALF, /* Don't drain half of objects first */
+ HEAP_DEL_DRAIN_N /* The number of different ways to drain, must be last */
+} fheap_test_del_drain_t;
+
+/* Testing parameters */
+typedef struct fheap_test_param_t {
+ fheap_test_type_t reopen_heap; /* Whether to re-open the heap during the test */
+ fheap_test_del_dir_t del_dir; /* Whether to delete objects forward or reverse */
+ fheap_test_del_drain_t drain_half; /* Whether to drain half of the objects & refill, when deleting objects */
+} fheap_test_param_t;
+
+/* Heap state information */
+typedef struct fheap_heap_state_t {
+ hsize_t heap_size; /* Total size of heap (managed & standalone objects) */
+ size_t nobjs; /* # of objects within heap */
+ hsize_t man_size; /* Size of managed object heap */
+ hsize_t man_alloc_size; /* Size of managed object heap allocated */
+ hsize_t man_free_space; /* Managed object free space within heap */
+} fheap_heap_state_t;
+
+/* Heap IDs to retain */
+typedef struct fheap_heap_ids_t {
+ size_t num_ids; /* # of heap IDs in array */
+ size_t alloc_ids; /* # of heap IDs allocated in array */
+ unsigned char *ids; /* Array of object heap IDs */
+ size_t *lens; /* Array of object lengths */
+ size_t *offs; /* Array of object offsets (in global shared write buffer) */
+} fheap_heap_ids_t;
+
+/* Local variables */
+unsigned char *shared_wobj_g; /* Pointer to shared write buffer for objects */
+unsigned char *shared_robj_g; /* Pointer to shared read buffer for objects */
+size_t shared_obj_size_g; /* Size of shared objects */
+unsigned char *shared_ids_g = NULL; /* Array of shared object heap IDs */
+size_t *shared_lens_g = NULL; /* Array of shared object lengths */
+size_t *shared_offs_g = NULL; /* Array of shared object offsets */
+size_t shared_alloc_ids_g = 0; /* # of shared heap IDs allocated in array */
/* Local routines */
static int init_small_cparam(H5HF_create_t *cparam);
-static int check_stats(H5HF_t *fh, hsize_t total_size,
- hsize_t man_size, hsize_t std_size, hsize_t man_free_space, hsize_t nobjs);
-
+static int check_stats(const H5HF_t *fh, const fheap_heap_state_t *state);
/*-------------------------------------------------------------------------
@@ -128,32 +171,31 @@ init_small_cparam(H5HF_create_t *cparam)
*-------------------------------------------------------------------------
*/
static int
-check_stats(H5HF_t *fh, hsize_t total_size,
- hsize_t man_size, hsize_t std_size, hsize_t man_free_space, hsize_t nobjs)
+check_stats(const H5HF_t *fh, const fheap_heap_state_t *state)
{
H5HF_stat_t heap_stats; /* Statistics about the heap */
/* Get statistics for heap and verify they are correct */
if(H5HF_stat_info(fh, &heap_stats) < 0)
FAIL_STACK_ERROR
- if(heap_stats.total_size != total_size) {
- HDfprintf(stdout, "heap_stats.total_size = %Hu, total_size = %Hu\n", heap_stats.total_size, total_size);
+ if(heap_stats.total_size != state->heap_size) {
+ HDfprintf(stdout, "heap_stats.total_size = %Hu, state->heap_size = %Hu\n", heap_stats.total_size, state->heap_size);
FAIL_STACK_ERROR
} /* end if */
- if(heap_stats.man_size != man_size) {
- HDfprintf(stdout, "heap_stats.man_size = %Hu, man_size = %Hu\n", heap_stats.man_size, man_size);
+ if(heap_stats.nobjs != state->nobjs) {
+ HDfprintf(stdout, "heap_stats.nobjs = %Hu, state->nobjs = %Hu\n", heap_stats.nobjs, state->nobjs);
FAIL_STACK_ERROR
} /* end if */
- if(heap_stats.std_size != std_size) {
- HDfprintf(stdout, "heap_stats.std_size = %Hu, std_size = %Hu\n", heap_stats.std_size, std_size);
+ if(heap_stats.man_size != state->man_size) {
+ HDfprintf(stdout, "heap_stats.man_size = %Hu, state->man_size = %Hu\n", heap_stats.man_size, state->man_size);
FAIL_STACK_ERROR
} /* end if */
- if(heap_stats.man_free_space != man_free_space) {
- HDfprintf(stdout, "heap_stats.man_free_space = %Hu, man_free_space = %Hu\n", heap_stats.man_free_space, man_free_space);
+ if(heap_stats.man_alloc_size != state->man_alloc_size) {
+ HDfprintf(stdout, "heap_stats.man_alloc_size = %Hu, state->man_alloc_size = %Hu\n", heap_stats.man_alloc_size, state->man_alloc_size);
FAIL_STACK_ERROR
} /* end if */
- if(heap_stats.nobjs != nobjs) {
- HDfprintf(stdout, "heap_stats.nobjs = %Hu, nobjs = %Hu\n", heap_stats.nobjs, nobjs);
+ if(heap_stats.man_free_space != state->man_free_space) {
+ HDfprintf(stdout, "heap_stats.man_free_space = %Hu, state->man_free_space = %Hu\n", heap_stats.man_free_space, state->man_free_space);
FAIL_STACK_ERROR
} /* end if */
@@ -170,6 +212,17 @@ error:
*
* Purpose: Add an object to heap
*
+ * Note: The following fields in the 'state' structure are set to
+ * the values expected _after_ any block created for the object:
+ * heap_size
+ * man_size
+ * man_alloc_size
+ * man_free_space
+ *
+ * The following fields in the 'state' structure are set to
+ * the current state, before any block has been created:
+ * nobjs
+ *
* Return: Success: 0
*
* Failure: 1
@@ -180,207 +233,481 @@ error:
*-------------------------------------------------------------------------
*/
static int
-add_obj(H5HF_t *fh, hid_t dxpl,
- hsize_t heap_size, hsize_t *free_space, unsigned *nobjs_ptr,
- unsigned obj_init, size_t obj_size)
+add_obj(H5HF_t *fh, hid_t dxpl, unsigned obj_off, size_t obj_size,
+ fheap_heap_state_t *state, fheap_heap_ids_t *keep_ids)
{
unsigned char heap_id[HEAP_ID_LEN]; /* Heap ID for object inserted */
- unsigned char *obj = NULL; /* Buffer for object to insert */
- unsigned char *robj = NULL; /* Buffer for reading object */
- size_t u; /* Local counting variable */
+ unsigned char *obj; /* Buffer for object to insert */
/* Sanity check */
- HDassert(nobjs_ptr);
- HDassert(free_space);
+ HDassert(fh);
+ HDassert(state);
/* Initialize object buffer */
- obj = H5MM_malloc(obj_size);
- HDassert(obj);
- for(u = 0; u < obj_size; u++)
- obj[u] = u + obj_init;
+ obj = &shared_wobj_g[obj_off];
/* Insert object */
HDmemset(heap_id, 0, sizeof(heap_id));
if(H5HF_insert(fh, dxpl, obj_size, obj, heap_id) < 0)
FAIL_STACK_ERROR
- /* Increment the number of objects */
- (*nobjs_ptr)++;
+ /* Adjust state of heap */
+ state->nobjs++;
+ state->man_free_space -= obj_size;
/* Check free space left in heap */
- *free_space -= obj_size;
- if(check_stats(fh, heap_size, heap_size, (hsize_t)0, *free_space, (hsize_t)*nobjs_ptr))
+ if(check_stats(fh, state))
FAIL_STACK_ERROR
/* Read in object */
- robj = H5MM_malloc(obj_size);
- if(H5HF_read(fh, dxpl, heap_id, robj) < 0)
+ if(H5HF_read(fh, dxpl, heap_id, shared_robj_g) < 0)
FAIL_STACK_ERROR
- if(HDmemcmp(obj, robj, obj_size))
+ if(HDmemcmp(obj, shared_robj_g, obj_size))
FAIL_STACK_ERROR
+ /* If the heap IDs are to be retained, append them to the list */
+ if(keep_ids) {
+ /* Check for needing to increase size of heap ID array */
+ if(keep_ids->num_ids + 1 > keep_ids->alloc_ids) {
+ keep_ids->alloc_ids = MAX(1024, (keep_ids->alloc_ids * 2));
+ if(NULL == (keep_ids->ids = H5MM_realloc(keep_ids->ids, HEAP_ID_LEN * keep_ids->alloc_ids)))
+ FAIL_STACK_ERROR
+ if(NULL == (keep_ids->lens = H5MM_realloc(keep_ids->lens, sizeof(size_t) * keep_ids->alloc_ids)))
+ FAIL_STACK_ERROR
+ if(NULL == (keep_ids->offs = H5MM_realloc(keep_ids->offs, sizeof(size_t) * keep_ids->alloc_ids)))
+ FAIL_STACK_ERROR
+ } /* end if */
+
+ /* Append the object info onto the array */
+ HDmemcpy(&keep_ids->ids[keep_ids->num_ids * HEAP_ID_LEN], obj, HEAP_ID_LEN);
+ keep_ids->lens[keep_ids->num_ids] = obj_size;
+ keep_ids->offs[keep_ids->num_ids] = obj_off;
+
+ /* Increment the number of IDs kept */
+ keep_ids->num_ids++;
+ } /* end if */
+
/* Operations succeeded */
- H5MM_xfree(obj);
- H5MM_xfree(robj);
return(0);
error:
- H5MM_xfree(obj);
- H5MM_xfree(robj);
return(1);
} /* add_obj() */
/*-------------------------------------------------------------------------
- * Function: fill_heap
+ * Function: get_del_string
*
- * Purpose: Insert (small) objects to fill up the free space in a heap block
- * (Generally used to create & fill up a new direct block)
+ * Purpose: Return string describing the kind of deletion to perform
*
* Return: Success: 0
*
* Failure: 1
*
* Programmer: Quincey Koziol
- * Tuesday, March 7, 2006
+ * Monday, June 6, 2006
+ *
+ *-------------------------------------------------------------------------
+ */
+static char *
+get_del_string(fheap_test_param_t *tparam)
+{
+ char *str;
+
+ /* Remove half of total objects from heap */
+ if(tparam->del_dir == HEAP_DEL_FORWARD)
+ if(tparam->drain_half == HEAP_DEL_DRAIN_ALL)
+ str = HDstrdup("(all - forward)");
+ else
+ str = HDstrdup("(half, refill, all - forward)");
+ else
+ if(tparam->drain_half == HEAP_DEL_DRAIN_ALL)
+ str = HDstrdup("(all - reverse)");
+ else
+ str = HDstrdup("(half, refill, all - reverse)");
+
+ return(str);
+} /* get_del_string() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: del_objs_half_refill
+ *
+ * Purpose: Remove half of objects from heap and refill
+ *
+ * Return: Success: 0
+ *
+ * Failure: 1
+ *
+ * Programmer: Quincey Koziol
+ * Monday, June 6, 2006
*
*-------------------------------------------------------------------------
*/
static int
-fill_heap(H5HF_t *fh, hid_t dxpl, const H5HF_create_t *cparam,
- hsize_t heap_size, size_t block_size,
- hsize_t extra_free, unsigned *nobjs_ptr)
+del_objs_half_refill(H5F_t *f, hid_t dxpl, H5HF_t **fh, fheap_test_param_t *tparam,
+ fheap_heap_state_t *state, fheap_heap_ids_t *keep_ids)
{
- H5HF_stat_t heap_stats; /* Statistics about the heap */
- hsize_t free_space; /* Size of free space in heap */
- unsigned char obj[SMALL_OBJ_SIZE1]; /* Buffer for object to insert */
- unsigned char robj[SMALL_OBJ_SIZE1]; /* Buffer for reading object */
- size_t num_ids = 0; /* # of heap IDs in array */
- size_t alloc_ids = 0; /* # of heap IDs allocated in array */
- unsigned char *ids = NULL; /* Array of heap IDs */
- size_t data_size; /* Size of data portion of heap block */
- size_t last_obj_len; /* Size of last object inserted into heap */
- unsigned u, v; /* Local index variable */
+ unsigned char *wobj; /* Buffer for object to insert */
+ haddr_t fh_addr; /* Address of fractal heap */
+ size_t half_nobjs; /* Half of total # of objects */
+ size_t obj_idx; /* Index of the object to remove */
+ size_t u; /* Local index variable */
/* Sanity check */
- HDassert(nobjs_ptr);
+ HDassert(fh);
+ HDassert(*fh);
+ HDassert(state);
+ HDassert(keep_ids);
+
+ /* Check for closing & re-opening the heap */
+ if(tparam->reopen_heap) {
+ if(H5HF_get_heap_addr(*fh, &fh_addr) < 0)
+ FAIL_STACK_ERROR
+ if(!H5F_addr_defined(fh_addr))
+ FAIL_STACK_ERROR
+ } /* end if */
- /* Initialize variables */
- data_size = block_size - DBLOCK_OVERHEAD(fh);
+ /* Remove half of total objects from heap */
+ if(tparam->del_dir == HEAP_DEL_FORWARD)
+ obj_idx = 0;
+ else
+ obj_idx = state->nobjs - 1;
+ half_nobjs = state->nobjs / 2;
+ for(u = 0; u < half_nobjs; u++) {
+ /* Remove object from heap */
+ if(H5HF_remove(*fh, dxpl, &keep_ids->ids[HEAP_ID_LEN * obj_idx]) < 0)
+ FAIL_STACK_ERROR
- /* Initialize object buffer */
- for(u = 0; u < sizeof(obj); u++)
- obj[u] = u;
+ /* Check for closing & re-opening the heap */
+ if(tparam->reopen_heap) {
+ /* Close (empty) heap */
+ if(H5HF_close(*fh, dxpl) < 0)
+ TEST_ERROR
+
+ /* Re-open heap */
+ if(NULL == (*fh = H5HF_open(f, dxpl, fh_addr)))
+ FAIL_STACK_ERROR
+ } /* end if */
- /* Increment object count */
- num_ids++;
+ /* Adjust index of object to delete next */
+ if(tparam->del_dir == HEAP_DEL_FORWARD)
+ obj_idx++;
+ else
+ obj_idx--;
+ } /* end for */
- /* Check for needing to increase size of heap ID array */
- if(num_ids > alloc_ids) {
- alloc_ids = MAX(1024, (alloc_ids * 2));
- if(NULL == (ids = H5MM_realloc(ids, HEAP_ID_LEN * alloc_ids)))
+ /* Re-insert half of total objects back into heap */
+ if(tparam->del_dir == HEAP_DEL_FORWARD)
+ obj_idx = 0;
+ else
+ obj_idx = state->nobjs - 1;
+ for(u = 0; u < half_nobjs; u++) {
+ /* Re-insert object */
+ wobj = &shared_wobj_g[keep_ids->offs[obj_idx]];
+ if(H5HF_insert(*fh, dxpl, keep_ids->lens[obj_idx], wobj, &keep_ids->ids[HEAP_ID_LEN * obj_idx]) < 0)
+ FAIL_STACK_ERROR
+
+ /* Check for closing & re-opening the heap */
+ if(tparam->reopen_heap) {
+ /* Close (empty) heap */
+ if(H5HF_close(*fh, dxpl) < 0)
+ TEST_ERROR
+
+ /* Re-open heap */
+ if(NULL == (*fh = H5HF_open(f, dxpl, fh_addr)))
+ FAIL_STACK_ERROR
+ } /* end if */
+
+ /* Adjust index of object to delete next */
+ if(tparam->del_dir == HEAP_DEL_FORWARD)
+ obj_idx++;
+ else
+ obj_idx--;
+ } /* end for */
+
+ /* Operations succeeded */
+ return(0);
+
+error:
+ return(1);
+} /* del_objs_half_refill() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: del_objs
+ *
+ * Purpose: Remove objects from heap
+ *
+ * Return: Success: 0
+ *
+ * Failure: 1
+ *
+ * Programmer: Quincey Koziol
+ * Monday, June 6, 2006
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+del_objs(H5F_t *f, hid_t dxpl, H5HF_t **fh, fheap_test_param_t *tparam,
+ fheap_heap_state_t *state, fheap_heap_ids_t *keep_ids)
+{
+ haddr_t fh_addr; /* Address of fractal heap */
+ size_t obj_idx; /* Index of the object to remove */
+ size_t u; /* Local index variable */
+
+ /* Sanity check */
+ HDassert(fh);
+ HDassert(*fh);
+ HDassert(state);
+ HDassert(keep_ids);
+
+ /* Check for first deleting half of objects & then re-inserting them */
+ if(tparam->drain_half == HEAP_DEL_DRAIN_HALF)
+ if(del_objs_half_refill(f, dxpl, fh, tparam, state, keep_ids))
+ FAIL_STACK_ERROR
+
+ /* Check for closing & re-opening the heap */
+ if(tparam->reopen_heap) {
+ if(H5HF_get_heap_addr(*fh, &fh_addr) < 0)
+ FAIL_STACK_ERROR
+ if(!H5F_addr_defined(fh_addr))
FAIL_STACK_ERROR
} /* end if */
- /* Insert first object */
- if(H5HF_insert(fh, dxpl, sizeof(obj), obj, &ids[(num_ids - 1) * HEAP_ID_LEN]) < 0)
- FAIL_STACK_ERROR
+ /* Remove all objects from heap */
+ if(tparam->del_dir == HEAP_DEL_FORWARD)
+ obj_idx = 0;
+ else
+ obj_idx = state->nobjs - 1;
+ for(u = 0; u < state->nobjs; u++) {
+ /* Remove object from heap */
+ if(H5HF_remove(*fh, dxpl, &keep_ids->ids[HEAP_ID_LEN * obj_idx]) < 0)
+ FAIL_STACK_ERROR
- free_space = extra_free + (data_size - (num_ids * sizeof(obj)));
-#ifdef QAK
-HDfprintf(stderr, "extra_free = %Hu\n", extra_free);
-HDfprintf(stderr, "free_space = %Hu\n", free_space);
-#endif /* QAK */
- if(check_stats(fh, heap_size, heap_size, (hsize_t)0, free_space, (hsize_t)(*nobjs_ptr + num_ids)))
- FAIL_STACK_ERROR
+ /* Check for closing & re-opening the heap */
+ if(tparam->reopen_heap) {
+ /* Close (empty) heap */
+ if(H5HF_close(*fh, dxpl) < 0)
+ TEST_ERROR
- /* Get statistics for heap */
- if(H5HF_stat_info(fh, &heap_stats) < 0)
+ /* Re-open heap */
+ if(NULL == (*fh = H5HF_open(f, dxpl, fh_addr)))
+ FAIL_STACK_ERROR
+ } /* end if */
+
+ /* Adjust index of object to delete next */
+ if(tparam->del_dir == HEAP_DEL_FORWARD)
+ obj_idx++;
+ else
+ obj_idx--;
+ } /* end for */
+
+ /* Check up on heap... */
+ state->heap_size = 0;
+ state->man_size = 0;
+ state->man_alloc_size = 0;
+ state->man_free_space = 0;
+ state->nobjs = 0;
+ if(check_stats(*fh, state))
FAIL_STACK_ERROR
- /* Loop over inserting objects into the root direct block, until there's no more space */
- while((heap_stats.man_free_space - extra_free) > sizeof(obj)) {
- /* Initialize object buffer */
- for(u = 0; u < sizeof(obj); u++)
- obj[u] = u + num_ids;
+ /* Operations succeeded */
+ return(0);
+error:
+ return(1);
+} /* del_objs() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: fill_heap
+ *
+ * Purpose: Insert (small) objects to fill up the free space in a heap block
+ *
+ * Note: The following fields in the 'state' structure are set to
+ * the values expected _after_ the block has been created:
+ * heap_size
+ * man_size
+ * man_alloc_size
+ * man_free_space
+ *
+ * The following fields in the 'state' structure are set to
+ * the current state, before the block has been created:
+ * nobjs
+ *
+ * Return: Success: 0
+ *
+ * Failure: 1
+ *
+ * Programmer: Quincey Koziol
+ * Tuesday, March 7, 2006
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+fill_heap(H5HF_t *fh, hid_t dxpl, unsigned block_row, size_t obj_size,
+ fheap_heap_state_t *state, fheap_heap_ids_t *keep_ids)
+{
+ unsigned char *wobj; /* Buffer for object to insert */
+ unsigned char *curr_id_ptr; /* Pointer into shared ID array */
+ size_t *curr_len_ptr; /* Pointer into shared length array */
+ size_t *curr_off_ptr; /* Pointer into shared offset array */
+ size_t num_ids = 0; /* # of heap IDs in array */
+ size_t data_size; /* Size of data portion of heap block */
+ size_t last_obj_len; /* Size of last object inserted into heap */
+ size_t obj_off; /* Offset of object in shared write buffer */
+ unsigned u; /* Local index variable */
+
+ /* Sanity check */
+ HDassert(fh);
+ HDassert(state);
+ HDassert(obj_size + 256 < shared_obj_size_g);
+
+ /* Initialize starting information */
+ data_size = DBLOCK_FREE(fh, block_row);
+ wobj = shared_wobj_g;
+ curr_id_ptr = shared_ids_g;
+ curr_len_ptr = shared_lens_g;
+ curr_off_ptr = shared_offs_g;
+ obj_off = 0;
+
+ /* Loop over inserting objects into the root direct block, until there's no more space */
+ while(data_size >= obj_size) {
/* Increment object count */
num_ids++;
/* Check for needing to increase size of heap ID array */
- if(num_ids > alloc_ids) {
- alloc_ids = MAX(1024, (alloc_ids * 2));
- if(NULL == (ids = H5MM_realloc(ids, HEAP_ID_LEN * alloc_ids)))
+ if(num_ids > shared_alloc_ids_g) {
+ shared_alloc_ids_g = MAX(1024, (shared_alloc_ids_g * 2));
+ if(NULL == (shared_ids_g = H5MM_realloc(shared_ids_g, HEAP_ID_LEN * shared_alloc_ids_g)))
+ FAIL_STACK_ERROR
+ if(NULL == (shared_lens_g = H5MM_realloc(shared_lens_g, sizeof(size_t) * shared_alloc_ids_g)))
FAIL_STACK_ERROR
+ if(NULL == (shared_offs_g = H5MM_realloc(shared_offs_g, sizeof(size_t) * shared_alloc_ids_g)))
+ FAIL_STACK_ERROR
+ curr_id_ptr = &shared_ids_g[(num_ids - 1) * HEAP_ID_LEN];
+ curr_len_ptr = &shared_lens_g[(num_ids - 1)];
+ curr_off_ptr = &shared_offs_g[(num_ids - 1)];
} /* end if */
- if(H5HF_insert(fh, dxpl, sizeof(obj), obj, &ids[(num_ids - 1) * HEAP_ID_LEN]) < 0)
+ /* Insert object */
+ if(H5HF_insert(fh, dxpl, obj_size, wobj, curr_id_ptr) < 0)
FAIL_STACK_ERROR
+ *curr_len_ptr = obj_size;
+ *curr_off_ptr = obj_off;
+
+ /* Adjust state of heap */
+ state->nobjs++;
+ state->man_free_space -= obj_size;
/* Check stats for heap */
- free_space = extra_free + (data_size - (num_ids * sizeof(obj)));
-#ifdef QAK
-HDfprintf(stderr, "free_space = %Hu\n", free_space);
-#endif /* QAK */
- if(check_stats(fh, heap_size, heap_size, (hsize_t)0, free_space, (hsize_t)(num_ids + *nobjs_ptr)))
+ if(check_stats(fh, state))
FAIL_STACK_ERROR
- /* Get statistics for heap */
- if(H5HF_stat_info(fh, &heap_stats) < 0)
- FAIL_STACK_ERROR
+ /* Adjust object & ID pointers */
+ wobj++;
+ obj_off++;
+ if(obj_off > 255) {
+ wobj = shared_wobj_g;
+ obj_off = 0;
+ } /* end if */
+ curr_id_ptr += HEAP_ID_LEN;
+ curr_len_ptr++;
+ curr_off_ptr++;
+
+ /* Decrement space left in block */
+ data_size -= obj_size;
} /* end while */
/* Check for adding smaller last object to heap block */
- if((heap_stats.man_free_space - extra_free) > 0) {
- last_obj_len = (size_t)(heap_stats.man_free_space - extra_free);
-
- /* Initialize object buffer */
- for(u = 0; u < sizeof(obj); u++)
- obj[u] = u + num_ids;
+ if(data_size > 0) {
+ /* Set size of last object in block */
+ last_obj_len = data_size;
/* Increment object count */
num_ids++;
/* Check for needing to increase size of heap ID array */
- if(num_ids > alloc_ids) {
- alloc_ids = MAX(1024, (alloc_ids * 2));
- if(NULL == (ids = H5MM_realloc(ids, HEAP_ID_LEN * alloc_ids)))
+ if(num_ids > shared_alloc_ids_g) {
+ shared_alloc_ids_g = MAX(1024, (shared_alloc_ids_g * 2));
+ if(NULL == (shared_ids_g = H5MM_realloc(shared_ids_g, HEAP_ID_LEN * shared_alloc_ids_g)))
+ FAIL_STACK_ERROR
+ if(NULL == (shared_lens_g = H5MM_realloc(shared_lens_g, sizeof(size_t) * shared_alloc_ids_g)))
+ FAIL_STACK_ERROR
+ if(NULL == (shared_offs_g = H5MM_realloc(shared_offs_g, sizeof(size_t) * shared_alloc_ids_g)))
FAIL_STACK_ERROR
+ curr_id_ptr = &shared_ids_g[(num_ids - 1) * HEAP_ID_LEN];
+ curr_len_ptr = &shared_lens_g[(num_ids - 1)];
+ curr_off_ptr = &shared_offs_g[(num_ids - 1)];
} /* end if */
/* Insert last object into the heap, using the remaining free space */
- if(H5HF_insert(fh, dxpl, last_obj_len, obj, &ids[(num_ids - 1) * HEAP_ID_LEN]) < 0)
+ if(H5HF_insert(fh, dxpl, last_obj_len, wobj, curr_id_ptr) < 0)
FAIL_STACK_ERROR
+ *curr_len_ptr = last_obj_len;
+ *curr_off_ptr = obj_off;
+
+ /* Adjust state of heap */
+ state->nobjs++;
+ state->man_free_space -= last_obj_len;
/* Verify that the heap is full */
- if(check_stats(fh, heap_size, heap_size, (hsize_t)0, extra_free, (hsize_t)(num_ids + *nobjs_ptr)))
+ if(check_stats(fh, state))
FAIL_STACK_ERROR
} /* end if */
else
- last_obj_len = sizeof(obj); /* Normal sized last object */
+ last_obj_len = obj_size; /* Normal sized last object */
/* Verify reading the objects written out */
- for(v = 0; v < num_ids; v++) {
- /* Initialize object buffer */
- for(u = 0; u < sizeof(obj); u++)
- obj[u] = u + v;
+ /* Verify all the objects */
+ wobj = shared_wobj_g;
+ curr_id_ptr = shared_ids_g;
+ curr_len_ptr = shared_lens_g;
+ curr_off_ptr = shared_offs_g;
+ for(u = 0; u < num_ids; u++) {
/* Read in object */
- if(H5HF_read(fh, dxpl, &ids[v * HEAP_ID_LEN], robj) < 0)
+ if(H5HF_read(fh, dxpl, curr_id_ptr, shared_robj_g) < 0)
FAIL_STACK_ERROR
- if(HDmemcmp(obj, robj, (v == (num_ids - 1) ? last_obj_len : sizeof(obj))))
+
+ /* Check that object is correct */
+ wobj = &shared_wobj_g[*curr_off_ptr];
+ if(HDmemcmp(wobj, shared_robj_g, *curr_len_ptr))
FAIL_STACK_ERROR
+
+ /* Adjust object & ID pointers */
+ curr_id_ptr += HEAP_ID_LEN;
+ curr_len_ptr++;
+ curr_off_ptr++;
} /* end for */
- /* Set the number of objects inserted */
- *nobjs_ptr += num_ids;
+ /* If the heap IDs are to be retained, append them to the list */
+ if(keep_ids) {
+ /* Check for needing to increase size of heap ID array */
+ if(keep_ids->num_ids + num_ids > keep_ids->alloc_ids) {
+ keep_ids->alloc_ids = MAX(1024, (keep_ids->alloc_ids * 2));
+ if(NULL == (keep_ids->ids = H5MM_realloc(keep_ids->ids, HEAP_ID_LEN * keep_ids->alloc_ids)))
+ FAIL_STACK_ERROR
+ if(NULL == (keep_ids->lens = H5MM_realloc(keep_ids->lens, sizeof(size_t) * keep_ids->alloc_ids)))
+ FAIL_STACK_ERROR
+ if(NULL == (keep_ids->offs = H5MM_realloc(keep_ids->offs, sizeof(size_t) * keep_ids->alloc_ids)))
+ FAIL_STACK_ERROR
+ } /* end if */
+
+ /* Append the IDs onto the array */
+ HDmemcpy(&keep_ids->ids[keep_ids->num_ids * HEAP_ID_LEN], shared_ids_g, (num_ids * HEAP_ID_LEN));
+ HDmemcpy(&keep_ids->lens[keep_ids->num_ids], shared_lens_g, (num_ids * sizeof(size_t)));
+ HDmemcpy(&keep_ids->offs[keep_ids->num_ids], shared_offs_g, (num_ids * sizeof(size_t)));
+
+ /* Increment the number of IDs kept */
+ keep_ids->num_ids += num_ids;
+ } /* end if */
/* Operations succeeded */
- H5MM_xfree(ids);
return(0);
error:
- H5MM_xfree(ids);
return(1);
} /* fill_heap() */
@@ -400,30 +727,27 @@ error:
*-------------------------------------------------------------------------
*/
static int
-fill_root_row(H5HF_t *fh, hid_t dxpl, const H5HF_create_t *cparam,
- hsize_t *base_heap_size, hsize_t *base_free_space, unsigned row,
- unsigned *nobjs_ptr)
+fill_root_row(H5HF_t *fh, hid_t dxpl, unsigned row, size_t obj_size,
+ fheap_heap_state_t *state, fheap_heap_ids_t *keep_ids)
{
hsize_t first_free_space; /* Size of free space in heap after the first block */
hsize_t all_free_space; /* Size of free space in heap after all blocks */
- hsize_t free_space; /* Size of free space in heap */
hsize_t first_heap_size; /* Total size of the heap after the first block */
hsize_t all_heap_size; /* Total size of the heap after all blocks */
- hsize_t heap_size; /* Total size of the heap */
size_t block_size; /* Block size for row */
+ size_t block_free; /* Free space in empty block of this row */
+ unsigned width; /* Width of heap's doubling table */
unsigned expand_rows; /* # of rows to expand heap by */
unsigned u; /* Local index variable */
/* Sanity check */
- HDassert(nobjs_ptr);
- HDassert(base_heap_size);
- HDassert(base_free_space);
+ HDassert(fh);
+ HDassert(state);
- /* Get the correct size for blocks in this row */
- if(row == 0)
- block_size = cparam->managed.start_block_size;
- else
- block_size = cparam->managed.start_block_size * (1 << (row - 1));
+ /* Get some information for the heap */
+ block_size = DBLOCK_SIZE(fh, row);
+ block_free = DBLOCK_FREE(fh, row);
+ width = DTABLE_WIDTH(fh);
/* Compute the number of rows to expand heap by */
if(row < 2)
@@ -434,55 +758,51 @@ fill_root_row(H5HF_t *fh, hid_t dxpl, const H5HF_create_t *cparam,
expand_rows = 0;
/* Compute first block & all blocks heap size & free space */
- if(*base_heap_size == 0) {
+ if(state->heap_size == 0) {
first_heap_size = block_size;
- first_free_space = DBLOCK_FREE(fh, row);
- all_heap_size = cparam->managed.width * block_size;
- all_free_space = (cparam->managed.width - 1) * DBLOCK_FREE(fh, row);
+ first_free_space = block_free;
+ all_heap_size = width * block_size;
+ all_free_space = (width - 1) * block_free;
} /* end if */
- else if(expand_rows ==0) {
- all_heap_size = *base_heap_size;
- all_free_space = *base_free_space;
+ else if(expand_rows == 0) {
+ all_heap_size = state->heap_size;
+ all_free_space = state->man_free_space;
first_heap_size = all_heap_size;
first_free_space = all_free_space;
- all_free_space -= DBLOCK_FREE(fh, row); /* Account for shift from first free space */
+ all_free_space -= block_free; /* Account for shift from first free space */
} /* end if */
else {
- hsize_t block_mult; /* Base block size multiplier */
-
- all_heap_size = *base_heap_size;
+ all_heap_size = state->heap_size;
all_free_space = 0;
- block_mult = 1;
for(u = 0; u < expand_rows; u++) {
- all_heap_size += cparam->managed.width * block_size * block_mult;
- all_free_space += cparam->managed.width * DBLOCK_FREE(fh, row + u);
- block_mult *= 2;
+ all_heap_size += width * DBLOCK_SIZE(fh, row + u);
+ all_free_space += width * DBLOCK_FREE(fh, row + u);
} /* end for */
first_heap_size = all_heap_size;
first_free_space = all_free_space;
- all_free_space -= DBLOCK_FREE(fh, row); /* Account for shift from first free space */
+ all_free_space -= block_free; /* Account for shift from first free space */
} /* end else */
- /* Loop over filling direct blocks, until first root indirect row is full */
- heap_size = first_heap_size;
- free_space = first_free_space;
- for(u = 0; u < cparam->managed.width; u++) {
+ /* Loop over filling direct blocks, until root indirect row is full */
+ state->heap_size = first_heap_size;
+ state->man_size = first_heap_size;
+ state->man_free_space = first_free_space;
+ for(u = 0; u < width; u++) {
/* Set heap's size & free space correctly */
if(u == 1) {
- heap_size = all_heap_size;
- free_space = all_free_space;
+ state->heap_size = all_heap_size;
+ state->man_size = all_heap_size;
+ state->man_free_space = all_free_space;
} /* end if */
- free_space -= DBLOCK_FREE(fh, row);
+
+ /* Account for new block added */
+ state->man_alloc_size += block_size;
/* Fill a direct heap block up */
- if(fill_heap(fh, dxpl, cparam, heap_size, block_size, free_space, nobjs_ptr))
+ if(fill_heap(fh, dxpl, row, obj_size, state, keep_ids))
FAIL_STACK_ERROR
} /* end for */
- /* Update heap size & free space */
- *base_heap_size = heap_size;
- *base_free_space = free_space;
-
/* Operations succeeded */
return(0);
@@ -506,29 +826,28 @@ error:
*-------------------------------------------------------------------------
*/
static int
-fill_row(H5HF_t *fh, hid_t dxpl, const H5HF_create_t *cparam,
- hsize_t *heap_size, hsize_t *free_space, unsigned row,
- unsigned *nobjs_ptr)
+fill_row(H5HF_t *fh, hid_t dxpl, unsigned row, size_t obj_size,
+ fheap_heap_state_t *state, fheap_heap_ids_t *keep_ids)
{
- size_t block_size; /* Block size for row */
+ size_t block_size; /* Size of direct block in this row */
+ unsigned width; /* Width of heap's doubling table */
unsigned u; /* Local index variable */
/* Sanity check */
- HDassert(nobjs_ptr);
- HDassert(heap_size);
- HDassert(free_space);
+ HDassert(fh);
+ HDassert(state);
- /* Get the correct size for blocks in this row */
- if(row == 0)
- block_size = cparam->managed.start_block_size;
- else
- block_size = cparam->managed.start_block_size * (1 << (row - 1));
+ /* Get some information for the heap */
+ block_size = DBLOCK_SIZE(fh, row);
+ width = DTABLE_WIDTH(fh);
/* Loop over filling direct blocks, until indirect row is full */
- for(u = 0; u < cparam->managed.width; u++) {
+ for(u = 0; u < width; u++) {
+ /* Adjust stats for new block */
+ state->man_alloc_size += block_size;
+
/* Fill a direct heap block up */
- *free_space -= DBLOCK_FREE(fh, row);
- if(fill_heap(fh, dxpl, cparam, *heap_size, block_size, *free_space, nobjs_ptr))
+ if(fill_heap(fh, dxpl, row, obj_size, state, keep_ids))
FAIL_STACK_ERROR
} /* end for */
@@ -558,27 +877,21 @@ error:
*-------------------------------------------------------------------------
*/
static int
-fill_root_direct(H5HF_t *fh, hid_t dxpl, const H5HF_create_t *cparam,
- hsize_t *heap_size, hsize_t *free_space, unsigned *nobjs)
+fill_root_direct(H5HF_t *fh, hid_t dxpl, size_t obj_size,
+ fheap_heap_state_t *state, fheap_heap_ids_t *keep_ids)
{
- size_t block_size; /* Size of block added */
- unsigned nrows; /* Number of rows inserted */
+ unsigned max_dblock_rows; /* Max. # of direct block rows in indirect block */
+ unsigned row; /* Row being created */
+
+ /* Get heap info */
+ max_dblock_rows = DTABLE_MAX_DROWS(fh);
+ HDassert(max_dblock_rows);
/* Loop over rows */
- block_size = cparam->managed.start_block_size;
- nrows = 0;
- while(block_size <= cparam->managed.max_direct_size) {
- if(fill_root_row(fh, dxpl, cparam, heap_size, free_space, nrows, nobjs))
+ for(row = 0; row < max_dblock_rows; row++)
+ if(fill_root_row(fh, dxpl, row, obj_size, state, keep_ids))
FAIL_STACK_ERROR
- /* Adjust block size for row */
- if(nrows > 0)
- block_size *= 2;
-
- /* Increment row count */
- nrows++;
- } /* end for */
-
/* Operations succeeded */
return(0);
@@ -604,33 +917,20 @@ error:
*-------------------------------------------------------------------------
*/
static int
-fill_2nd_indirect(H5HF_t *fh, hid_t dxpl, const H5HF_create_t *cparam,
- hsize_t *heap_size, hsize_t *free_space, unsigned *nobjs,
- unsigned pos)
+fill_2nd_indirect(H5HF_t *fh, hid_t dxpl, unsigned pos, size_t obj_size,
+ fheap_heap_state_t *state, fheap_heap_ids_t *keep_ids)
{
- size_t iblock_size; /* Indirect block's size */
- size_t max_dblock_size; /* Max. size of direct block to add */
- size_t dblock_size; /* Size of direct block added */
- unsigned nrows; /* Number of rows inserted */
+ unsigned max_dblock_rows; /* Max. # of direct block rows in indirect block */
+ unsigned row; /* Current row to create */
+
+ /* Get some information for the heap */
+ max_dblock_rows = IBLOCK_MAX_DROWS(fh, pos);
+ HDassert(max_dblock_rows);
/* Loop over rows */
- nrows = 0;
- dblock_size = cparam->managed.start_block_size;
- iblock_size = cparam->managed.max_direct_size * (1 << pos);
- max_dblock_size = dblock_size * (1 << ((H5V_log2_of2(iblock_size / cparam->managed.width) -
- (H5V_log2_of2(cparam->managed.start_block_size) +
- H5V_log2_of2(cparam->managed.width))) + 1));
- while(dblock_size <= max_dblock_size) {
- if(fill_row(fh, dxpl, cparam, heap_size, free_space, nrows, nobjs))
- FAIL_STACK_ERROR
-
- /* Adjust block size for row */
- if(nrows > 0)
- dblock_size *= 2;
-
- /* Increment row count */
- nrows++;
- } /* end for */
+ for(row = 0; row < max_dblock_rows; row++)
+ if(fill_row(fh, dxpl, row, obj_size, state, keep_ids))
+ FAIL_STACK_ERROR
/* Operations succeeded */
return(0);
@@ -656,27 +956,21 @@ error:
*-------------------------------------------------------------------------
*/
static int
-fill_all_direct(H5HF_t *fh, hid_t dxpl, const H5HF_create_t *cparam,
- hsize_t *heap_size, hsize_t *free_space, unsigned *nobjs)
+fill_all_direct(H5HF_t *fh, hid_t dxpl, size_t obj_size,
+ fheap_heap_state_t *state, fheap_heap_ids_t *keep_ids)
{
- size_t dblock_size; /* Size of direct block added */
- unsigned nrows; /* Number of rows inserted */
+ unsigned max_dblock_rows; /* Max. # of direct block rows in indirect block */
+ unsigned row; /* Row being created */
+
+ /* Get heap info */
+ max_dblock_rows = DTABLE_MAX_DROWS(fh);
+ HDassert(max_dblock_rows);
/* Loop over rows */
- nrows = 0;
- dblock_size = cparam->managed.start_block_size;
- while(dblock_size <= cparam->managed.max_direct_size) {
- if(fill_row(fh, dxpl, cparam, heap_size, free_space, nrows, nobjs))
+ for(row = 0; row < max_dblock_rows; row++)
+ if(fill_row(fh, dxpl, row, obj_size, state, keep_ids))
FAIL_STACK_ERROR
- /* Adjust block size for row */
- if(nrows > 0)
- dblock_size *= 2;
-
- /* Increment row count */
- nrows++;
- } /* end for */
-
/* Operations succeeded */
return(0);
@@ -702,15 +996,18 @@ error:
*-------------------------------------------------------------------------
*/
static int
-fill_2nd_indirect_row(H5HF_t *fh, hid_t dxpl, const H5HF_create_t *cparam,
- hsize_t *heap_size, hsize_t *free_space, unsigned *nobjs,
- unsigned pos)
+fill_2nd_indirect_row(H5HF_t *fh, hid_t dxpl, unsigned pos, size_t obj_size,
+ fheap_heap_state_t *state, fheap_heap_ids_t *keep_ids)
{
+ unsigned width; /* Width of heap's doubling table */
unsigned u; /* Local index variable */
+ /* Get some information for the heap */
+ width = DTABLE_WIDTH(fh);
+
/* Loop over row of indirect blocks */
- for(u = 0; u < cparam->managed.width; u++)
- if(fill_2nd_indirect(fh, dxpl, cparam, heap_size, free_space, nobjs, pos))
+ for(u = 0; u < width; u++)
+ if(fill_2nd_indirect(fh, dxpl, pos, obj_size, state, keep_ids))
FAIL_STACK_ERROR
/* Operations succeeded */
@@ -738,14 +1035,18 @@ error:
*-------------------------------------------------------------------------
*/
static int
-fill_all_2nd_indirect_rows(H5HF_t *fh, hid_t dxpl, const H5HF_create_t *cparam,
- hsize_t *heap_size, hsize_t *free_space, unsigned *nobjs)
+fill_all_2nd_indirect_rows(H5HF_t *fh, hid_t dxpl, size_t obj_size,
+ fheap_heap_state_t *state, fheap_heap_ids_t *keep_ids)
{
+ unsigned width; /* Width of heap's doubling table */
unsigned u; /* Local index variable */
+ /* Get some information for the heap */
+ width = DTABLE_WIDTH(fh);
+
/* Loop over rows of 2nd level deep indirect blocks */
- for(u = 0; u < (H5V_log2_of2(cparam->managed.width) + 1); u++)
- if(fill_2nd_indirect_row(fh, dxpl, cparam, heap_size, free_space, nobjs, (u + 1)))
+ for(u = 0; u < (H5V_log2_of2(width) + 1); u++)
+ if(fill_2nd_indirect_row(fh, dxpl, (u + 1), obj_size, state, keep_ids))
FAIL_STACK_ERROR
/* Operations succeeded */
@@ -773,19 +1074,18 @@ error:
*-------------------------------------------------------------------------
*/
static int
-fill_3rd_indirect(H5HF_t *fh, hid_t dxpl, const H5HF_create_t *cparam,
- hsize_t *heap_size, hsize_t *free_space, unsigned *nobjs,
- unsigned pos)
+fill_3rd_indirect(H5HF_t *fh, hid_t dxpl, unsigned pos, size_t obj_size,
+ fheap_heap_state_t *state, fheap_heap_ids_t *keep_ids)
{
unsigned u; /* Local index variable */
/* Fill all direct block rows in third level indirect block */
- if(fill_all_direct(fh, dxpl, cparam, heap_size, free_space, nobjs))
+ if(fill_all_direct(fh, dxpl, obj_size, state, keep_ids))
FAIL_STACK_ERROR
/* Fill rows of recursive indirect blocks in third level indirect block */
for(u = 0; u < pos; u++)
- if(fill_2nd_indirect_row(fh, dxpl, cparam, heap_size, free_space, nobjs, (u + 1)))
+ if(fill_2nd_indirect_row(fh, dxpl, (u + 1), obj_size, state, keep_ids))
FAIL_STACK_ERROR
/* Operations succeeded */
@@ -813,16 +1113,19 @@ error:
*-------------------------------------------------------------------------
*/
static int
-fill_3rd_indirect_row(H5HF_t *fh, hid_t dxpl, const H5HF_create_t *cparam,
- hsize_t *heap_size, hsize_t *free_space, unsigned *nobjs,
- unsigned pos)
+fill_3rd_indirect_row(H5HF_t *fh, hid_t dxpl, unsigned pos, size_t obj_size,
+ fheap_heap_state_t *state, fheap_heap_ids_t *keep_ids)
{
+ unsigned width; /* Width of heap's doubling table */
unsigned u; /* Local index variable */
+ /* Get some information for the heap */
+ width = DTABLE_WIDTH(fh);
+
/* Loop over row of 3rd level indirect blocks */
- for(u = 0; u < cparam->managed.width; u++)
+ for(u = 0; u < width; u++)
/* Fill third level indirect block */
- if(fill_3rd_indirect(fh, dxpl, cparam, heap_size, free_space, nobjs, pos))
+ if(fill_3rd_indirect(fh, dxpl, pos, obj_size, state, keep_ids))
FAIL_STACK_ERROR
/* Operations succeeded */
@@ -850,15 +1153,19 @@ error:
*-------------------------------------------------------------------------
*/
static int
-fill_all_3rd_indirect_rows(H5HF_t *fh, hid_t dxpl, const H5HF_create_t *cparam,
- hsize_t *heap_size, hsize_t *free_space, unsigned *nobjs)
+fill_all_3rd_indirect_rows(H5HF_t *fh, hid_t dxpl, size_t obj_size,
+ fheap_heap_state_t *state, fheap_heap_ids_t *keep_ids)
{
+ unsigned width; /* Width of heap's doubling table */
unsigned u; /* Local index variable */
+ /* Get some information for the heap */
+ width = DTABLE_WIDTH(fh);
+
/* Loop over rows of 3rd level deep indirect blocks */
- for(u = 0; u < (H5V_log2_of2(cparam->managed.width) + 1); u++)
+ for(u = 0; u < (H5V_log2_of2(width) + 1); u++)
/* Fill row of 3rd level indirect blocks */
- if(fill_3rd_indirect_row(fh, dxpl, cparam, heap_size, free_space, nobjs, u + 1))
+ if(fill_3rd_indirect_row(fh, dxpl, (u + 1), obj_size, state, keep_ids))
FAIL_STACK_ERROR
/* Operations succeeded */
@@ -886,25 +1193,28 @@ error:
*-------------------------------------------------------------------------
*/
static int
-fill_4th_indirect_row(H5HF_t *fh, hid_t dxpl, const H5HF_create_t *cparam,
- hsize_t *heap_size, hsize_t *free_space, unsigned *nobjs,
- unsigned pos)
+fill_4th_indirect_row(H5HF_t *fh, hid_t dxpl, unsigned pos, size_t obj_size,
+ fheap_heap_state_t *state, fheap_heap_ids_t *keep_ids)
{
+ unsigned width; /* Width of heap's doubling table */
unsigned u, v; /* Local index variables */
+ /* Get some information for the heap */
+ width = DTABLE_WIDTH(fh);
+
/* Loop over row of 4th level indirect blocks */
- for(u = 0; u < cparam->managed.width; u++) {
+ for(u = 0; u < width; u++) {
/* Fill all direct block rows in fourth level indirect block */
- if(fill_all_direct(fh, dxpl, cparam, heap_size, free_space, nobjs))
+ if(fill_all_direct(fh, dxpl, obj_size, state, keep_ids))
FAIL_STACK_ERROR
/* Fill all rows of 2nd level deep indirect blocks in fourth level indirect block */
- if(fill_all_2nd_indirect_rows(fh, dxpl, cparam, heap_size, free_space, nobjs))
+ if(fill_all_2nd_indirect_rows(fh, dxpl, obj_size, state, keep_ids))
FAIL_STACK_ERROR
/* Fill rows of third level indirect blocks in fourth level indirect block */
for(v = 0; v < pos; v++)
- if(fill_3rd_indirect_row(fh, dxpl, cparam, heap_size, free_space, nobjs, (v + 1)))
+ if(fill_3rd_indirect_row(fh, dxpl, (v + 1), obj_size, state, keep_ids))
FAIL_STACK_ERROR
} /* end for */
@@ -933,39 +1243,37 @@ error:
*-------------------------------------------------------------------------
*/
static int
-fill_all_4th_indirect_rows(H5HF_t *fh, hid_t dxpl, const H5HF_create_t *cparam,
- hsize_t *heap_size, hsize_t *free_space, unsigned *nobjs)
+fill_all_4th_indirect_rows(H5HF_t *fh, hid_t dxpl, size_t obj_size,
+ fheap_heap_state_t *state, fheap_heap_ids_t *keep_ids)
{
+ unsigned width; /* Width of heap's doubling table */
unsigned u; /* Local index variable */
+ /* Get some information for the heap */
+ width = DTABLE_WIDTH(fh);
+
/* Loop over rows of 4th level deep indirect blocks */
- for(u = 0; u < (H5V_log2_of2(cparam->managed.width) + 1); u++) {
+ for(u = 0; u < (H5V_log2_of2(width) + 1); u++) {
/* Fill row of 4th level indirect blocks */
- if(fill_4th_indirect_row(fh, dxpl, cparam, heap_size, free_space, nobjs, (u + 1)))
+ if(fill_4th_indirect_row(fh, dxpl, (u + 1), obj_size, state, keep_ids))
FAIL_STACK_ERROR
/* Account for root indirect block doubling # of rows again */
/* (From 16 rows to the max. # of rows: 22) */
+ /* (Note: this is tied to the particular doubling table/heap creation parameters) */
if(u == 0) {
- hsize_t block_size; /* Current block size */
- hsize_t max_block_size; /* Maximum size of blocks in heap */
+ unsigned max_root_rows; /* Maximum # of rows in root indirect block */
unsigned row; /* Row in heap */
- /* Compute current & maximum block size in heap */
- block_size = cparam->managed.start_block_size * ((hsize_t)1 << 15);
- max_block_size = (((hsize_t)1 << cparam->managed.max_index) / 2) /
- cparam->managed.width;
+ /* Get some information for the heap */
+ max_root_rows = HEAP_MAX_ROOT_ROWS(fh);
/* Increase heap size & free space */
- row = 16;
- while(block_size <= max_block_size) {
- *heap_size += cparam->managed.width * block_size;
- *free_space += cparam->managed.width * DBLOCK_FREE(fh, row);
-
- /* Advance to next row */
- block_size *= 2;
- row++;
- } /* end while */
+ for(row = 16; row < max_root_rows; row++) {
+ state->heap_size += width * DBLOCK_SIZE(fh, row);
+ state->man_size += width * DBLOCK_SIZE(fh, row);
+ state->man_free_space += width * DBLOCK_FREE(fh, row);
+ } /* end for */
} /* end if */
} /* end for */
@@ -1000,6 +1308,7 @@ test_create(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t UNUSED *tparam
H5HF_create_t test_cparam; /* Creation parameters for heap */
H5HF_t *fh = NULL; /* Fractal heap wrapper */
size_t id_len; /* Size of fractal heap IDs */
+ fheap_heap_state_t state; /* State of fractal heap */
/* Set the filename to use for this test (dependent on fapl) */
h5_fixname(FILENAME[0], fapl, filename, sizeof(filename));
@@ -1022,7 +1331,8 @@ test_create(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t UNUSED *tparam
FAIL_STACK_ERROR
if(id_len > HEAP_ID_LEN)
FAIL_STACK_ERROR
- if(check_stats(fh, (hsize_t)0, (hsize_t)0, (hsize_t)0, (hsize_t)0, (hsize_t)0))
+ HDmemset(&state, 0, sizeof(fheap_heap_state_t));
+ if(check_stats(fh, &state))
FAIL_STACK_ERROR
PASSED()
@@ -1080,6 +1390,7 @@ test_reopen(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t UNUSED *tparam
H5HF_t *fh = NULL; /* Fractal heap wrapper */
haddr_t fh_addr; /* Address of fractal heap */
size_t id_len; /* Size of fractal heap IDs */
+ fheap_heap_state_t state; /* State of fractal heap */
/* Set the filename to use for this test (dependent on fapl) */
h5_fixname(FILENAME[0], fapl, filename, sizeof(filename));
@@ -1109,7 +1420,8 @@ test_reopen(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t UNUSED *tparam
FAIL_STACK_ERROR
if(!H5F_addr_defined(fh_addr))
FAIL_STACK_ERROR
- if(check_stats(fh, (hsize_t)0, (hsize_t)0, (hsize_t)0, (hsize_t)0, (hsize_t)0))
+ HDmemset(&state, 0, sizeof(fheap_heap_state_t));
+ if(check_stats(fh, &state))
FAIL_STACK_ERROR
/* Close the fractal heap */
@@ -1174,9 +1486,7 @@ test_abs_insert_first(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tpa
H5HF_t *fh = NULL; /* Fractal heap wrapper */
haddr_t fh_addr; /* Address of fractal heap */
size_t id_len; /* Size of fractal heap IDs */
- hsize_t free_space; /* Size of free space in heap */
- hsize_t heap_size; /* Total size of the heap */
- unsigned nobjs = 0; /* Total number of objects inserted */
+ fheap_heap_state_t state; /* State of fractal heap */
/* Set the filename to use for this test (dependent on fapl) */
h5_fixname(FILENAME[0], fapl, filename, sizeof(filename));
@@ -1200,7 +1510,8 @@ test_abs_insert_first(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tpa
FAIL_STACK_ERROR
if(!H5F_addr_defined(fh_addr))
FAIL_STACK_ERROR
- if(check_stats(fh, (hsize_t)0, (hsize_t)0, (hsize_t)0, (hsize_t)0, (hsize_t)0))
+ HDmemset(&state, 0, sizeof(fheap_heap_state_t));
+ if(check_stats(fh, &state))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -1218,9 +1529,11 @@ test_abs_insert_first(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tpa
* Test inserting first (small) object into absolute heap
*/
TESTING("inserting first (small) object into absolute heap");
- free_space = DBLOCK_FREE(fh, 0);
- heap_size = cparam->managed.start_block_size;
- if(add_obj(fh, dxpl, heap_size, &free_space, &nobjs, 10, SMALL_OBJ_SIZE1))
+ state.heap_size = DBLOCK_SIZE(fh, 0);
+ state.man_size = DBLOCK_SIZE(fh, 0);
+ state.man_alloc_size = DBLOCK_SIZE(fh, 0);
+ state.man_free_space = DBLOCK_FREE(fh, 0);
+ if(add_obj(fh, dxpl, 10, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -1235,7 +1548,7 @@ test_abs_insert_first(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tpa
} /* end if */
/* Check for correctly sized heap */
- if(check_stats(fh, heap_size, heap_size, (hsize_t)0, free_space, (hsize_t)1))
+ if(check_stats(fh, &state))
FAIL_STACK_ERROR
PASSED()
@@ -1285,8 +1598,7 @@ test_abs_insert_second(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tp
H5HF_t *fh = NULL; /* Fractal heap wrapper */
haddr_t fh_addr; /* Address of fractal heap */
size_t id_len; /* Size of fractal heap IDs */
- hsize_t free_space; /* Size of free space in heap */
- unsigned nobjs = 0; /* Total number of objects inserted */
+ fheap_heap_state_t state; /* State of fractal heap */
/* Set the filename to use for this test (dependent on fapl) */
h5_fixname(FILENAME[0], fapl, filename, sizeof(filename));
@@ -1310,13 +1622,17 @@ test_abs_insert_second(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tp
FAIL_STACK_ERROR
if(!H5F_addr_defined(fh_addr))
FAIL_STACK_ERROR
+ HDmemset(&state, 0, sizeof(fheap_heap_state_t));
/*
* Test inserting first (small) object into absolute heap
*/
TESTING("inserting two (small) objects into absolute heap");
- free_space = DBLOCK_FREE(fh, 0);
- if(add_obj(fh, dxpl, (hsize_t)cparam->managed.start_block_size, &free_space, &nobjs, 10, SMALL_OBJ_SIZE1))
+ state.heap_size = DBLOCK_SIZE(fh, 0);
+ state.man_size = DBLOCK_SIZE(fh, 0);
+ state.man_alloc_size = DBLOCK_SIZE(fh, 0);
+ state.man_free_space = DBLOCK_FREE(fh, 0);
+ if(add_obj(fh, dxpl, 10, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -1331,7 +1647,7 @@ test_abs_insert_second(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tp
} /* end if */
/* Insert second object */
- if(add_obj(fh, dxpl, (hsize_t)cparam->managed.start_block_size, &free_space, &nobjs, 20, SMALL_OBJ_SIZE2))
+ if(add_obj(fh, dxpl, 20, SMALL_OBJ_SIZE2, &state, NULL))
FAIL_STACK_ERROR
PASSED()
@@ -1382,7 +1698,7 @@ test_abs_insert_root_mult(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t
H5HF_t *fh = NULL; /* Fractal heap wrapper */
haddr_t fh_addr; /* Address of fractal heap */
size_t id_len; /* Size of fractal heap IDs */
- unsigned nobjs = 0; /* Number of objects inserted */
+ fheap_heap_state_t state; /* State of fractal heap */
/* Set the filename to use for this test (dependent on fapl) */
h5_fixname(FILENAME[0], fapl, filename, sizeof(filename));
@@ -1406,6 +1722,7 @@ test_abs_insert_root_mult(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t
FAIL_STACK_ERROR
if(!H5F_addr_defined(fh_addr))
FAIL_STACK_ERROR
+ HDmemset(&state, 0, sizeof(fheap_heap_state_t));
/*
* Test inserting mult. (small) object into absolute heap
@@ -1413,7 +1730,11 @@ test_abs_insert_root_mult(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t
TESTING("inserting objects to fill absolute heap's root direct block");
/* Fill the heap up */
- if(fill_heap(fh, dxpl, cparam, (hsize_t)cparam->managed.start_block_size, cparam->managed.start_block_size, (hsize_t)0, &nobjs))
+ state.heap_size = DBLOCK_SIZE(fh, 0);
+ state.man_size = DBLOCK_SIZE(fh, 0);
+ state.man_alloc_size = DBLOCK_SIZE(fh, 0);
+ state.man_free_space = DBLOCK_FREE(fh, 0);
+ if(fill_heap(fh, dxpl, 0, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -1476,9 +1797,7 @@ test_abs_insert_force_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_test_par
H5HF_t *fh = NULL; /* Fractal heap wrapper */
haddr_t fh_addr; /* Address of fractal heap */
size_t id_len; /* Size of fractal heap IDs */
- hsize_t free_space; /* Size of free space in heap */
- hsize_t heap_size; /* Total size of the heap */
- unsigned nobjs = 0; /* Number of objects inserted */
+ fheap_heap_state_t state; /* State of fractal heap */
/* Set the filename to use for this test (dependent on fapl) */
h5_fixname(FILENAME[0], fapl, filename, sizeof(filename));
@@ -1502,6 +1821,7 @@ test_abs_insert_force_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_test_par
FAIL_STACK_ERROR
if(!H5F_addr_defined(fh_addr))
FAIL_STACK_ERROR
+ HDmemset(&state, 0, sizeof(fheap_heap_state_t));
/*
* Test forcing creation of indirect root block & second direct block
@@ -1509,7 +1829,11 @@ test_abs_insert_force_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_test_par
TESTING("inserting objects to create root indirect block");
/* Fill the heap up */
- if(fill_heap(fh, dxpl, cparam, (hsize_t)cparam->managed.start_block_size, cparam->managed.start_block_size, (hsize_t)0, &nobjs))
+ state.heap_size = DBLOCK_SIZE(fh, 0);
+ state.man_size = DBLOCK_SIZE(fh, 0);
+ state.man_alloc_size = DBLOCK_SIZE(fh, 0);
+ state.man_free_space = DBLOCK_FREE(fh, 0);
+ if(fill_heap(fh, dxpl, 0, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -1524,9 +1848,11 @@ test_abs_insert_force_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_test_par
} /* end if */
/* Insert one more object, to force root indirect block creation */
- free_space = (cparam->managed.width - 1) * DBLOCK_FREE(fh, 0);
- heap_size = cparam->managed.width * cparam->managed.start_block_size;
- if(add_obj(fh, dxpl, heap_size, &free_space, &nobjs, 10, SMALL_OBJ_SIZE1))
+ state.heap_size = cparam->managed.width * DBLOCK_SIZE(fh, 0);
+ state.man_size = cparam->managed.width * DBLOCK_SIZE(fh, 0);
+ state.man_alloc_size += DBLOCK_SIZE(fh, 0);
+ state.man_free_space = (cparam->managed.width - 1) * DBLOCK_FREE(fh, 0);
+ if(add_obj(fh, dxpl, 10, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
PASSED()
@@ -1578,9 +1904,7 @@ test_abs_insert_fill_second(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_
H5HF_t *fh = NULL; /* Fractal heap wrapper */
haddr_t fh_addr; /* Address of fractal heap */
size_t id_len; /* Size of fractal heap IDs */
- hsize_t free_space; /* Size of free space in heap */
- hsize_t heap_size; /* Total size of the heap */
- unsigned nobjs = 0; /* Number of objects inserted */
+ fheap_heap_state_t state; /* State of fractal heap */
/* Set the filename to use for this test (dependent on fapl) */
h5_fixname(FILENAME[0], fapl, filename, sizeof(filename));
@@ -1604,6 +1928,7 @@ test_abs_insert_fill_second(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_
FAIL_STACK_ERROR
if(!H5F_addr_defined(fh_addr))
FAIL_STACK_ERROR
+ HDmemset(&state, 0, sizeof(fheap_heap_state_t));
/*
* Test inserting mult. (small) objects to fill second direct block
@@ -1611,7 +1936,11 @@ test_abs_insert_fill_second(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_
TESTING("inserting objects to fill second direct block");
/* Fill the first direct block heap up */
- if(fill_heap(fh, dxpl, cparam, (hsize_t)cparam->managed.start_block_size, cparam->managed.start_block_size, (hsize_t)0, &nobjs))
+ state.heap_size = DBLOCK_SIZE(fh, 0);
+ state.man_size = DBLOCK_SIZE(fh, 0);
+ state.man_alloc_size = DBLOCK_SIZE(fh, 0);
+ state.man_free_space = DBLOCK_FREE(fh, 0);
+ if(fill_heap(fh, dxpl, 0, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -1626,9 +1955,11 @@ test_abs_insert_fill_second(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_
} /* end if */
/* Fill the second direct block heap up (also creates initial root indirect block) */
- free_space = (cparam->managed.width - 2) * DBLOCK_FREE(fh, 0);
- heap_size = cparam->managed.width * cparam->managed.start_block_size;
- if(fill_heap(fh, dxpl, cparam, heap_size, cparam->managed.start_block_size, free_space, &nobjs))
+ state.heap_size = cparam->managed.width * DBLOCK_SIZE(fh, 0);
+ state.man_size = cparam->managed.width * DBLOCK_SIZE(fh, 0);
+ state.man_alloc_size += DBLOCK_SIZE(fh, 0);
+ state.man_free_space = (cparam->managed.width - 1) * DBLOCK_FREE(fh, 0);
+ if(fill_heap(fh, dxpl, 0, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
PASSED()
@@ -1681,9 +2012,7 @@ test_abs_insert_third_direct(hid_t fapl, H5HF_create_t *cparam, fheap_test_param
H5HF_t *fh = NULL; /* Fractal heap wrapper */
haddr_t fh_addr; /* Address of fractal heap */
size_t id_len; /* Size of fractal heap IDs */
- hsize_t free_space; /* Size of free space in heap */
- hsize_t heap_size; /* Total size of the heap */
- unsigned nobjs = 0; /* Number of objects inserted */
+ fheap_heap_state_t state; /* State of fractal heap */
/* Set the filename to use for this test (dependent on fapl) */
h5_fixname(FILENAME[0], fapl, filename, sizeof(filename));
@@ -1707,6 +2036,7 @@ test_abs_insert_third_direct(hid_t fapl, H5HF_create_t *cparam, fheap_test_param
FAIL_STACK_ERROR
if(!H5F_addr_defined(fh_addr))
FAIL_STACK_ERROR
+ HDmemset(&state, 0, sizeof(fheap_heap_state_t));
/*
* Test inserting mult. (small) objects to create third direct block
@@ -1714,13 +2044,19 @@ test_abs_insert_third_direct(hid_t fapl, H5HF_create_t *cparam, fheap_test_param
TESTING("inserting objects to create third direct block");
/* Fill the first direct block up */
- if(fill_heap(fh, dxpl, cparam, (hsize_t)cparam->managed.start_block_size, cparam->managed.start_block_size, (hsize_t)0, &nobjs))
+ state.heap_size = DBLOCK_SIZE(fh, 0);
+ state.man_size = DBLOCK_SIZE(fh, 0);
+ state.man_alloc_size = DBLOCK_SIZE(fh, 0);
+ state.man_free_space = DBLOCK_FREE(fh, 0);
+ if(fill_heap(fh, dxpl, 0, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Fill the second direct block heap up (also creates initial root indirect block) */
- free_space = (cparam->managed.width - 2) * DBLOCK_FREE(fh, 0);
- heap_size = cparam->managed.width * cparam->managed.start_block_size;
- if(fill_heap(fh, dxpl, cparam, heap_size, cparam->managed.start_block_size, free_space, &nobjs))
+ state.heap_size = cparam->managed.width * DBLOCK_SIZE(fh, 0);
+ state.man_size = cparam->managed.width * DBLOCK_SIZE(fh, 0);
+ state.man_alloc_size += DBLOCK_SIZE(fh, 0);
+ state.man_free_space = (cparam->managed.width - 1) * DBLOCK_FREE(fh, 0);
+ if(fill_heap(fh, dxpl, 0, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -1735,7 +2071,8 @@ test_abs_insert_third_direct(hid_t fapl, H5HF_create_t *cparam, fheap_test_param
} /* end if */
/* Insert one more object, to force creation of third direct block */
- if(add_obj(fh, dxpl, heap_size, &free_space, &nobjs, 10, SMALL_OBJ_SIZE1))
+ state.man_alloc_size += DBLOCK_SIZE(fh, 0);
+ if(add_obj(fh, dxpl, 10, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
PASSED()
@@ -1787,9 +2124,7 @@ test_abs_fill_first_row(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *t
H5HF_t *fh = NULL; /* Fractal heap wrapper */
haddr_t fh_addr; /* Address of fractal heap */
size_t id_len; /* Size of fractal heap IDs */
- hsize_t free_space; /* Size of free space in heap */
- hsize_t heap_size; /* Total size of heap */
- unsigned nobjs = 0; /* Total number of objects inserted */
+ fheap_heap_state_t state; /* State of fractal heap */
/* Set the filename to use for this test (dependent on fapl) */
h5_fixname(FILENAME[0], fapl, filename, sizeof(filename));
@@ -1813,6 +2148,7 @@ test_abs_fill_first_row(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *t
FAIL_STACK_ERROR
if(!H5F_addr_defined(fh_addr))
FAIL_STACK_ERROR
+ HDmemset(&state, 0, sizeof(fheap_heap_state_t));
/*
* Test inserting mult. (small) objects to fill first row in root indirect block
@@ -1820,9 +2156,7 @@ test_abs_fill_first_row(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *t
TESTING("inserting objects to fill first row of root indirect block");
/* Fill first row of [root] indirect block */
- heap_size = 0;
- free_space = 0;
- if(fill_root_row(fh, dxpl, cparam, &heap_size, &free_space, 0, &nobjs))
+ if(fill_root_row(fh, dxpl, 0, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -1885,9 +2219,7 @@ test_abs_start_second_row(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t
H5HF_t *fh = NULL; /* Fractal heap wrapper */
haddr_t fh_addr; /* Address of fractal heap */
size_t id_len; /* Size of fractal heap IDs */
- hsize_t free_space; /* Size of free space in heap */
- hsize_t heap_size; /* Total size of the heap */
- unsigned nobjs = 0; /* Number of objects inserted */
+ fheap_heap_state_t state; /* State of fractal heap */
/* Set the filename to use for this test (dependent on fapl) */
h5_fixname(FILENAME[0], fapl, filename, sizeof(filename));
@@ -1911,6 +2243,7 @@ test_abs_start_second_row(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t
FAIL_STACK_ERROR
if(!H5F_addr_defined(fh_addr))
FAIL_STACK_ERROR
+ HDmemset(&state, 0, sizeof(fheap_heap_state_t));
/*
* Test inserting mult. (small) objects to start second row in root indirect block
@@ -1918,9 +2251,7 @@ test_abs_start_second_row(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t
TESTING("inserting objects to start second row of root indirect block");
/* Fill first root indirect row */
- heap_size = 0;
- free_space = 0;
- if(fill_root_row(fh, dxpl, cparam, &heap_size, &free_space, 0, &nobjs))
+ if(fill_root_row(fh, dxpl, 0, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -1935,9 +2266,11 @@ test_abs_start_second_row(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t
} /* end if */
/* Insert one more object, to force expanding root indirect block to two rows */
- heap_size += cparam->managed.width * cparam->managed.start_block_size;
- free_space += cparam->managed.width * DBLOCK_FREE(fh, 1);
- if(add_obj(fh, dxpl, heap_size, &free_space, &nobjs, 10, SMALL_OBJ_SIZE1))
+ state.heap_size += cparam->managed.width * DBLOCK_SIZE(fh, 1);
+ state.man_size += cparam->managed.width * DBLOCK_SIZE(fh, 1);
+ state.man_alloc_size += DBLOCK_SIZE(fh, 1);
+ state.man_free_space = cparam->managed.width * DBLOCK_FREE(fh, 1);
+ if(add_obj(fh, dxpl, 10, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
PASSED()
@@ -1989,9 +2322,7 @@ test_abs_fill_second_row(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *
H5HF_t *fh = NULL; /* Fractal heap wrapper */
haddr_t fh_addr; /* Address of fractal heap */
size_t id_len; /* Size of fractal heap IDs */
- hsize_t free_space; /* Size of free space in heap */
- hsize_t heap_size; /* Total size of the heap */
- unsigned nobjs = 0; /* Number of objects inserted */
+ fheap_heap_state_t state; /* State of fractal heap */
/* Set the filename to use for this test (dependent on fapl) */
h5_fixname(FILENAME[0], fapl, filename, sizeof(filename));
@@ -2015,6 +2346,7 @@ test_abs_fill_second_row(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *
FAIL_STACK_ERROR
if(!H5F_addr_defined(fh_addr))
FAIL_STACK_ERROR
+ HDmemset(&state, 0, sizeof(fheap_heap_state_t));
/*
* Test inserting mult. (small) objects to start second row in root indirect block
@@ -2022,9 +2354,7 @@ test_abs_fill_second_row(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *
TESTING("inserting objects to fill second row of root indirect block");
/* Fill first root indirect row */
- heap_size = 0;
- free_space = 0;
- if(fill_root_row(fh, dxpl, cparam, &heap_size, &free_space, 0, &nobjs))
+ if(fill_root_row(fh, dxpl, 0, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -2039,7 +2369,7 @@ test_abs_fill_second_row(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *
} /* end if */
/* Fill second root indirect row */
- if(fill_root_row(fh, dxpl, cparam, &heap_size, &free_space, 1, &nobjs))
+ if(fill_root_row(fh, dxpl, 1, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
PASSED()
@@ -2092,9 +2422,7 @@ test_abs_start_third_row(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *
H5HF_t *fh = NULL; /* Fractal heap wrapper */
haddr_t fh_addr; /* Address of fractal heap */
size_t id_len; /* Size of fractal heap IDs */
- hsize_t free_space; /* Size of free space in heap */
- hsize_t heap_size; /* Total size of heap */
- unsigned nobjs = 0; /* Number of objects inserted */
+ fheap_heap_state_t state; /* State of fractal heap */
/* Set the filename to use for this test (dependent on fapl) */
h5_fixname(FILENAME[0], fapl, filename, sizeof(filename));
@@ -2118,6 +2446,7 @@ test_abs_start_third_row(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *
FAIL_STACK_ERROR
if(!H5F_addr_defined(fh_addr))
FAIL_STACK_ERROR
+ HDmemset(&state, 0, sizeof(fheap_heap_state_t));
/*
* Test inserting mult. (small) objects to start third row in root indirect block
@@ -2125,13 +2454,11 @@ test_abs_start_third_row(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *
TESTING("inserting objects to start third row of root indirect block");
/* Fill first root indirect row */
- heap_size = 0;
- free_space = 0;
- if(fill_root_row(fh, dxpl, cparam, &heap_size, &free_space, 0, &nobjs))
+ if(fill_root_row(fh, dxpl, 0, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Fill second root indirect row */
- if(fill_root_row(fh, dxpl, cparam, &heap_size, &free_space, 1, &nobjs))
+ if(fill_root_row(fh, dxpl, 1, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -2147,11 +2474,14 @@ test_abs_start_third_row(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *
/* Insert one more object, to force expanding root indirect block to four rows */
/* (Goes to four rows because it's doubling) */
- heap_size += cparam->managed.width * cparam->managed.start_block_size * 2;
- heap_size += cparam->managed.width * cparam->managed.start_block_size * 4;
- free_space += cparam->managed.width * DBLOCK_FREE(fh, 2);
- free_space += cparam->managed.width * DBLOCK_FREE(fh, 3);
- if(add_obj(fh, dxpl, heap_size, &free_space, &nobjs, 10, SMALL_OBJ_SIZE1))
+ state.heap_size += cparam->managed.width * DBLOCK_SIZE(fh, 2);
+ state.heap_size += cparam->managed.width * DBLOCK_SIZE(fh, 3);
+ state.man_size += cparam->managed.width * DBLOCK_SIZE(fh, 2);
+ state.man_size += cparam->managed.width * DBLOCK_SIZE(fh, 3);
+ state.man_alloc_size += DBLOCK_SIZE(fh, 2);
+ state.man_free_space += cparam->managed.width * DBLOCK_FREE(fh, 2);
+ state.man_free_space += cparam->managed.width * DBLOCK_FREE(fh, 3);
+ if(add_obj(fh, dxpl, 10, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
PASSED()
@@ -2203,9 +2533,7 @@ test_abs_fill_fourth_row(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *
H5HF_t *fh = NULL; /* Fractal heap wrapper */
haddr_t fh_addr; /* Address of fractal heap */
size_t id_len; /* Size of fractal heap IDs */
- unsigned nobjs = 0; /* Number of objects inserted */
- hsize_t free_space; /* Size of free space in heap */
- hsize_t heap_size; /* Total size of heap */
+ fheap_heap_state_t state; /* State of fractal heap */
unsigned u; /* Local index variables */
/* Set the filename to use for this test (dependent on fapl) */
@@ -2230,6 +2558,7 @@ test_abs_fill_fourth_row(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *
FAIL_STACK_ERROR
if(!H5F_addr_defined(fh_addr))
FAIL_STACK_ERROR
+ HDmemset(&state, 0, sizeof(fheap_heap_state_t));
/*
* Test inserting mult. (small) objects to fill four rows in root indirect block
@@ -2237,10 +2566,8 @@ test_abs_fill_fourth_row(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *
TESTING("inserting objects to fill four rows of root indirect block");
/* Loop over rows */
- heap_size = 0;
- free_space = 0;
for(u = 0; u < 4; u++)
- if(fill_root_row(fh, dxpl, cparam, &heap_size, &free_space, u, &nobjs))
+ if(fill_root_row(fh, dxpl, u, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -2303,9 +2630,7 @@ test_abs_fill_all_root_direct(hid_t fapl, H5HF_create_t *cparam, fheap_test_para
H5HF_t *fh = NULL; /* Fractal heap wrapper */
haddr_t fh_addr; /* Address of fractal heap */
size_t id_len; /* Size of fractal heap IDs */
- unsigned nobjs = 0; /* Number of objects inserted */
- hsize_t free_space; /* Size of free space in heap */
- hsize_t heap_size; /* Total size of heap */
+ fheap_heap_state_t state; /* State of fractal heap */
/* Set the filename to use for this test (dependent on fapl) */
h5_fixname(FILENAME[0], fapl, filename, sizeof(filename));
@@ -2329,6 +2654,7 @@ test_abs_fill_all_root_direct(hid_t fapl, H5HF_create_t *cparam, fheap_test_para
FAIL_STACK_ERROR
if(!H5F_addr_defined(fh_addr))
FAIL_STACK_ERROR
+ HDmemset(&state, 0, sizeof(fheap_heap_state_t));
/*
* Test inserting mult. (small) objects to fill all direct rows in root indirect block
@@ -2336,9 +2662,7 @@ test_abs_fill_all_root_direct(hid_t fapl, H5HF_create_t *cparam, fheap_test_para
TESTING("inserting objects to fill all direct rows of root indirect block");
/* Fill all direct blocks in root indirect block */
- heap_size = 0;
- free_space = 0;
- if(fill_root_direct(fh, dxpl, cparam, &heap_size, &free_space, &nobjs))
+ if(fill_root_direct(fh, dxpl, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -2401,9 +2725,7 @@ test_abs_first_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_test_
H5HF_t *fh = NULL; /* Fractal heap wrapper */
haddr_t fh_addr; /* Address of fractal heap */
size_t id_len; /* Size of fractal heap IDs */
- unsigned nobjs = 0; /* Number of objects inserted */
- hsize_t free_space; /* Size of free space in heap */
- hsize_t heap_size; /* Total size of heap */
+ fheap_heap_state_t state; /* State of fractal heap */
/* Set the filename to use for this test (dependent on fapl) */
h5_fixname(FILENAME[0], fapl, filename, sizeof(filename));
@@ -2427,6 +2749,7 @@ test_abs_first_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_test_
FAIL_STACK_ERROR
if(!H5F_addr_defined(fh_addr))
FAIL_STACK_ERROR
+ HDmemset(&state, 0, sizeof(fheap_heap_state_t));
/*
* Test inserting mult. (small) objects to force creation of first recursive indirect block
@@ -2434,9 +2757,7 @@ test_abs_first_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_test_
TESTING("inserting objects to create first recursive indirect block");
/* Fill direct blocks up */
- heap_size = 0;
- free_space = 0;
- if(fill_root_direct(fh, dxpl, cparam, &heap_size, &free_space, &nobjs))
+ if(fill_root_direct(fh, dxpl, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -2451,7 +2772,8 @@ test_abs_first_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_test_
} /* end if */
/* Insert one more object, to force creation of first recursive indirect block */
- if(add_obj(fh, dxpl, heap_size, &free_space, &nobjs, 10, SMALL_OBJ_SIZE1))
+ state.man_alloc_size += DBLOCK_SIZE(fh, 0);
+ if(add_obj(fh, dxpl, 10, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
PASSED()
@@ -2504,9 +2826,7 @@ test_abs_second_direct_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fhe
H5HF_t *fh = NULL; /* Fractal heap wrapper */
haddr_t fh_addr; /* Address of fractal heap */
size_t id_len; /* Size of fractal heap IDs */
- unsigned nobjs = 0; /* Number of objects inserted */
- hsize_t free_space; /* Size of free space in heap */
- hsize_t heap_size; /* Total size of heap */
+ fheap_heap_state_t state; /* State of fractal heap */
/* Set the filename to use for this test (dependent on fapl) */
h5_fixname(FILENAME[0], fapl, filename, sizeof(filename));
@@ -2530,6 +2850,7 @@ test_abs_second_direct_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fhe
FAIL_STACK_ERROR
if(!H5F_addr_defined(fh_addr))
FAIL_STACK_ERROR
+ HDmemset(&state, 0, sizeof(fheap_heap_state_t));
/*
* Test inserting mult. (small) objects to force creation of second direct
@@ -2538,14 +2859,12 @@ test_abs_second_direct_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fhe
TESTING("inserting objects to create second direct block in first recursive indirect block");
/* Fill direct blocks up */
- heap_size = 0;
- free_space = 0;
- if(fill_root_direct(fh, dxpl, cparam, &heap_size, &free_space, &nobjs))
+ if(fill_root_direct(fh, dxpl, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Fill the first direct block in the recursive indirect block up */
- free_space -= DBLOCK_FREE(fh, 0);
- if(fill_heap(fh, dxpl, cparam, heap_size, cparam->managed.start_block_size, free_space, &nobjs))
+ state.man_alloc_size += DBLOCK_SIZE(fh, 0);
+ if(fill_heap(fh, dxpl, 0, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -2562,7 +2881,8 @@ test_abs_second_direct_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fhe
/* Insert one more object, to force creation of second direct block in
* first recursive indirect block
*/
- if(add_obj(fh, dxpl, heap_size, &free_space, &nobjs, 10, SMALL_OBJ_SIZE1))
+ state.man_alloc_size += DBLOCK_SIZE(fh, 0);
+ if(add_obj(fh, dxpl, 10, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
PASSED()
@@ -2615,9 +2935,7 @@ test_abs_fill_first_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_
H5HF_t *fh = NULL; /* Fractal heap wrapper */
haddr_t fh_addr; /* Address of fractal heap */
size_t id_len; /* Size of fractal heap IDs */
- unsigned nobjs = 0; /* Number of objects inserted */
- hsize_t free_space; /* Size of free space in heap */
- hsize_t heap_size; /* Total size of heap */
+ fheap_heap_state_t state; /* State of fractal heap */
/* Set the filename to use for this test (dependent on fapl) */
h5_fixname(FILENAME[0], fapl, filename, sizeof(filename));
@@ -2641,6 +2959,7 @@ test_abs_fill_first_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_
FAIL_STACK_ERROR
if(!H5F_addr_defined(fh_addr))
FAIL_STACK_ERROR
+ HDmemset(&state, 0, sizeof(fheap_heap_state_t));
/*
* Test inserting mult. (small) objects to fill all direct
@@ -2649,9 +2968,7 @@ test_abs_fill_first_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_
TESTING("inserting objects to fill all direct blocks in first recursive indirect block");
/* Fill direct blocks up in root indirect block */
- heap_size = 0;
- free_space = 0;
- if(fill_root_direct(fh, dxpl, cparam, &heap_size, &free_space, &nobjs))
+ if(fill_root_direct(fh, dxpl, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -2666,7 +2983,7 @@ test_abs_fill_first_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_
} /* end if */
/* Fill first recursive indirect block */
- if(fill_2nd_indirect(fh, dxpl, cparam, &heap_size, &free_space, &nobjs, 1))
+ if(fill_2nd_indirect(fh, dxpl, 1, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
PASSED()
@@ -2720,9 +3037,7 @@ test_abs_second_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_test
H5HF_t *fh = NULL; /* Fractal heap wrapper */
haddr_t fh_addr; /* Address of fractal heap */
size_t id_len; /* Size of fractal heap IDs */
- unsigned nobjs = 0; /* Number of objects inserted */
- hsize_t free_space; /* Size of free space in heap */
- hsize_t heap_size; /* Total size of heap */
+ fheap_heap_state_t state; /* State of fractal heap */
/* Set the filename to use for this test (dependent on fapl) */
h5_fixname(FILENAME[0], fapl, filename, sizeof(filename));
@@ -2746,6 +3061,7 @@ test_abs_second_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_test
FAIL_STACK_ERROR
if(!H5F_addr_defined(fh_addr))
FAIL_STACK_ERROR
+ HDmemset(&state, 0, sizeof(fheap_heap_state_t));
/*
* Test inserting mult. (small) objects to fill all direct
@@ -2754,13 +3070,11 @@ test_abs_second_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_test
TESTING("inserting objects to start second recursive indirect block");
/* Fill direct blocks up in root indirect block */
- heap_size = 0;
- free_space = 0;
- if(fill_root_direct(fh, dxpl, cparam, &heap_size, &free_space, &nobjs))
+ if(fill_root_direct(fh, dxpl, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Fill first recursive indirect block */
- if(fill_2nd_indirect(fh, dxpl, cparam, &heap_size, &free_space, &nobjs, 1))
+ if(fill_2nd_indirect(fh, dxpl, 1, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -2777,7 +3091,8 @@ test_abs_second_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_test
/* Insert one more object, to force creation of second
* recursive indirect block
*/
- if(add_obj(fh, dxpl, heap_size, &free_space, &nobjs, 10, SMALL_OBJ_SIZE1))
+ state.man_alloc_size += DBLOCK_SIZE(fh, 0);
+ if(add_obj(fh, dxpl, 10, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
PASSED()
@@ -2832,9 +3147,7 @@ test_abs_fill_second_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fheap
H5HF_t *fh = NULL; /* Fractal heap wrapper */
haddr_t fh_addr; /* Address of fractal heap */
size_t id_len; /* Size of fractal heap IDs */
- unsigned nobjs = 0; /* Number of objects inserted */
- hsize_t free_space; /* Size of free space in heap */
- hsize_t heap_size; /* Total size of heap */
+ fheap_heap_state_t state; /* State of fractal heap */
/* Set the filename to use for this test (dependent on fapl) */
h5_fixname(FILENAME[0], fapl, filename, sizeof(filename));
@@ -2858,6 +3171,7 @@ test_abs_fill_second_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fheap
FAIL_STACK_ERROR
if(!H5F_addr_defined(fh_addr))
FAIL_STACK_ERROR
+ HDmemset(&state, 0, sizeof(fheap_heap_state_t));
/*
* Test inserting mult. (small) objects to fill all direct
@@ -2866,13 +3180,11 @@ test_abs_fill_second_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fheap
TESTING("inserting objects to fill all direct blocks in second recursive indirect block");
/* Fill direct blocks up in root indirect block */
- heap_size = 0;
- free_space = 0;
- if(fill_root_direct(fh, dxpl, cparam, &heap_size, &free_space, &nobjs))
+ if(fill_root_direct(fh, dxpl, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Fill first recursive indirect block */
- if(fill_2nd_indirect(fh, dxpl, cparam, &heap_size, &free_space, &nobjs, 1))
+ if(fill_2nd_indirect(fh, dxpl, 1, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -2887,7 +3199,7 @@ test_abs_fill_second_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fheap
} /* end if */
/* Fill 2nd recursive indirect block */
- if(fill_2nd_indirect(fh, dxpl, cparam, &heap_size, &free_space, &nobjs, 1))
+ if(fill_2nd_indirect(fh, dxpl, 1, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
PASSED()
@@ -2942,9 +3254,7 @@ test_abs_fill_recursive_indirect_row(hid_t fapl, H5HF_create_t *cparam, fheap_te
H5HF_t *fh = NULL; /* Fractal heap wrapper */
haddr_t fh_addr; /* Address of fractal heap */
size_t id_len; /* Size of fractal heap IDs */
- unsigned nobjs = 0; /* Number of objects inserted */
- hsize_t free_space; /* Size of free space in heap */
- hsize_t heap_size; /* Total size of heap */
+ fheap_heap_state_t state; /* State of fractal heap */
/* Set the filename to use for this test (dependent on fapl) */
h5_fixname(FILENAME[0], fapl, filename, sizeof(filename));
@@ -2968,6 +3278,7 @@ test_abs_fill_recursive_indirect_row(hid_t fapl, H5HF_create_t *cparam, fheap_te
FAIL_STACK_ERROR
if(!H5F_addr_defined(fh_addr))
FAIL_STACK_ERROR
+ HDmemset(&state, 0, sizeof(fheap_heap_state_t));
/*
* Test inserting mult. (small) objects to fill all direct
@@ -2976,9 +3287,7 @@ test_abs_fill_recursive_indirect_row(hid_t fapl, H5HF_create_t *cparam, fheap_te
TESTING("inserting objects to fill all direct blocks in first row of recursive indirect block");
/* Fill direct blocks in root indirect block up */
- heap_size = 0;
- free_space = 0;
- if(fill_root_direct(fh, dxpl, cparam, &heap_size, &free_space, &nobjs))
+ if(fill_root_direct(fh, dxpl, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -2993,7 +3302,7 @@ test_abs_fill_recursive_indirect_row(hid_t fapl, H5HF_create_t *cparam, fheap_te
} /* end if */
/* Fill row of recursive indirect blocks */
- if(fill_2nd_indirect_row(fh, dxpl, cparam, &heap_size, &free_space, &nobjs, 1))
+ if(fill_2nd_indirect_row(fh, dxpl, 1, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
PASSED()
@@ -3046,9 +3355,7 @@ test_abs_start_2nd_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_t
H5HF_t *fh = NULL; /* Fractal heap wrapper */
haddr_t fh_addr; /* Address of fractal heap */
size_t id_len; /* Size of fractal heap IDs */
- unsigned nobjs = 0; /* Number of objects inserted */
- hsize_t free_space; /* Size of free space in heap */
- hsize_t heap_size; /* Total size of heap */
+ fheap_heap_state_t state; /* State of fractal heap */
/* Set the filename to use for this test (dependent on fapl) */
h5_fixname(FILENAME[0], fapl, filename, sizeof(filename));
@@ -3072,6 +3379,7 @@ test_abs_start_2nd_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_t
FAIL_STACK_ERROR
if(!H5F_addr_defined(fh_addr))
FAIL_STACK_ERROR
+ HDmemset(&state, 0, sizeof(fheap_heap_state_t));
/*
* Test inserting mult. (small) objects to fill all direct
@@ -3080,13 +3388,11 @@ test_abs_start_2nd_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_t
TESTING("inserting objects to start second row of recursive indirect blocks");
/* Fill direct blocks in root indirect block up */
- heap_size = 0;
- free_space = 0;
- if(fill_root_direct(fh, dxpl, cparam, &heap_size, &free_space, &nobjs))
+ if(fill_root_direct(fh, dxpl, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Fill row of recursive indirect blocks */
- if(fill_2nd_indirect_row(fh, dxpl, cparam, &heap_size, &free_space, &nobjs, 1))
+ if(fill_2nd_indirect_row(fh, dxpl, 1, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -3103,7 +3409,8 @@ test_abs_start_2nd_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_t
/* Insert one more object, to force creation of second
* recursive indirect block
*/
- if(add_obj(fh, dxpl, heap_size, &free_space, &nobjs, 10, SMALL_OBJ_SIZE1))
+ state.man_alloc_size += DBLOCK_SIZE(fh, 0);
+ if(add_obj(fh, dxpl, 10, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
PASSED()
@@ -3156,9 +3463,7 @@ test_abs_recursive_indirect_two_deep(hid_t fapl, H5HF_create_t *cparam, fheap_te
H5HF_t *fh = NULL; /* Fractal heap wrapper */
haddr_t fh_addr; /* Address of fractal heap */
size_t id_len; /* Size of fractal heap IDs */
- unsigned nobjs = 0; /* Number of objects inserted */
- hsize_t free_space; /* Size of free space in heap */
- hsize_t heap_size; /* Total size of heap */
+ fheap_heap_state_t state; /* State of fractal heap */
/* Set the filename to use for this test (dependent on fapl) */
h5_fixname(FILENAME[0], fapl, filename, sizeof(filename));
@@ -3182,6 +3487,7 @@ test_abs_recursive_indirect_two_deep(hid_t fapl, H5HF_create_t *cparam, fheap_te
FAIL_STACK_ERROR
if(!H5F_addr_defined(fh_addr))
FAIL_STACK_ERROR
+ HDmemset(&state, 0, sizeof(fheap_heap_state_t));
/*
* Test inserting mult. (small) objects to fill all direct
@@ -3190,9 +3496,7 @@ test_abs_recursive_indirect_two_deep(hid_t fapl, H5HF_create_t *cparam, fheap_te
TESTING("inserting objects to fill recursive indirect blocks two levels deep");
/* Fill direct blocks up in root indirect block */
- heap_size = 0;
- free_space = 0;
- if(fill_root_direct(fh, dxpl, cparam, &heap_size, &free_space, &nobjs))
+ if(fill_root_direct(fh, dxpl, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -3207,7 +3511,7 @@ test_abs_recursive_indirect_two_deep(hid_t fapl, H5HF_create_t *cparam, fheap_te
} /* end if */
/* Fill all rows of 2nd level indirect blocks */
- if(fill_all_2nd_indirect_rows(fh, dxpl, cparam, &heap_size, &free_space, &nobjs))
+ if(fill_all_2nd_indirect_rows(fh, dxpl, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
PASSED()
@@ -3261,9 +3565,7 @@ test_abs_start_3rd_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_t
H5HF_t *fh = NULL; /* Fractal heap wrapper */
haddr_t fh_addr; /* Address of fractal heap */
size_t id_len; /* Size of fractal heap IDs */
- unsigned nobjs = 0; /* Number of objects inserted */
- hsize_t free_space; /* Size of free space in heap */
- hsize_t heap_size; /* Total size of heap */
+ fheap_heap_state_t state; /* State of fractal heap */
/* Set the filename to use for this test (dependent on fapl) */
h5_fixname(FILENAME[0], fapl, filename, sizeof(filename));
@@ -3287,6 +3589,7 @@ test_abs_start_3rd_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_t
FAIL_STACK_ERROR
if(!H5F_addr_defined(fh_addr))
FAIL_STACK_ERROR
+ HDmemset(&state, 0, sizeof(fheap_heap_state_t));
/*
* Test inserting mult. (small) objects to fill all direct
@@ -3295,13 +3598,11 @@ test_abs_start_3rd_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_t
TESTING("inserting objects to start recursive indirect blocks three levels deep");
/* Fill direct blocks up in root indirect block */
- heap_size = 0;
- free_space = 0;
- if(fill_root_direct(fh, dxpl, cparam, &heap_size, &free_space, &nobjs))
+ if(fill_root_direct(fh, dxpl, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Fill all rows of 2nd level indirect blocks */
- if(fill_all_2nd_indirect_rows(fh, dxpl, cparam, &heap_size, &free_space, &nobjs))
+ if(fill_all_2nd_indirect_rows(fh, dxpl, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -3318,7 +3619,8 @@ test_abs_start_3rd_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_t
/* Insert one more object, to force creation of third level deep
* recursive indirect block
*/
- if(add_obj(fh, dxpl, heap_size, &free_space, &nobjs, 10, SMALL_OBJ_SIZE1))
+ state.man_alloc_size += DBLOCK_SIZE(fh, 0);
+ if(add_obj(fh, dxpl, 10, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
PASSED()
@@ -3372,9 +3674,7 @@ test_abs_fill_first_3rd_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fh
H5HF_t *fh = NULL; /* Fractal heap wrapper */
haddr_t fh_addr; /* Address of fractal heap */
size_t id_len; /* Size of fractal heap IDs */
- unsigned nobjs = 0; /* Number of objects inserted */
- hsize_t free_space; /* Size of free space in heap */
- hsize_t heap_size; /* Total size of heap */
+ fheap_heap_state_t state; /* State of fractal heap */
/* Set the filename to use for this test (dependent on fapl) */
h5_fixname(FILENAME[0], fapl, filename, sizeof(filename));
@@ -3398,6 +3698,7 @@ test_abs_fill_first_3rd_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fh
FAIL_STACK_ERROR
if(!H5F_addr_defined(fh_addr))
FAIL_STACK_ERROR
+ HDmemset(&state, 0, sizeof(fheap_heap_state_t));
/*
* Test inserting mult. (small) objects to fill all direct
@@ -3406,17 +3707,15 @@ test_abs_fill_first_3rd_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fh
TESTING("inserting objects to fill first indirect block of recursive indirect blocks three levels deep");
/* Fill direct blocks up in root indirect block */
- heap_size = 0;
- free_space = 0;
- if(fill_root_direct(fh, dxpl, cparam, &heap_size, &free_space, &nobjs))
+ if(fill_root_direct(fh, dxpl, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Fill all rows of 2nd level indirect blocks */
- if(fill_all_2nd_indirect_rows(fh, dxpl, cparam, &heap_size, &free_space, &nobjs))
+ if(fill_all_2nd_indirect_rows(fh, dxpl, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Fill all direct block rows in third level indirect block */
- if(fill_all_direct(fh, dxpl, cparam, &heap_size, &free_space, &nobjs))
+ if(fill_all_direct(fh, dxpl, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -3431,7 +3730,7 @@ test_abs_fill_first_3rd_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fh
} /* end if */
/* Fill row of recursive indirect blocks in third level indirect block */
- if(fill_2nd_indirect_row(fh, dxpl, cparam, &heap_size, &free_space, &nobjs, 1))
+ if(fill_2nd_indirect_row(fh, dxpl, 1, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
PASSED()
@@ -3485,9 +3784,7 @@ test_abs_fill_3rd_recursive_indirect_row(hid_t fapl, H5HF_create_t *cparam, fhea
H5HF_t *fh = NULL; /* Fractal heap wrapper */
haddr_t fh_addr; /* Address of fractal heap */
size_t id_len; /* Size of fractal heap IDs */
- unsigned nobjs = 0; /* Number of objects inserted */
- hsize_t free_space; /* Size of free space in heap */
- hsize_t heap_size; /* Total size of heap */
+ fheap_heap_state_t state; /* State of fractal heap */
/* Set the filename to use for this test (dependent on fapl) */
h5_fixname(FILENAME[0], fapl, filename, sizeof(filename));
@@ -3511,6 +3808,7 @@ test_abs_fill_3rd_recursive_indirect_row(hid_t fapl, H5HF_create_t *cparam, fhea
FAIL_STACK_ERROR
if(!H5F_addr_defined(fh_addr))
FAIL_STACK_ERROR
+ HDmemset(&state, 0, sizeof(fheap_heap_state_t));
/*
* Test inserting mult. (small) objects to fill all direct
@@ -3519,13 +3817,11 @@ test_abs_fill_3rd_recursive_indirect_row(hid_t fapl, H5HF_create_t *cparam, fhea
TESTING("inserting objects to fill row of indirect blocks in recursive indirect blocks three levels deep");
/* Fill direct blocks up in root indirect block */
- heap_size = 0;
- free_space = 0;
- if(fill_root_direct(fh, dxpl, cparam, &heap_size, &free_space, &nobjs))
+ if(fill_root_direct(fh, dxpl, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Fill all rows of 2nd level indirect blocks */
- if(fill_all_2nd_indirect_rows(fh, dxpl, cparam, &heap_size, &free_space, &nobjs))
+ if(fill_all_2nd_indirect_rows(fh, dxpl, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -3540,7 +3836,7 @@ test_abs_fill_3rd_recursive_indirect_row(hid_t fapl, H5HF_create_t *cparam, fhea
} /* end if */
/* Fill 1st row of 3rd level indirect blocks */
- if(fill_3rd_indirect_row(fh, dxpl, cparam, &heap_size, &free_space, &nobjs, 1))
+ if(fill_3rd_indirect_row(fh, dxpl, 1, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
PASSED()
@@ -3594,9 +3890,7 @@ test_abs_fill_all_3rd_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fhea
H5HF_t *fh = NULL; /* Fractal heap wrapper */
haddr_t fh_addr; /* Address of fractal heap */
size_t id_len; /* Size of fractal heap IDs */
- unsigned nobjs = 0; /* Number of objects inserted */
- hsize_t free_space; /* Size of free space in heap */
- hsize_t heap_size; /* Total size of heap */
+ fheap_heap_state_t state; /* State of fractal heap */
/* Set the filename to use for this test (dependent on fapl) */
h5_fixname(FILENAME[0], fapl, filename, sizeof(filename));
@@ -3620,6 +3914,7 @@ test_abs_fill_all_3rd_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fhea
FAIL_STACK_ERROR
if(!H5F_addr_defined(fh_addr))
FAIL_STACK_ERROR
+ HDmemset(&state, 0, sizeof(fheap_heap_state_t));
/*
* Test inserting mult. (small) objects to fill all direct
@@ -3628,13 +3923,11 @@ test_abs_fill_all_3rd_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fhea
TESTING("inserting objects to fill row of indirect blocks in recursive indirect blocks three levels deep");
/* Fill direct blocks up in root indirect block */
- heap_size = 0;
- free_space = 0;
- if(fill_root_direct(fh, dxpl, cparam, &heap_size, &free_space, &nobjs))
+ if(fill_root_direct(fh, dxpl, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Fill all rows of 2nd level indirect blocks */
- if(fill_all_2nd_indirect_rows(fh, dxpl, cparam, &heap_size, &free_space, &nobjs))
+ if(fill_all_2nd_indirect_rows(fh, dxpl, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -3649,7 +3942,7 @@ test_abs_fill_all_3rd_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fhea
} /* end if */
/* Fill all rows of 3rd level indirect blocks */
- if(fill_all_3rd_indirect_rows(fh, dxpl, cparam, &heap_size, &free_space, &nobjs))
+ if(fill_all_3rd_indirect_rows(fh, dxpl, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
PASSED()
@@ -3704,9 +3997,7 @@ test_abs_start_4th_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_t
H5HF_t *fh = NULL; /* Fractal heap wrapper */
haddr_t fh_addr; /* Address of fractal heap */
size_t id_len; /* Size of fractal heap IDs */
- unsigned nobjs = 0; /* Number of objects inserted */
- hsize_t free_space; /* Size of free space in heap */
- hsize_t heap_size; /* Total size of heap */
+ fheap_heap_state_t state; /* State of fractal heap */
/* Set the filename to use for this test (dependent on fapl) */
h5_fixname(FILENAME[0], fapl, filename, sizeof(filename));
@@ -3730,6 +4021,7 @@ test_abs_start_4th_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_t
FAIL_STACK_ERROR
if(!H5F_addr_defined(fh_addr))
FAIL_STACK_ERROR
+ HDmemset(&state, 0, sizeof(fheap_heap_state_t));
/*
* Test inserting mult. (small) objects to fill all direct
@@ -3738,17 +4030,15 @@ test_abs_start_4th_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_t
TESTING("inserting objects to start first direct block in recursive indirect blocks four levels deep");
/* Fill direct blocks up in root indirect block */
- heap_size = 0;
- free_space = 0;
- if(fill_root_direct(fh, dxpl, cparam, &heap_size, &free_space, &nobjs))
+ if(fill_root_direct(fh, dxpl, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Fill all rows of 2nd level indirect blocks */
- if(fill_all_2nd_indirect_rows(fh, dxpl, cparam, &heap_size, &free_space, &nobjs))
+ if(fill_all_2nd_indirect_rows(fh, dxpl, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Fill all rows of 3rd level indirect blocks */
- if(fill_all_3rd_indirect_rows(fh, dxpl, cparam, &heap_size, &free_space, &nobjs))
+ if(fill_all_3rd_indirect_rows(fh, dxpl, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -3765,7 +4055,8 @@ test_abs_start_4th_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_t
/* Insert one more object, to force creation of four level deep
* recursive indirect block
*/
- if(add_obj(fh, dxpl, heap_size, &free_space, &nobjs, 10, SMALL_OBJ_SIZE1))
+ state.man_alloc_size += DBLOCK_SIZE(fh, 0);
+ if(add_obj(fh, dxpl, 10, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
PASSED()
@@ -3820,9 +4111,7 @@ test_abs_fill_first_4th_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fh
H5HF_t *fh = NULL; /* Fractal heap wrapper */
haddr_t fh_addr; /* Address of fractal heap */
size_t id_len; /* Size of fractal heap IDs */
- unsigned nobjs = 0; /* Number of objects inserted */
- hsize_t free_space; /* Size of free space in heap */
- hsize_t heap_size; /* Total size of heap */
+ fheap_heap_state_t state; /* State of fractal heap */
/* Set the filename to use for this test (dependent on fapl) */
h5_fixname(FILENAME[0], fapl, filename, sizeof(filename));
@@ -3846,6 +4135,7 @@ test_abs_fill_first_4th_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fh
FAIL_STACK_ERROR
if(!H5F_addr_defined(fh_addr))
FAIL_STACK_ERROR
+ HDmemset(&state, 0, sizeof(fheap_heap_state_t));
/*
* Test inserting mult. (small) objects to fill all direct
@@ -3854,25 +4144,23 @@ test_abs_fill_first_4th_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fh
TESTING("inserting objects to fill first (3rd level) indirect block in recursive indirect block four levels deep");
/* Fill direct blocks up in root indirect block */
- heap_size = 0;
- free_space = 0;
- if(fill_root_direct(fh, dxpl, cparam, &heap_size, &free_space, &nobjs))
+ if(fill_root_direct(fh, dxpl, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Fill all rows of 2nd level indirect blocks */
- if(fill_all_2nd_indirect_rows(fh, dxpl, cparam, &heap_size, &free_space, &nobjs))
+ if(fill_all_2nd_indirect_rows(fh, dxpl, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Fill all rows of 3rd level indirect blocks */
- if(fill_all_3rd_indirect_rows(fh, dxpl, cparam, &heap_size, &free_space, &nobjs))
+ if(fill_all_3rd_indirect_rows(fh, dxpl, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Fill direct block rows in fourth level indirect block */
- if(fill_all_direct(fh, dxpl, cparam, &heap_size, &free_space, &nobjs))
+ if(fill_all_direct(fh, dxpl, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Fill all rows of 2nd level deep indirect blocks in fourth level indirect block */
- if(fill_all_2nd_indirect_rows(fh, dxpl, cparam, &heap_size, &free_space, &nobjs))
+ if(fill_all_2nd_indirect_rows(fh, dxpl, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -3887,7 +4175,7 @@ test_abs_fill_first_4th_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fh
} /* end if */
/* Fill first row of 3rd level deep indirect blocks in fourth level indirect block */
- if(fill_3rd_indirect_row(fh, dxpl, cparam, &heap_size, &free_space, &nobjs, 1))
+ if(fill_3rd_indirect_row(fh, dxpl, 1, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
PASSED()
@@ -3942,9 +4230,7 @@ test_abs_fill_4th_recursive_indirect_row(hid_t fapl, H5HF_create_t *cparam, fhea
H5HF_t *fh = NULL; /* Fractal heap wrapper */
haddr_t fh_addr; /* Address of fractal heap */
size_t id_len; /* Size of fractal heap IDs */
- unsigned nobjs = 0; /* Number of objects inserted */
- hsize_t free_space; /* Size of free space in heap */
- hsize_t heap_size; /* Total size of heap */
+ fheap_heap_state_t state; /* State of fractal heap */
/* Set the filename to use for this test (dependent on fapl) */
h5_fixname(FILENAME[0], fapl, filename, sizeof(filename));
@@ -3968,6 +4254,7 @@ test_abs_fill_4th_recursive_indirect_row(hid_t fapl, H5HF_create_t *cparam, fhea
FAIL_STACK_ERROR
if(!H5F_addr_defined(fh_addr))
FAIL_STACK_ERROR
+ HDmemset(&state, 0, sizeof(fheap_heap_state_t));
/*
* Test inserting mult. (small) objects to fill all direct
@@ -3976,17 +4263,15 @@ test_abs_fill_4th_recursive_indirect_row(hid_t fapl, H5HF_create_t *cparam, fhea
TESTING("inserting objects to fill first row of recursive indirect blocks four levels deep");
/* Fill direct blocks up in root indirect block */
- heap_size = 0;
- free_space = 0;
- if(fill_root_direct(fh, dxpl, cparam, &heap_size, &free_space, &nobjs))
+ if(fill_root_direct(fh, dxpl, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Fill all rows of 2nd level indirect blocks */
- if(fill_all_2nd_indirect_rows(fh, dxpl, cparam, &heap_size, &free_space, &nobjs))
+ if(fill_all_2nd_indirect_rows(fh, dxpl, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Fill all rows of 3rd level indirect blocks */
- if(fill_all_3rd_indirect_rows(fh, dxpl, cparam, &heap_size, &free_space, &nobjs))
+ if(fill_all_3rd_indirect_rows(fh, dxpl, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -4001,7 +4286,7 @@ test_abs_fill_4th_recursive_indirect_row(hid_t fapl, H5HF_create_t *cparam, fhea
} /* end if */
/* Fill 1st row of 4th level indirect blocks */
- if(fill_4th_indirect_row(fh, dxpl, cparam, &heap_size, &free_space, &nobjs, 1))
+ if(fill_4th_indirect_row(fh, dxpl, 1, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
PASSED()
@@ -4056,9 +4341,7 @@ test_abs_fill_all_4th_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fhea
H5HF_t *fh = NULL; /* Fractal heap wrapper */
haddr_t fh_addr; /* Address of fractal heap */
size_t id_len; /* Size of fractal heap IDs */
- unsigned nobjs = 0; /* Number of objects inserted */
- hsize_t free_space; /* Size of free space in heap */
- hsize_t heap_size; /* Total size of heap */
+ fheap_heap_state_t state; /* State of fractal heap */
/* Set the filename to use for this test (dependent on fapl) */
h5_fixname(FILENAME[0], fapl, filename, sizeof(filename));
@@ -4082,6 +4365,7 @@ test_abs_fill_all_4th_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fhea
FAIL_STACK_ERROR
if(!H5F_addr_defined(fh_addr))
FAIL_STACK_ERROR
+ HDmemset(&state, 0, sizeof(fheap_heap_state_t));
/*
* Test inserting mult. (small) objects to fill all direct
@@ -4090,17 +4374,15 @@ test_abs_fill_all_4th_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fhea
TESTING("inserting objects to fill all rows of recursive indirect blocks four levels deep");
/* Fill direct blocks up in root indirect block */
- heap_size = 0;
- free_space = 0;
- if(fill_root_direct(fh, dxpl, cparam, &heap_size, &free_space, &nobjs))
+ if(fill_root_direct(fh, dxpl, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Fill all rows of 2nd level indirect blocks */
- if(fill_all_2nd_indirect_rows(fh, dxpl, cparam, &heap_size, &free_space, &nobjs))
+ if(fill_all_2nd_indirect_rows(fh, dxpl, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Fill all rows of 3rd level indirect blocks */
- if(fill_all_3rd_indirect_rows(fh, dxpl, cparam, &heap_size, &free_space, &nobjs))
+ if(fill_all_3rd_indirect_rows(fh, dxpl, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -4115,7 +4397,7 @@ test_abs_fill_all_4th_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fhea
} /* end if */
/* Fill all rows of 4th level indirect blocks */
- if(fill_all_4th_indirect_rows(fh, dxpl, cparam, &heap_size, &free_space, &nobjs))
+ if(fill_all_4th_indirect_rows(fh, dxpl, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
PASSED()
@@ -4173,9 +4455,7 @@ test_abs_start_5th_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_t
H5HF_t *fh = NULL; /* Fractal heap wrapper */
haddr_t fh_addr; /* Address of fractal heap */
size_t id_len; /* Size of fractal heap IDs */
- unsigned nobjs = 0; /* Number of objects inserted */
- hsize_t free_space; /* Size of free space in heap */
- hsize_t heap_size; /* Total size of heap */
+ fheap_heap_state_t state; /* State of fractal heap */
/* Set the filename to use for this test (dependent on fapl) */
h5_fixname(FILENAME[0], fapl, filename, sizeof(filename));
@@ -4199,6 +4479,7 @@ test_abs_start_5th_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_t
FAIL_STACK_ERROR
if(!H5F_addr_defined(fh_addr))
FAIL_STACK_ERROR
+ HDmemset(&state, 0, sizeof(fheap_heap_state_t));
/*
* Test inserting mult. (small) objects to fill all direct
@@ -4208,9 +4489,7 @@ test_abs_start_5th_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_t
TESTING("inserting objects to create first direct block in recursive indirect blocks five levels deep");
/* Fill direct blocks up in root indirect block */
- heap_size = 0;
- free_space = 0;
- if(fill_root_direct(fh, dxpl, cparam, &heap_size, &free_space, &nobjs))
+ if(fill_root_direct(fh, dxpl, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -4225,7 +4504,7 @@ test_abs_start_5th_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_t
} /* end if */
/* Fill all rows of 2nd level indirect blocks */
- if(fill_all_2nd_indirect_rows(fh, dxpl, cparam, &heap_size, &free_space, &nobjs))
+ if(fill_all_2nd_indirect_rows(fh, dxpl, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -4240,7 +4519,7 @@ test_abs_start_5th_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_t
} /* end if */
/* Fill all rows of 3rd level indirect blocks */
- if(fill_all_3rd_indirect_rows(fh, dxpl, cparam, &heap_size, &free_space, &nobjs))
+ if(fill_all_3rd_indirect_rows(fh, dxpl, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -4255,7 +4534,7 @@ test_abs_start_5th_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_t
} /* end if */
/* Fill all rows of 4th level indirect blocks */
- if(fill_all_4th_indirect_rows(fh, dxpl, cparam, &heap_size, &free_space, &nobjs))
+ if(fill_all_4th_indirect_rows(fh, dxpl, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -4272,7 +4551,8 @@ test_abs_start_5th_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_t
/* Insert one more object, to force creation of five level deep
* recursive indirect block
*/
- if(add_obj(fh, dxpl, heap_size, &free_space, &nobjs, 10, SMALL_OBJ_SIZE1))
+ state.man_alloc_size += DBLOCK_SIZE(fh, 0);
+ if(add_obj(fh, dxpl, 10, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
PASSED()
@@ -4326,10 +4606,8 @@ test_abs_skip_start_block(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t
H5HF_t *fh = NULL; /* Fractal heap wrapper */
haddr_t fh_addr; /* Address of fractal heap */
size_t id_len; /* Size of fractal heap IDs */
- unsigned nobjs = 0; /* Number of objects inserted */
size_t obj_size; /* Size of object */
- hsize_t free_space; /* Size of free space in heap */
- hsize_t heap_size; /* Total size of heap */
+ fheap_heap_state_t state; /* State of fractal heap */
/* Set the filename to use for this test (dependent on fapl) */
h5_fixname(FILENAME[0], fapl, filename, sizeof(filename));
@@ -4353,7 +4631,8 @@ test_abs_skip_start_block(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t
FAIL_STACK_ERROR
if(!H5F_addr_defined(fh_addr))
FAIL_STACK_ERROR
- if(check_stats(fh, (hsize_t)0, (hsize_t)0, (hsize_t)0, (hsize_t)0, (hsize_t)0))
+ HDmemset(&state, 0, sizeof(fheap_heap_state_t));
+ if(check_stats(fh, &state))
FAIL_STACK_ERROR
/*
@@ -4362,12 +4641,18 @@ test_abs_skip_start_block(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t
*/
TESTING("inserting object that is too large for starting block");
- obj_size = cparam->managed.start_block_size + 1;
- free_space = 2 * cparam->managed.width * DBLOCK_FREE(fh, 0);
- free_space += cparam->managed.width * DBLOCK_FREE(fh, 2);
- heap_size = 2 * cparam->managed.width * cparam->managed.start_block_size;
- heap_size += cparam->managed.width * (cparam->managed.start_block_size * 2);
- if(add_obj(fh, dxpl, heap_size, &free_space, &nobjs, 10, obj_size))
+ obj_size = DBLOCK_SIZE(fh, 0) + 1;
+ state.heap_size = cparam->managed.width * DBLOCK_SIZE(fh, 0);
+ state.heap_size += cparam->managed.width * DBLOCK_SIZE(fh, 1);
+ state.heap_size += cparam->managed.width * DBLOCK_SIZE(fh, 2);
+ state.man_size = cparam->managed.width * DBLOCK_SIZE(fh, 0);
+ state.man_size += cparam->managed.width * DBLOCK_SIZE(fh, 1);
+ state.man_size += cparam->managed.width * DBLOCK_SIZE(fh, 2);
+ state.man_alloc_size = DBLOCK_SIZE(fh, 2);
+ state.man_free_space = cparam->managed.width * DBLOCK_FREE(fh, 0);
+ state.man_free_space += cparam->managed.width * DBLOCK_FREE(fh, 1);
+ state.man_free_space += cparam->managed.width * DBLOCK_FREE(fh, 2);
+ if(add_obj(fh, dxpl, 10, obj_size, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -4430,10 +4715,8 @@ test_abs_skip_start_block_add_back(hid_t fapl, H5HF_create_t *cparam, fheap_test
H5HF_t *fh = NULL; /* Fractal heap wrapper */
haddr_t fh_addr; /* Address of fractal heap */
size_t id_len; /* Size of fractal heap IDs */
- unsigned nobjs = 0; /* Number of objects inserted */
size_t obj_size; /* Size of object */
- hsize_t free_space; /* Size of free space in heap */
- hsize_t heap_size; /* Total size of heap */
+ fheap_heap_state_t state; /* State of fractal heap */
/* Set the filename to use for this test (dependent on fapl) */
h5_fixname(FILENAME[0], fapl, filename, sizeof(filename));
@@ -4457,7 +4740,8 @@ test_abs_skip_start_block_add_back(hid_t fapl, H5HF_create_t *cparam, fheap_test
FAIL_STACK_ERROR
if(!H5F_addr_defined(fh_addr))
FAIL_STACK_ERROR
- if(check_stats(fh, (hsize_t)0, (hsize_t)0, (hsize_t)0, (hsize_t)0, (hsize_t)0))
+ HDmemset(&state, 0, sizeof(fheap_heap_state_t));
+ if(check_stats(fh, &state))
FAIL_STACK_ERROR
/*
@@ -4467,12 +4751,18 @@ test_abs_skip_start_block_add_back(hid_t fapl, H5HF_create_t *cparam, fheap_test
TESTING("skipping starting block, then adding object back to first block");
/* Insert object too large for starting block size */
- obj_size = cparam->managed.start_block_size + 1;
- free_space = 2 * cparam->managed.width * DBLOCK_FREE(fh, 0);
- free_space += cparam->managed.width * DBLOCK_FREE(fh, 2);
- heap_size = 2 * cparam->managed.width * cparam->managed.start_block_size;
- heap_size += cparam->managed.width * (cparam->managed.start_block_size * 2);
- if(add_obj(fh, dxpl, heap_size, &free_space, &nobjs, 10, obj_size))
+ obj_size = DBLOCK_SIZE(fh, 0) + 1;
+ state.heap_size = cparam->managed.width * DBLOCK_SIZE(fh, 0);
+ state.heap_size += cparam->managed.width * DBLOCK_SIZE(fh, 1);
+ state.heap_size += cparam->managed.width * DBLOCK_SIZE(fh, 2);
+ state.man_size = cparam->managed.width * DBLOCK_SIZE(fh, 0);
+ state.man_size += cparam->managed.width * DBLOCK_SIZE(fh, 1);
+ state.man_size += cparam->managed.width * DBLOCK_SIZE(fh, 2);
+ state.man_alloc_size = DBLOCK_SIZE(fh, 2);
+ state.man_free_space = cparam->managed.width * DBLOCK_FREE(fh, 0);
+ state.man_free_space += cparam->managed.width * DBLOCK_FREE(fh, 1);
+ state.man_free_space += cparam->managed.width * DBLOCK_FREE(fh, 2);
+ if(add_obj(fh, dxpl, 10, obj_size, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -4488,7 +4778,7 @@ test_abs_skip_start_block_add_back(hid_t fapl, H5HF_create_t *cparam, fheap_test
/* Insert an object to fill up the heap block just created */
obj_size = DBLOCK_FREE(fh, 2) - obj_size;
- if(add_obj(fh, dxpl, heap_size, &free_space, &nobjs, 10, obj_size))
+ if(add_obj(fh, dxpl, 10, obj_size, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -4503,7 +4793,8 @@ test_abs_skip_start_block_add_back(hid_t fapl, H5HF_create_t *cparam, fheap_test
} /* end if */
/* Insert second "real" object, which should go in earlier direct block */
- if(add_obj(fh, dxpl, heap_size, &free_space, &nobjs, 20, SMALL_OBJ_SIZE2))
+ state.man_alloc_size += DBLOCK_SIZE(fh, 0);
+ if(add_obj(fh, dxpl, 20, SMALL_OBJ_SIZE2, &state, NULL))
FAIL_STACK_ERROR
PASSED()
@@ -4556,10 +4847,8 @@ test_abs_skip_start_block_add_skipped(hid_t fapl, H5HF_create_t *cparam, fheap_t
H5HF_t *fh = NULL; /* Fractal heap wrapper */
haddr_t fh_addr; /* Address of fractal heap */
size_t id_len; /* Size of fractal heap IDs */
- unsigned nobjs = 0; /* Number of objects inserted */
size_t obj_size; /* Size of object */
- hsize_t free_space; /* Size of free space in heap */
- hsize_t heap_size; /* Total size of heap */
+ fheap_heap_state_t state; /* State of fractal heap */
/* Set the filename to use for this test (dependent on fapl) */
h5_fixname(FILENAME[0], fapl, filename, sizeof(filename));
@@ -4583,7 +4872,8 @@ test_abs_skip_start_block_add_skipped(hid_t fapl, H5HF_create_t *cparam, fheap_t
FAIL_STACK_ERROR
if(!H5F_addr_defined(fh_addr))
FAIL_STACK_ERROR
- if(check_stats(fh, (hsize_t)0, (hsize_t)0, (hsize_t)0, (hsize_t)0, (hsize_t)0))
+ HDmemset(&state, 0, sizeof(fheap_heap_state_t));
+ if(check_stats(fh, &state))
FAIL_STACK_ERROR
/*
@@ -4593,12 +4883,18 @@ test_abs_skip_start_block_add_skipped(hid_t fapl, H5HF_create_t *cparam, fheap_t
TESTING("skipping starting block, then adding objects to backfill and extend");
/* Insert object too large for starting block size */
- obj_size = cparam->managed.start_block_size + 1;
- free_space = 2 * cparam->managed.width * DBLOCK_FREE(fh, 0);
- free_space += cparam->managed.width * DBLOCK_FREE(fh, 2);
- heap_size = 2 * cparam->managed.width * cparam->managed.start_block_size;
- heap_size += cparam->managed.width * (cparam->managed.start_block_size * 2);
- if(add_obj(fh, dxpl, heap_size, &free_space, &nobjs, 10, obj_size))
+ obj_size = DBLOCK_SIZE(fh, 0) + 1;
+ state.heap_size = cparam->managed.width * DBLOCK_SIZE(fh, 0);
+ state.heap_size += cparam->managed.width * DBLOCK_SIZE(fh, 1);
+ state.heap_size += cparam->managed.width * DBLOCK_SIZE(fh, 2);
+ state.man_size = cparam->managed.width * DBLOCK_SIZE(fh, 0);
+ state.man_size += cparam->managed.width * DBLOCK_SIZE(fh, 1);
+ state.man_size += cparam->managed.width * DBLOCK_SIZE(fh, 2);
+ state.man_alloc_size = DBLOCK_SIZE(fh, 2);
+ state.man_free_space = cparam->managed.width * DBLOCK_FREE(fh, 0);
+ state.man_free_space += cparam->managed.width * DBLOCK_FREE(fh, 1);
+ state.man_free_space += cparam->managed.width * DBLOCK_FREE(fh, 2);
+ if(add_obj(fh, dxpl, 10, obj_size, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -4614,7 +4910,7 @@ test_abs_skip_start_block_add_skipped(hid_t fapl, H5HF_create_t *cparam, fheap_t
/* Insert an object to fill up the heap block just created */
obj_size = DBLOCK_FREE(fh, 2) - obj_size;
- if(add_obj(fh, dxpl, heap_size, &free_space, &nobjs, 10, obj_size))
+ if(add_obj(fh, dxpl, 10, obj_size, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -4629,9 +4925,9 @@ test_abs_skip_start_block_add_skipped(hid_t fapl, H5HF_create_t *cparam, fheap_t
} /* end if */
/* Add rows of blocks to "backfill" direct blocks that were skipped */
- if(fill_row(fh, dxpl, cparam, &heap_size, &free_space, 0, &nobjs))
+ if(fill_row(fh, dxpl, 0, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
- if(fill_row(fh, dxpl, cparam, &heap_size, &free_space, 1, &nobjs))
+ if(fill_row(fh, dxpl, 1, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -4645,8 +4941,9 @@ test_abs_skip_start_block_add_skipped(hid_t fapl, H5HF_create_t *cparam, fheap_t
FAIL_STACK_ERROR
} /* end if */
- /* Insert another object, which should go extend direct blocks, instead of backfill */
- if(add_obj(fh, dxpl, heap_size, &free_space, &nobjs, 20, SMALL_OBJ_SIZE2))
+ /* Insert another object, which should extend direct blocks, instead of backfill */
+ state.man_alloc_size += DBLOCK_SIZE(fh, 2);
+ if(add_obj(fh, dxpl, 20, SMALL_OBJ_SIZE2, &state, NULL))
FAIL_STACK_ERROR
PASSED()
@@ -4699,10 +4996,8 @@ test_abs_skip_2nd_block(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *t
H5HF_t *fh = NULL; /* Fractal heap wrapper */
haddr_t fh_addr; /* Address of fractal heap */
size_t id_len; /* Size of fractal heap IDs */
- unsigned nobjs = 0; /* Number of objects inserted */
size_t obj_size; /* Size of object */
- hsize_t free_space; /* Size of free space in heap */
- hsize_t heap_size; /* Total size of heap */
+ fheap_heap_state_t state; /* State of fractal heap */
/* Set the filename to use for this test (dependent on fapl) */
h5_fixname(FILENAME[0], fapl, filename, sizeof(filename));
@@ -4726,6 +5021,7 @@ test_abs_skip_2nd_block(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *t
FAIL_STACK_ERROR
if(!H5F_addr_defined(fh_addr))
FAIL_STACK_ERROR
+ HDmemset(&state, 0, sizeof(fheap_heap_state_t));
/*
* Test inserting first (small) object into absolute heap
@@ -4733,10 +5029,11 @@ test_abs_skip_2nd_block(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *t
TESTING("insert object to initial block, then add object too large for starting direct blocks");
/* Insert small object, to create root direct block */
- obj_size = SMALL_OBJ_SIZE1;
- free_space = DBLOCK_FREE(fh, 0);
- heap_size = cparam->managed.start_block_size;
- if(add_obj(fh, dxpl, heap_size, &free_space, &nobjs, 10, obj_size))
+ state.heap_size = DBLOCK_SIZE(fh, 0);
+ state.man_size = DBLOCK_SIZE(fh, 0);
+ state.man_alloc_size = DBLOCK_SIZE(fh, 0);
+ state.man_free_space = DBLOCK_FREE(fh, 0);
+ if(add_obj(fh, dxpl, 10, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -4753,14 +5050,18 @@ test_abs_skip_2nd_block(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *t
/* Insert large object, to force creation of indirect block and
* range of skipped blocks that are too small to hold the second object
*/
- obj_size = cparam->managed.start_block_size + 1;
- free_space += (cparam->managed.width - 1 )* DBLOCK_FREE(fh, 0);
- free_space += cparam->managed.width * DBLOCK_FREE(fh, 1);
- free_space += cparam->managed.width * DBLOCK_FREE(fh, 2);
- heap_size += (cparam->managed.width - 1) * cparam->managed.start_block_size;
- heap_size += cparam->managed.width * cparam->managed.start_block_size;
- heap_size += cparam->managed.width * cparam->managed.start_block_size * 2;
- if(add_obj(fh, dxpl, heap_size, &free_space, &nobjs, 20, obj_size))
+ obj_size = DBLOCK_SIZE(fh, 0) + 1;
+ state.heap_size += (cparam->managed.width - 1) * DBLOCK_SIZE(fh, 0);
+ state.heap_size += cparam->managed.width * DBLOCK_SIZE(fh, 1);
+ state.heap_size += cparam->managed.width * DBLOCK_SIZE(fh, 2);
+ state.man_size += (cparam->managed.width - 1) * DBLOCK_SIZE(fh, 0);
+ state.man_size += cparam->managed.width * DBLOCK_SIZE(fh, 1);
+ state.man_size += cparam->managed.width * DBLOCK_SIZE(fh, 2);
+ state.man_alloc_size += DBLOCK_SIZE(fh, 2);
+ state.man_free_space += (cparam->managed.width - 1 )* DBLOCK_FREE(fh, 0);
+ state.man_free_space += cparam->managed.width * DBLOCK_FREE(fh, 1);
+ state.man_free_space += cparam->managed.width * DBLOCK_FREE(fh, 2);
+ if(add_obj(fh, dxpl, 20, obj_size, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -4827,11 +5128,9 @@ test_abs_skip_2nd_block_add_skipped(hid_t fapl, H5HF_create_t *cparam, fheap_tes
H5HF_t *fh = NULL; /* Fractal heap wrapper */
haddr_t fh_addr; /* Address of fractal heap */
size_t id_len; /* Size of fractal heap IDs */
- unsigned nobjs = 0; /* Number of objects inserted */
size_t obj_size; /* Size of object */
- hsize_t free_space; /* Size of free space in heap */
- hsize_t heap_size; /* Total size of heap */
- unsigned u, v; /* Local index variables */
+ fheap_heap_state_t state; /* State of fractal heap */
+ unsigned v; /* Local index variables */
/* Set the filename to use for this test (dependent on fapl) */
h5_fixname(FILENAME[0], fapl, filename, sizeof(filename));
@@ -4855,6 +5154,7 @@ test_abs_skip_2nd_block_add_skipped(hid_t fapl, H5HF_create_t *cparam, fheap_tes
FAIL_STACK_ERROR
if(!H5F_addr_defined(fh_addr))
FAIL_STACK_ERROR
+ HDmemset(&state, 0, sizeof(fheap_heap_state_t));
/*
* Test inserting first (small) object into absolute heap
@@ -4862,10 +5162,11 @@ test_abs_skip_2nd_block_add_skipped(hid_t fapl, H5HF_create_t *cparam, fheap_tes
TESTING("insert object to initial block, then add object too large for starting direct blocks, then backfill and extend");
/* Insert small object, to create root direct block */
- obj_size = SMALL_OBJ_SIZE1;
- free_space = DBLOCK_FREE(fh, 0);
- heap_size = cparam->managed.start_block_size;
- if(add_obj(fh, dxpl, heap_size, &free_space, &nobjs, 10, obj_size))
+ state.heap_size = DBLOCK_SIZE(fh, 0);
+ state.man_size = DBLOCK_SIZE(fh, 0);
+ state.man_alloc_size = DBLOCK_SIZE(fh, 0);
+ state.man_free_space = DBLOCK_FREE(fh, 0);
+ if(add_obj(fh, dxpl, 10, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -4882,14 +5183,18 @@ test_abs_skip_2nd_block_add_skipped(hid_t fapl, H5HF_create_t *cparam, fheap_tes
/* Insert large object, to force creation of indirect block and
* range of skipped blocks that are too small to hold the second object
*/
- obj_size = cparam->managed.start_block_size + 1;
- free_space += (cparam->managed.width - 1 )* DBLOCK_FREE(fh, 0);
- free_space += cparam->managed.width * DBLOCK_FREE(fh, 1);
- free_space += cparam->managed.width * DBLOCK_FREE(fh, 2);
- heap_size += (cparam->managed.width - 1) * cparam->managed.start_block_size;
- heap_size += cparam->managed.width * cparam->managed.start_block_size;
- heap_size += cparam->managed.width * cparam->managed.start_block_size * 2;
- if(add_obj(fh, dxpl, heap_size, &free_space, &nobjs, 20, obj_size))
+ obj_size = DBLOCK_SIZE(fh, 0) + 1;
+ state.heap_size += (cparam->managed.width - 1) * DBLOCK_SIZE(fh, 0);
+ state.heap_size += cparam->managed.width * DBLOCK_SIZE(fh, 1);
+ state.heap_size += cparam->managed.width * DBLOCK_SIZE(fh, 2);
+ state.man_size += (cparam->managed.width - 1) * DBLOCK_SIZE(fh, 0);
+ state.man_size += cparam->managed.width * DBLOCK_SIZE(fh, 1);
+ state.man_size += cparam->managed.width * DBLOCK_SIZE(fh, 2);
+ state.man_alloc_size += DBLOCK_SIZE(fh, 2);
+ state.man_free_space += (cparam->managed.width - 1 )* DBLOCK_FREE(fh, 0);
+ state.man_free_space += cparam->managed.width * DBLOCK_FREE(fh, 1);
+ state.man_free_space += cparam->managed.width * DBLOCK_FREE(fh, 2);
+ if(add_obj(fh, dxpl, 20, obj_size, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -4905,7 +5210,7 @@ test_abs_skip_2nd_block_add_skipped(hid_t fapl, H5HF_create_t *cparam, fheap_tes
/* Insert an object to fill up the (smaller) heap block just created */
obj_size = DBLOCK_FREE(fh, 0) - SMALL_OBJ_SIZE1;
- if(add_obj(fh, dxpl, heap_size, &free_space, &nobjs, 10, obj_size))
+ if(add_obj(fh, dxpl, 10, obj_size, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -4920,8 +5225,8 @@ test_abs_skip_2nd_block_add_skipped(hid_t fapl, H5HF_create_t *cparam, fheap_tes
} /* end if */
/* Fill remainder of 2 * start size block */
- obj_size = DBLOCK_FREE(fh, 2) - (cparam->managed.start_block_size + 1);
- if(add_obj(fh, dxpl, heap_size, &free_space, &nobjs, 20, obj_size))
+ obj_size = DBLOCK_FREE(fh, 2) - (DBLOCK_SIZE(fh, 0) + 1);
+ if(add_obj(fh, dxpl, 20, obj_size, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -4936,15 +5241,18 @@ test_abs_skip_2nd_block_add_skipped(hid_t fapl, H5HF_create_t *cparam, fheap_tes
} /* end if */
/* Insert objects to fill remaining rows of the starting block size */
- for(u = 0; u < 2; u++) {
- /* Fill a row of direct heap blocks up */
- for(v = 0; v < (cparam->managed.width - 1); v++) {
- free_space -= DBLOCK_FREE(fh, u);
- if(fill_heap(fh, dxpl, cparam, heap_size, cparam->managed.start_block_size, free_space, &nobjs))
- FAIL_STACK_ERROR
- } /* end for */
+
+ /* Fill remainder of first row of direct heap blocks up */
+ for(v = 0; v < (cparam->managed.width - 1); v++) {
+ state.man_alloc_size += DBLOCK_SIZE(fh, 0);
+ if(fill_heap(fh, dxpl, 0, SMALL_OBJ_SIZE1, &state, NULL))
+ FAIL_STACK_ERROR
} /* end for */
+ /* Fill second row of direct blocks */
+ if(fill_row(fh, dxpl, 1, SMALL_OBJ_SIZE1, &state, NULL))
+ FAIL_STACK_ERROR
+
/* Check for closing & re-opening the heap */
if(tparam->reopen_heap) {
/* Close heap */
@@ -4957,8 +5265,8 @@ test_abs_skip_2nd_block_add_skipped(hid_t fapl, H5HF_create_t *cparam, fheap_tes
} /* end if */
/* Insert one more object, to create new 2 * start size direct block */
- obj_size = SMALL_OBJ_SIZE1;
- if(add_obj(fh, dxpl, heap_size, &free_space, &nobjs, 10, obj_size))
+ state.man_alloc_size += DBLOCK_SIZE(fh, 2);
+ if(add_obj(fh, dxpl, 10, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
PASSED()
@@ -5016,10 +5324,8 @@ test_abs_fill_one_partial_skip_2nd_block_add_skipped(hid_t fapl, H5HF_create_t *
H5HF_t *fh = NULL; /* Fractal heap wrapper */
haddr_t fh_addr; /* Address of fractal heap */
size_t id_len; /* Size of fractal heap IDs */
- unsigned nobjs = 0; /* Number of objects inserted */
size_t obj_size; /* Size of object */
- hsize_t free_space; /* Size of free space in heap */
- hsize_t heap_size; /* Total size of heap */
+ fheap_heap_state_t state; /* State of fractal heap */
unsigned u; /* Local index variable */
/* Set the filename to use for this test (dependent on fapl) */
@@ -5044,6 +5350,7 @@ test_abs_fill_one_partial_skip_2nd_block_add_skipped(hid_t fapl, H5HF_create_t *
FAIL_STACK_ERROR
if(!H5F_addr_defined(fh_addr))
FAIL_STACK_ERROR
+ HDmemset(&state, 0, sizeof(fheap_heap_state_t));
/*
* Test absolute heap
@@ -5051,9 +5358,11 @@ test_abs_fill_one_partial_skip_2nd_block_add_skipped(hid_t fapl, H5HF_create_t *
TESTING("skipping blocks with indirect root, then backfill and extend");
/* Fill initial direct block */
- heap_size = cparam->managed.start_block_size;
- free_space = 0;
- if(fill_heap(fh, dxpl, cparam, heap_size, cparam->managed.start_block_size, free_space, &nobjs))
+ state.heap_size = DBLOCK_SIZE(fh, 0);
+ state.man_size = DBLOCK_SIZE(fh, 0);
+ state.man_alloc_size = DBLOCK_SIZE(fh, 0);
+ state.man_free_space = DBLOCK_FREE(fh, 0);
+ if(fill_heap(fh, dxpl, 0, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -5068,10 +5377,11 @@ test_abs_fill_one_partial_skip_2nd_block_add_skipped(hid_t fapl, H5HF_create_t *
} /* end if */
/* Insert small object, to create root indirect block */
- obj_size = SMALL_OBJ_SIZE1;
- heap_size += (cparam->managed.width - 1) * cparam->managed.start_block_size;
- free_space += (cparam->managed.width - 1) * DBLOCK_FREE(fh, 0);
- if(add_obj(fh, dxpl, heap_size, &free_space, &nobjs, 10, obj_size))
+ state.heap_size += (cparam->managed.width - 1) * DBLOCK_SIZE(fh, 0);
+ state.man_size += (cparam->managed.width - 1) * DBLOCK_SIZE(fh, 0);
+ state.man_alloc_size += DBLOCK_SIZE(fh, 0);
+ state.man_free_space += (cparam->managed.width - 1) * DBLOCK_FREE(fh, 0);
+ if(add_obj(fh, dxpl, 10, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -5088,14 +5398,18 @@ test_abs_fill_one_partial_skip_2nd_block_add_skipped(hid_t fapl, H5HF_create_t *
/* Insert large object, to force creation of indirect block and
* range of skipped blocks that are too small to hold the large object
*/
- obj_size = (2 * cparam->managed.start_block_size) + 1;
- heap_size += cparam->managed.width * cparam->managed.start_block_size;
- heap_size += cparam->managed.width * cparam->managed.start_block_size * 2;
- heap_size += cparam->managed.width * cparam->managed.start_block_size * 4;
- free_space += cparam->managed.width * DBLOCK_FREE(fh, 1);
- free_space += cparam->managed.width * DBLOCK_FREE(fh, 2);
- free_space += cparam->managed.width * DBLOCK_FREE(fh, 3);
- if(add_obj(fh, dxpl, heap_size, &free_space, &nobjs, 20, obj_size))
+ obj_size = DBLOCK_SIZE(fh, 2) + 1;
+ state.heap_size += cparam->managed.width * DBLOCK_SIZE(fh, 1);
+ state.heap_size += cparam->managed.width * DBLOCK_SIZE(fh, 2);
+ state.heap_size += cparam->managed.width * DBLOCK_SIZE(fh, 3);
+ state.man_size += cparam->managed.width * DBLOCK_SIZE(fh, 1);
+ state.man_size += cparam->managed.width * DBLOCK_SIZE(fh, 2);
+ state.man_size += cparam->managed.width * DBLOCK_SIZE(fh, 3);
+ state.man_alloc_size += DBLOCK_SIZE(fh, 3);
+ state.man_free_space += cparam->managed.width * DBLOCK_FREE(fh, 1);
+ state.man_free_space += cparam->managed.width * DBLOCK_FREE(fh, 2);
+ state.man_free_space += cparam->managed.width * DBLOCK_FREE(fh, 3);
+ if(add_obj(fh, dxpl, 10, obj_size, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -5111,7 +5425,7 @@ test_abs_fill_one_partial_skip_2nd_block_add_skipped(hid_t fapl, H5HF_create_t *
/* Insert an object to fill up the (smaller) heap block just created */
obj_size = DBLOCK_FREE(fh, 0) - SMALL_OBJ_SIZE1;
- if(add_obj(fh, dxpl, heap_size, &free_space, &nobjs, 10, obj_size))
+ if(add_obj(fh, dxpl, 10, obj_size, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -5126,8 +5440,8 @@ test_abs_fill_one_partial_skip_2nd_block_add_skipped(hid_t fapl, H5HF_create_t *
} /* end if */
/* Insert object to fill remainder of 4 * start size block */
- obj_size = DBLOCK_FREE(fh, 3) - ((2 * cparam->managed.start_block_size) + 1);
- if(add_obj(fh, dxpl, heap_size, &free_space, &nobjs, 20, obj_size))
+ obj_size = DBLOCK_FREE(fh, 3) - (DBLOCK_SIZE(fh, 2) + 1);
+ if(add_obj(fh, dxpl, 10, obj_size, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -5144,8 +5458,8 @@ test_abs_fill_one_partial_skip_2nd_block_add_skipped(hid_t fapl, H5HF_create_t *
/* Insert objects to fill remaining heaps in first row */
for(u = 0; u < (cparam->managed.width - 2); u++) {
/* Fill a direct heap block up */
- free_space -= DBLOCK_FREE(fh, 0);
- if(fill_heap(fh, dxpl, cparam, heap_size, cparam->managed.start_block_size, free_space, &nobjs))
+ state.man_alloc_size += DBLOCK_SIZE(fh, 0);
+ if(fill_heap(fh, dxpl, 0, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
} /* end for */
@@ -5161,7 +5475,7 @@ test_abs_fill_one_partial_skip_2nd_block_add_skipped(hid_t fapl, H5HF_create_t *
} /* end if */
/* Insert objects to fill remaining heaps in second row */
- if(fill_row(fh, dxpl, cparam, &heap_size, &free_space, 1, &nobjs))
+ if(fill_row(fh, dxpl, 1, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -5176,7 +5490,7 @@ test_abs_fill_one_partial_skip_2nd_block_add_skipped(hid_t fapl, H5HF_create_t *
} /* end if */
/* Insert objects to fill remaining heaps in third row */
- if(fill_row(fh, dxpl, cparam, &heap_size, &free_space, 2, &nobjs))
+ if(fill_row(fh, dxpl, 2, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -5191,8 +5505,8 @@ test_abs_fill_one_partial_skip_2nd_block_add_skipped(hid_t fapl, H5HF_create_t *
} /* end if */
/* Insert one more object, to create new 4 * start size direct block */
- obj_size = SMALL_OBJ_SIZE1;
- if(add_obj(fh, dxpl, heap_size, &free_space, &nobjs, 10, obj_size))
+ state.man_alloc_size += DBLOCK_SIZE(fh, 3);
+ if(add_obj(fh, dxpl, 10, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
PASSED()
@@ -5249,10 +5563,8 @@ test_abs_fill_row_skip_add_skipped(hid_t fapl, H5HF_create_t *cparam, fheap_test
H5HF_t *fh = NULL; /* Fractal heap wrapper */
haddr_t fh_addr; /* Address of fractal heap */
size_t id_len; /* Size of fractal heap IDs */
- unsigned nobjs = 0; /* Number of objects inserted */
size_t obj_size; /* Size of object */
- hsize_t free_space; /* Size of free space in heap */
- hsize_t heap_size; /* Total size of heap */
+ fheap_heap_state_t state; /* State of fractal heap */
/* Set the filename to use for this test (dependent on fapl) */
h5_fixname(FILENAME[0], fapl, filename, sizeof(filename));
@@ -5276,6 +5588,7 @@ test_abs_fill_row_skip_add_skipped(hid_t fapl, H5HF_create_t *cparam, fheap_test
FAIL_STACK_ERROR
if(!H5F_addr_defined(fh_addr))
FAIL_STACK_ERROR
+ HDmemset(&state, 0, sizeof(fheap_heap_state_t));
/*
* Test absolute heap
@@ -5283,9 +5596,7 @@ test_abs_fill_row_skip_add_skipped(hid_t fapl, H5HF_create_t *cparam, fheap_test
TESTING("filling first row, then skipping rows, then backfill and extend");
/* Fill first row of direct blocks */
- heap_size = 0;
- free_space = 0;
- if(fill_root_row(fh, dxpl, cparam, &heap_size, &free_space, 0, &nobjs))
+ if(fill_root_row(fh, dxpl, 0, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -5302,14 +5613,18 @@ test_abs_fill_row_skip_add_skipped(hid_t fapl, H5HF_create_t *cparam, fheap_test
/* Insert large object, to force creation of indirect block and
* range of skipped blocks that are too small to hold the large object
*/
- obj_size = (2 * cparam->managed.start_block_size) + 1;
- heap_size += cparam->managed.width * DBLOCK_SIZE(fh, 1);
- heap_size += cparam->managed.width * DBLOCK_SIZE(fh, 2);
- heap_size += cparam->managed.width * DBLOCK_SIZE(fh, 3);
- free_space += cparam->managed.width * DBLOCK_FREE(fh, 1);
- free_space += cparam->managed.width * DBLOCK_FREE(fh, 2);
- free_space += cparam->managed.width * DBLOCK_FREE(fh, 3);
- if(add_obj(fh, dxpl, heap_size, &free_space, &nobjs, 20, obj_size))
+ obj_size = DBLOCK_SIZE(fh, 2) + 1;
+ state.heap_size += cparam->managed.width * DBLOCK_SIZE(fh, 1);
+ state.heap_size += cparam->managed.width * DBLOCK_SIZE(fh, 2);
+ state.heap_size += cparam->managed.width * DBLOCK_SIZE(fh, 3);
+ state.man_size += cparam->managed.width * DBLOCK_SIZE(fh, 1);
+ state.man_size += cparam->managed.width * DBLOCK_SIZE(fh, 2);
+ state.man_size += cparam->managed.width * DBLOCK_SIZE(fh, 3);
+ state.man_alloc_size += DBLOCK_SIZE(fh, 3);
+ state.man_free_space += cparam->managed.width * DBLOCK_FREE(fh, 1);
+ state.man_free_space += cparam->managed.width * DBLOCK_FREE(fh, 2);
+ state.man_free_space += cparam->managed.width * DBLOCK_FREE(fh, 3);
+ if(add_obj(fh, dxpl, 20, obj_size, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -5325,7 +5640,7 @@ test_abs_fill_row_skip_add_skipped(hid_t fapl, H5HF_create_t *cparam, fheap_test
/* Insert object to fill remainder of 4 * start size block */
obj_size = DBLOCK_FREE(fh, 3) - obj_size;
- if(add_obj(fh, dxpl, heap_size, &free_space, &nobjs, 20, obj_size))
+ if(add_obj(fh, dxpl, 20, obj_size, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -5340,7 +5655,7 @@ test_abs_fill_row_skip_add_skipped(hid_t fapl, H5HF_create_t *cparam, fheap_test
} /* end if */
/* Insert objects to fill remaining heaps in second row */
- if(fill_row(fh, dxpl, cparam, &heap_size, &free_space, 1, &nobjs))
+ if(fill_row(fh, dxpl, 1, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -5355,7 +5670,7 @@ test_abs_fill_row_skip_add_skipped(hid_t fapl, H5HF_create_t *cparam, fheap_test
} /* end if */
/* Insert objects to fill remaining heaps in third row */
- if(fill_row(fh, dxpl, cparam, &heap_size, &free_space, 2, &nobjs))
+ if(fill_row(fh, dxpl, 2, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -5370,8 +5685,8 @@ test_abs_fill_row_skip_add_skipped(hid_t fapl, H5HF_create_t *cparam, fheap_test
} /* end if */
/* Insert one more object, to create new 4 * start size direct block */
- obj_size = SMALL_OBJ_SIZE1;
- if(add_obj(fh, dxpl, heap_size, &free_space, &nobjs, 10, obj_size))
+ state.man_alloc_size += DBLOCK_SIZE(fh, 3);
+ if(add_obj(fh, dxpl, 10, obj_size, &state, NULL))
FAIL_STACK_ERROR
PASSED()
@@ -5424,10 +5739,8 @@ test_abs_fill_direct_skip_indirect_start_block_add_skipped(hid_t fapl, H5HF_crea
H5HF_t *fh = NULL; /* Fractal heap wrapper */
haddr_t fh_addr; /* Address of fractal heap */
size_t id_len; /* Size of fractal heap IDs */
- unsigned nobjs = 0; /* Number of objects inserted */
size_t obj_size; /* Size of object */
- hsize_t free_space; /* Size of free space in heap */
- hsize_t heap_size; /* Total size of heap */
+ fheap_heap_state_t state; /* State of fractal heap */
/* Set the filename to use for this test (dependent on fapl) */
h5_fixname(FILENAME[0], fapl, filename, sizeof(filename));
@@ -5451,6 +5764,7 @@ test_abs_fill_direct_skip_indirect_start_block_add_skipped(hid_t fapl, H5HF_crea
FAIL_STACK_ERROR
if(!H5F_addr_defined(fh_addr))
FAIL_STACK_ERROR
+ HDmemset(&state, 0, sizeof(fheap_heap_state_t));
/*
* Test absolute heap
@@ -5458,9 +5772,7 @@ test_abs_fill_direct_skip_indirect_start_block_add_skipped(hid_t fapl, H5HF_crea
TESTING("filling direct blocks and skipping blocks in non-root indirect block, then backfill and extend");
/* Fill direct blocks in root indirect block */
- heap_size = 0;
- free_space = 0;
- if(fill_root_direct(fh, dxpl, cparam, &heap_size, &free_space, &nobjs))
+ if(fill_root_direct(fh, dxpl, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -5477,8 +5789,9 @@ test_abs_fill_direct_skip_indirect_start_block_add_skipped(hid_t fapl, H5HF_crea
/* Insert large object, to force creation of indirect block and
* range of skipped blocks that are too small to hold the large object
*/
- obj_size = (2 * cparam->managed.start_block_size) + 1;
- if(add_obj(fh, dxpl, heap_size, &free_space, &nobjs, 20, obj_size))
+ obj_size = DBLOCK_SIZE(fh, 2) + 1;
+ state.man_alloc_size += DBLOCK_SIZE(fh, 3);
+ if(add_obj(fh, dxpl, 20, obj_size, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -5493,9 +5806,9 @@ test_abs_fill_direct_skip_indirect_start_block_add_skipped(hid_t fapl, H5HF_crea
} /* end if */
/* Add rows of blocks to "backfill" direct blocks that were skipped */
- if(fill_row(fh, dxpl, cparam, &heap_size, &free_space, 0, &nobjs))
+ if(fill_row(fh, dxpl, 0, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
- if(fill_row(fh, dxpl, cparam, &heap_size, &free_space, 1, &nobjs))
+ if(fill_row(fh, dxpl, 1, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -5510,8 +5823,8 @@ test_abs_fill_direct_skip_indirect_start_block_add_skipped(hid_t fapl, H5HF_crea
} /* end if */
/* Insert an object to fill up the (biggest) heap block created */
- obj_size = DBLOCK_FREE(fh, 3) - ((2 * cparam->managed.start_block_size) + 1);
- if(add_obj(fh, dxpl, heap_size, &free_space, &nobjs, 20, obj_size))
+ obj_size = DBLOCK_FREE(fh, 3) - obj_size;
+ if(add_obj(fh, dxpl, 20, obj_size, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -5526,7 +5839,7 @@ test_abs_fill_direct_skip_indirect_start_block_add_skipped(hid_t fapl, H5HF_crea
} /* end if */
/* Fill direct block heaps with 2 * initial block size in nested indirect block */
- if(fill_row(fh, dxpl, cparam, &heap_size, &free_space, 2, &nobjs))
+ if(fill_row(fh, dxpl, 2, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -5542,7 +5855,8 @@ test_abs_fill_direct_skip_indirect_start_block_add_skipped(hid_t fapl, H5HF_crea
/* Insert one more object, to create new 4 * start size direct block */
obj_size = SMALL_OBJ_SIZE1;
- if(add_obj(fh, dxpl, heap_size, &free_space, &nobjs, 10, obj_size))
+ state.man_alloc_size += DBLOCK_SIZE(fh, 3);
+ if(add_obj(fh, dxpl, 10, obj_size, &state, NULL))
FAIL_STACK_ERROR
PASSED()
@@ -5596,16 +5910,10 @@ test_abs_fill_direct_skip_2nd_indirect_start_block_add_skipped(hid_t fapl, H5HF_
H5HF_t *fh = NULL; /* Fractal heap wrapper */
haddr_t fh_addr; /* Address of fractal heap */
size_t id_len; /* Size of fractal heap IDs */
- unsigned first_row_bits; /* Number of bits used bit addresses in first row */
- unsigned first_indirect_block_size; /* Range of addresses covered by each of the first indirect blocks */
unsigned num_first_indirect_rows; /* Number of rows (of direct blocks) in each of the first indirect blocks */
- size_t obj_block_size; /* Size of block to hold large object added */
- size_t block_size; /* Size of block added */
unsigned row; /* Current row in indirect block */
- unsigned nobjs = 0; /* Number of objects inserted */
size_t obj_size; /* Size of object */
- hsize_t free_space; /* Size of free space in heap */
- hsize_t heap_size; /* Total size of heap */
+ fheap_heap_state_t state; /* State of fractal heap */
unsigned u; /* Local index variable */
/* Set the filename to use for this test (dependent on fapl) */
@@ -5630,18 +5938,12 @@ test_abs_fill_direct_skip_2nd_indirect_start_block_add_skipped(hid_t fapl, H5HF_
FAIL_STACK_ERROR
if(!H5F_addr_defined(fh_addr))
FAIL_STACK_ERROR
+ HDmemset(&state, 0, sizeof(fheap_heap_state_t));
- /* Compute # of bits used in first row */
- first_row_bits = H5V_log2_of2(cparam->managed.start_block_size) +
- H5V_log2_of2(cparam->managed.width);
- first_indirect_block_size = 2 * cparam->managed.max_direct_size;
- num_first_indirect_rows = (H5V_log2_of2(first_indirect_block_size) - first_row_bits) + 1;
- obj_block_size = 1 << ((num_first_indirect_rows + H5V_log2_of2(cparam->managed.start_block_size)) - 1);
+ /* Retrieve info about heap */
+ num_first_indirect_rows = IBLOCK_MAX_DROWS(fh, 1);
#ifdef QAK
-HDfprintf(stderr, "first_row_bits = %u\n", first_row_bits);
-HDfprintf(stderr, "first_indirect_block_size = %u\n", first_indirect_block_size);
HDfprintf(stderr, "num_first_indirect_rows = %u\n", num_first_indirect_rows);
-HDfprintf(stderr, "obj_block_size = %Zu\n", obj_block_size);
#endif /* QAK */
/*
@@ -5650,9 +5952,7 @@ HDfprintf(stderr, "obj_block_size = %Zu\n", obj_block_size);
TESTING("filling direct blocks and skipping row of non-root indirect blocks, then backfill and extend");
/* Fill direct blocks in root indirect block */
- heap_size = 0;
- free_space = 0;
- if(fill_root_direct(fh, dxpl, cparam, &heap_size, &free_space, &nobjs))
+ if(fill_root_direct(fh, dxpl, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -5670,11 +5970,12 @@ HDfprintf(stderr, "obj_block_size = %Zu\n", obj_block_size);
* range of skipped (indirect) blocks that are too small to hold the large
* object
*/
- obj_size = (1 << ((num_first_indirect_rows + H5V_log2_of2(cparam->managed.start_block_size)) - 2)) + 1;
+ obj_size = DBLOCK_SIZE(fh, num_first_indirect_rows - 1) + 1;
#ifdef QAK
HDfprintf(stderr, "obj_size = %Zu\n", obj_size);
#endif /* QAK */
- if(add_obj(fh, dxpl, heap_size, &free_space, &nobjs, 20, obj_size))
+ state.man_alloc_size += DBLOCK_SIZE(fh, num_first_indirect_rows);
+ if(add_obj(fh, dxpl, 20, obj_size, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -5690,7 +5991,7 @@ HDfprintf(stderr, "obj_size = %Zu\n", obj_size);
/* Insert object to fill space in (large) block created */
obj_size = DBLOCK_FREE(fh, num_first_indirect_rows) - obj_size;
- if(add_obj(fh, dxpl, heap_size, &free_space, &nobjs, 20, obj_size))
+ if(add_obj(fh, dxpl, 20, obj_size, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -5705,23 +6006,16 @@ HDfprintf(stderr, "obj_size = %Zu\n", obj_size);
} /* end if */
/* Fill all rows of direct blocks that are smaller than large object's block size */
- block_size = cparam->managed.start_block_size;
- row = 0;
- while(block_size < obj_block_size) {
+ for(row = 0; row < num_first_indirect_rows; row++) {
/* Fill rows of direct blocks in skipped indirect blocks */
for(u = 0; u < cparam->managed.width; u++)
- if(fill_row(fh, dxpl, cparam, &heap_size, &free_space, row, &nobjs))
+ if(fill_row(fh, dxpl, row, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Fill row of direct blocks in largest (i.e. non-skipped) indirect block */
- if(fill_row(fh, dxpl, cparam, &heap_size, &free_space, row, &nobjs))
+ if(fill_row(fh, dxpl, row, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
-
- /* Advance position in blocks */
- if(row > 0)
- block_size *= 2;
- row++;
- } /* end while */
+ } /* end for */
/* Check for closing & re-opening the heap */
if(tparam->reopen_heap) {
@@ -5736,7 +6030,8 @@ HDfprintf(stderr, "obj_size = %Zu\n", obj_size);
/* Add one more object, to create another "large" block */
obj_size = SMALL_OBJ_SIZE1;
- if(add_obj(fh, dxpl, heap_size, &free_space, &nobjs, 10, obj_size))
+ state.man_alloc_size += DBLOCK_SIZE(fh, num_first_indirect_rows);
+ if(add_obj(fh, dxpl, 10, obj_size, &state, NULL))
FAIL_STACK_ERROR
PASSED()
@@ -5791,13 +6086,9 @@ test_abs_fill_2nd_direct_less_one_wrap_start_block_add_skipped(hid_t fapl, H5HF_
H5HF_t *fh = NULL; /* Fractal heap wrapper */
haddr_t fh_addr; /* Address of fractal heap */
size_t id_len; /* Size of fractal heap IDs */
- unsigned first_row_bits; /* Number of bits used bit addresses in first row */
- unsigned first_indirect_block_size; /* Range of addresses covered by each of the first indirect blocks */
unsigned num_first_indirect_rows; /* Number of rows (of direct blocks) in each of the first indirect blocks */
- unsigned nobjs = 0; /* Number of objects inserted */
size_t obj_size; /* Size of object */
- hsize_t free_space; /* Size of free space in heap */
- hsize_t heap_size; /* Total size of heap */
+ fheap_heap_state_t state; /* State of fractal heap */
unsigned u; /* Local index variables */
/* Set the filename to use for this test (dependent on fapl) */
@@ -5822,15 +6113,11 @@ test_abs_fill_2nd_direct_less_one_wrap_start_block_add_skipped(hid_t fapl, H5HF_
FAIL_STACK_ERROR
if(!H5F_addr_defined(fh_addr))
FAIL_STACK_ERROR
+ HDmemset(&state, 0, sizeof(fheap_heap_state_t));
- /* Compute # of bits used in first row */
- first_row_bits = H5V_log2_of2(cparam->managed.start_block_size) +
- H5V_log2_of2(cparam->managed.width);
- first_indirect_block_size = 2 * cparam->managed.max_direct_size;
- num_first_indirect_rows = (H5V_log2_of2(first_indirect_block_size) - first_row_bits) + 1;
+ /* Retrieve info about heap */
+ num_first_indirect_rows = IBLOCK_MAX_DROWS(fh, 1);
#ifdef QAK
-HDfprintf(stderr, "first_row_bits = %u\n", first_row_bits);
-HDfprintf(stderr, "first_indirect_block_size = %u\n", first_indirect_block_size);
HDfprintf(stderr, "num_first_indirect_rows = %u\n", num_first_indirect_rows);
#endif /* QAK */
@@ -5840,9 +6127,7 @@ HDfprintf(stderr, "num_first_indirect_rows = %u\n", num_first_indirect_rows);
TESTING("filling direct blocks, filling 2nd level indirect blocks, except last one, and insert object too large for 2nd level indirect blocks, then backfill and extend");
/* Fill direct blocks in root indirect block */
- heap_size = 0;
- free_space = 0;
- if(fill_root_direct(fh, dxpl, cparam, &heap_size, &free_space, &nobjs))
+ if(fill_root_direct(fh, dxpl, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -5857,11 +6142,10 @@ HDfprintf(stderr, "num_first_indirect_rows = %u\n", num_first_indirect_rows);
} /* end if */
/* Fill first row (except one) of 2nd level indirect blocks */
- for(u = 0; u < cparam->managed.width - 1; u++) {
+ for(u = 0; u < cparam->managed.width - 1; u++)
/* Fill all rows of 2nd level indirect blocks in root block */
- if(fill_2nd_indirect(fh, dxpl, cparam, &heap_size, &free_space, &nobjs, 1))
+ if(fill_2nd_indirect(fh, dxpl, 1, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
- } /* end for */
/* Check for closing & re-opening the heap */
if(tparam->reopen_heap) {
@@ -5878,11 +6162,12 @@ HDfprintf(stderr, "num_first_indirect_rows = %u\n", num_first_indirect_rows);
* range of skipped (indirect) blocks that are too small to hold the large
* object
*/
- obj_size = (1 << ((num_first_indirect_rows + H5V_log2_of2(cparam->managed.start_block_size)) - 2)) + 1;
+ obj_size = DBLOCK_SIZE(fh, num_first_indirect_rows - 1) + 1;
#ifdef QAK
HDfprintf(stderr, "obj_size = %Zu\n", obj_size);
#endif /* QAK */
- if(add_obj(fh, dxpl, heap_size, &free_space, &nobjs, 20, obj_size))
+ state.man_alloc_size += DBLOCK_SIZE(fh, num_first_indirect_rows);
+ if(add_obj(fh, dxpl, 20, obj_size, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -5898,7 +6183,7 @@ HDfprintf(stderr, "obj_size = %Zu\n", obj_size);
/* Insert object to fill space in (large) block created */
obj_size = DBLOCK_FREE(fh, num_first_indirect_rows) - obj_size;
- if(add_obj(fh, dxpl, heap_size, &free_space, &nobjs, 20, obj_size))
+ if(add_obj(fh, dxpl, 20, obj_size, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -5917,11 +6202,11 @@ HDfprintf(stderr, "obj_size = %Zu\n", obj_size);
*/
for(u = 0; u < num_first_indirect_rows; u++) {
/* Direct block rows in skipped 2nd level indirect block */
- if(fill_row(fh, dxpl, cparam, &heap_size, &free_space, u, &nobjs))
+ if(fill_row(fh, dxpl, u, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Direct block row in current 2nd level indirect block */
- if(fill_row(fh, dxpl, cparam, &heap_size, &free_space, u, &nobjs))
+ if(fill_row(fh, dxpl, u, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
} /* end for */
@@ -5938,7 +6223,8 @@ HDfprintf(stderr, "obj_size = %Zu\n", obj_size);
/* Add one more object, to create another "large" block */
obj_size = SMALL_OBJ_SIZE1;
- if(add_obj(fh, dxpl, heap_size, &free_space, &nobjs, 10, obj_size))
+ state.man_alloc_size += DBLOCK_SIZE(fh, num_first_indirect_rows);
+ if(add_obj(fh, dxpl, 10, obj_size, &state, NULL))
FAIL_STACK_ERROR
PASSED()
@@ -5996,16 +6282,10 @@ test_abs_fill_direct_skip_2nd_indirect_skip_2nd_block_add_skipped(hid_t fapl, H5
H5HF_t *fh = NULL; /* Fractal heap wrapper */
haddr_t fh_addr; /* Address of fractal heap */
size_t id_len; /* Size of fractal heap IDs */
- unsigned first_row_bits; /* Number of bits used bit addresses in first row */
- unsigned first_indirect_block_size; /* Range of addresses covered by each of the first indirect blocks */
unsigned num_first_indirect_rows; /* Number of rows (of direct blocks) in each of the first indirect blocks */
- size_t obj_block_size; /* Size of block to hold large object added */
- size_t block_size; /* Size of block added */
unsigned row; /* Current row in indirect block */
- unsigned nobjs = 0; /* Number of objects inserted */
size_t obj_size; /* Size of object */
- hsize_t free_space; /* Size of free space in heap */
- hsize_t heap_size; /* Total size of heap */
+ fheap_heap_state_t state; /* State of fractal heap */
unsigned u; /* Local index variable */
/* Set the filename to use for this test (dependent on fapl) */
@@ -6030,18 +6310,12 @@ test_abs_fill_direct_skip_2nd_indirect_skip_2nd_block_add_skipped(hid_t fapl, H5
FAIL_STACK_ERROR
if(!H5F_addr_defined(fh_addr))
FAIL_STACK_ERROR
+ HDmemset(&state, 0, sizeof(fheap_heap_state_t));
- /* Compute # of bits used in first row */
- first_row_bits = H5V_log2_of2(cparam->managed.start_block_size) +
- H5V_log2_of2(cparam->managed.width);
- first_indirect_block_size = 2 * cparam->managed.max_direct_size;
- num_first_indirect_rows = (H5V_log2_of2(first_indirect_block_size) - first_row_bits) + 1;
- obj_block_size = 1 << ((num_first_indirect_rows + H5V_log2_of2(cparam->managed.start_block_size)) - 1);
+ /* Retrieve info about heap */
+ num_first_indirect_rows = IBLOCK_MAX_DROWS(fh, 1);
#ifdef QAK
-HDfprintf(stderr, "first_row_bits = %u\n", first_row_bits);
-HDfprintf(stderr, "first_indirect_block_size = %u\n", first_indirect_block_size);
HDfprintf(stderr, "num_first_indirect_rows = %u\n", num_first_indirect_rows);
-HDfprintf(stderr, "obj_block_size = %Zu\n", obj_block_size);
#endif /* QAK */
/*
@@ -6050,9 +6324,7 @@ HDfprintf(stderr, "obj_block_size = %Zu\n", obj_block_size);
TESTING("filling direct blocks and skipping row of non-root indirect blocks, then skip row of direct blocks, then backfill and extend");
/* Fill direct blocks in root indirect block */
- heap_size = 0;
- free_space = 0;
- if(fill_root_direct(fh, dxpl, cparam, &heap_size, &free_space, &nobjs))
+ if(fill_root_direct(fh, dxpl, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -6070,11 +6342,12 @@ HDfprintf(stderr, "obj_block_size = %Zu\n", obj_block_size);
* range of skipped (indirect) blocks that are too small to hold the large
* object
*/
- obj_size = (1 << ((num_first_indirect_rows + H5V_log2_of2(cparam->managed.start_block_size)) - 2)) + 1;
+ obj_size = DBLOCK_SIZE(fh, num_first_indirect_rows - 1) + 1;
#ifdef QAK
HDfprintf(stderr, "obj_size = %Zu\n", obj_size);
#endif /* QAK */
- if(add_obj(fh, dxpl, heap_size, &free_space, &nobjs, 20, obj_size))
+ state.man_alloc_size += DBLOCK_SIZE(fh, num_first_indirect_rows);
+ if(add_obj(fh, dxpl, 20, obj_size, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -6090,7 +6363,7 @@ HDfprintf(stderr, "obj_size = %Zu\n", obj_size);
/* Insert object to fill space in (large) block created */
obj_size = DBLOCK_FREE(fh, num_first_indirect_rows) - obj_size;
- if(add_obj(fh, dxpl, heap_size, &free_space, &nobjs, 20, obj_size))
+ if(add_obj(fh, dxpl, 20, obj_size, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -6105,11 +6378,12 @@ HDfprintf(stderr, "obj_size = %Zu\n", obj_size);
} /* end if */
/* Insert object too large for initial block size in skipped indirect blocks */
- obj_size = (cparam->managed.start_block_size * 4) + 1;
+ obj_size = DBLOCK_SIZE(fh, 3) + 1;
#ifdef QAK
HDfprintf(stderr, "obj_size = %Zu\n", obj_size);
#endif /* QAK */
- if(add_obj(fh, dxpl, heap_size, &free_space, &nobjs, 10, obj_size))
+ state.man_alloc_size += DBLOCK_SIZE(fh, 4);
+ if(add_obj(fh, dxpl, 10, obj_size, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -6128,7 +6402,7 @@ HDfprintf(stderr, "obj_size = %Zu\n", obj_size);
#ifdef QAK
HDfprintf(stderr, "obj_size = %Zu\n", obj_size);
#endif /* QAK */
- if(add_obj(fh, dxpl, heap_size, &free_space, &nobjs, 20, obj_size))
+ if(add_obj(fh, dxpl, 20, obj_size, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -6144,12 +6418,11 @@ HDfprintf(stderr, "obj_size = %Zu\n", obj_size);
/* Finish off blocks in row of medium block size (just to make row filling easier below) */
obj_size = DBLOCK_FREE(fh, 4);
- if(add_obj(fh, dxpl, heap_size, &free_space, &nobjs, 20, obj_size))
- FAIL_STACK_ERROR
- if(add_obj(fh, dxpl, heap_size, &free_space, &nobjs, 20, obj_size))
- FAIL_STACK_ERROR
- if(add_obj(fh, dxpl, heap_size, &free_space, &nobjs, 20, obj_size))
- FAIL_STACK_ERROR
+ for(u = 1; u < cparam->managed.width; u++) {
+ state.man_alloc_size += DBLOCK_SIZE(fh, 4);
+ if(add_obj(fh, dxpl, 20, obj_size, &state, NULL))
+ FAIL_STACK_ERROR
+ } /* end for */
/* Check for closing & re-opening the heap */
if(tparam->reopen_heap) {
@@ -6163,24 +6436,17 @@ HDfprintf(stderr, "obj_size = %Zu\n", obj_size);
} /* end if */
/* Fill all rows of direct blocks that are smaller than large object's block size */
- block_size = cparam->managed.start_block_size;
- row = 0;
- while(block_size < obj_block_size) {
+ for(row = 0; row < num_first_indirect_rows; row++) {
/* Fill rows of direct blocks in skipped indirect blocks */
for(u = 0; u < cparam->managed.width; u++)
- if(fill_row(fh, dxpl, cparam, &heap_size, &free_space, row, &nobjs))
+ if(fill_row(fh, dxpl, row, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Fill row of direct blocks in largest (i.e. non-skipped) indirect block */
/* (Skip the row of blocks filled above) */
if(row != 4)
- if(fill_row(fh, dxpl, cparam, &heap_size, &free_space, row, &nobjs))
+ if(fill_row(fh, dxpl, row, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
-
- /* Advance position in blocks */
- if(row > 0)
- block_size *= 2;
- row++;
} /* end while */
/* Check for closing & re-opening the heap */
@@ -6196,7 +6462,8 @@ HDfprintf(stderr, "obj_size = %Zu\n", obj_size);
/* Add one more object, to create another "large" block */
obj_size = SMALL_OBJ_SIZE1;
- if(add_obj(fh, dxpl, heap_size, &free_space, &nobjs, 10, obj_size))
+ state.man_alloc_size += DBLOCK_SIZE(fh, num_first_indirect_rows);
+ if(add_obj(fh, dxpl, 10, obj_size, &state, NULL))
FAIL_STACK_ERROR
PASSED()
@@ -6249,13 +6516,10 @@ test_abs_fill_direct_skip_indirect_two_rows_add_skipped(hid_t fapl, H5HF_create_
H5HF_t *fh = NULL; /* Fractal heap wrapper */
haddr_t fh_addr; /* Address of fractal heap */
size_t id_len; /* Size of fractal heap IDs */
- unsigned first_row_bits; /* Number of bits used bit addresses in first row */
- unsigned first_indirect_block_size; /* Range of addresses covered by each of the first indirect blocks */
unsigned num_first_indirect_rows; /* Number of rows (of direct blocks) in each of the first indirect blocks */
- unsigned nobjs = 0; /* Number of objects inserted */
+ unsigned max_dblock_rows; /* Max. # of rows (of direct blocks) in the root indirect block */
size_t obj_size; /* Size of object */
- hsize_t free_space; /* Size of free space in heap */
- hsize_t heap_size; /* Total size of heap */
+ fheap_heap_state_t state; /* State of fractal heap */
unsigned u, v; /* Local index variables */
/* Set the filename to use for this test (dependent on fapl) */
@@ -6280,12 +6544,11 @@ test_abs_fill_direct_skip_indirect_two_rows_add_skipped(hid_t fapl, H5HF_create_
FAIL_STACK_ERROR
if(!H5F_addr_defined(fh_addr))
FAIL_STACK_ERROR
+ HDmemset(&state, 0, sizeof(fheap_heap_state_t));
- /* Compute # of bits used in first row */
- first_row_bits = H5V_log2_of2(cparam->managed.start_block_size) +
- H5V_log2_of2(cparam->managed.width);
- first_indirect_block_size = 2 * cparam->managed.max_direct_size;
- num_first_indirect_rows = (H5V_log2_of2(first_indirect_block_size) - first_row_bits) + 1;
+ /* Retrieve info about heap */
+ num_first_indirect_rows = IBLOCK_MAX_DROWS(fh, 1);
+ max_dblock_rows = DTABLE_MAX_DROWS(fh);
/*
* Test absolute heap
@@ -6293,9 +6556,7 @@ test_abs_fill_direct_skip_indirect_two_rows_add_skipped(hid_t fapl, H5HF_create_
TESTING("filling direct blocks and skipping two rows of root indirect block, then backfill and extend");
/* Fill direct blocks in root indirect block */
- heap_size = 0;
- free_space = 0;
- if(fill_root_direct(fh, dxpl, cparam, &heap_size, &free_space, &nobjs))
+ if(fill_root_direct(fh, dxpl, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -6312,8 +6573,9 @@ test_abs_fill_direct_skip_indirect_two_rows_add_skipped(hid_t fapl, H5HF_create_
/* Insert large object, to force creation of indirect block and
* range of skipped blocks that are too small to hold the large object
*/
- obj_size = (cparam->managed.max_direct_size / 2) + 1;
- if(add_obj(fh, dxpl, heap_size, &free_space, &nobjs, 20, obj_size))
+ obj_size = DBLOCK_SIZE(fh, max_dblock_rows - 2) + 1;
+ state.man_alloc_size += DBLOCK_SIZE(fh, max_dblock_rows - 1);
+ if(add_obj(fh, dxpl, 20, obj_size, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -6328,8 +6590,8 @@ test_abs_fill_direct_skip_indirect_two_rows_add_skipped(hid_t fapl, H5HF_create_
} /* end if */
/* Insert an object to fill up the (biggest) heap block created */
- obj_size = DBLOCK_FREE(fh, num_first_indirect_rows + 1) - obj_size;
- if(add_obj(fh, dxpl, heap_size, &free_space, &nobjs, 20, obj_size))
+ obj_size = DBLOCK_FREE(fh, max_dblock_rows - 1) - obj_size;
+ if(add_obj(fh, dxpl, 20, obj_size, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -6343,21 +6605,20 @@ test_abs_fill_direct_skip_indirect_two_rows_add_skipped(hid_t fapl, H5HF_create_
FAIL_STACK_ERROR
} /* end if */
- /* Fill rows skipped over in indirect block's direct blocks
- */
+ /* Fill rows skipped over in indirect block's direct blocks */
for(u = 0; u < num_first_indirect_rows; u++) {
/* Direct block rows in first row of skipped 2nd level indirect blocks */
for(v = 0; v < cparam->managed.width; v++)
- if(fill_row(fh, dxpl, cparam, &heap_size, &free_space, u, &nobjs))
+ if(fill_row(fh, dxpl, u, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Direct block rows in second row of skipped 2nd level indirect blocks */
for(v = 0; v < cparam->managed.width; v++)
- if(fill_row(fh, dxpl, cparam, &heap_size, &free_space, u, &nobjs))
+ if(fill_row(fh, dxpl, u, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Direct block row in used 2nd level indirect block */
- if(fill_row(fh, dxpl, cparam, &heap_size, &free_space, u, &nobjs))
+ if(fill_row(fh, dxpl, u, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
} /* end for */
@@ -6376,7 +6637,7 @@ test_abs_fill_direct_skip_indirect_two_rows_add_skipped(hid_t fapl, H5HF_create_
/* Direct block rows in skipped 2nd level indirect blocks */
for(v = 0; v < cparam->managed.width; v++)
- if(fill_row(fh, dxpl, cparam, &heap_size, &free_space, num_first_indirect_rows, &nobjs))
+ if(fill_row(fh, dxpl, num_first_indirect_rows, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -6391,7 +6652,7 @@ test_abs_fill_direct_skip_indirect_two_rows_add_skipped(hid_t fapl, H5HF_create_
} /* end if */
/* Direct block row in used 2nd level indirect block */
- if(fill_row(fh, dxpl, cparam, &heap_size, &free_space, num_first_indirect_rows, &nobjs))
+ if(fill_row(fh, dxpl, num_first_indirect_rows, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -6407,7 +6668,8 @@ test_abs_fill_direct_skip_indirect_two_rows_add_skipped(hid_t fapl, H5HF_create_
/* Add one more object, to create another "large" block */
obj_size = SMALL_OBJ_SIZE1;
- if(add_obj(fh, dxpl, heap_size, &free_space, &nobjs, 10, obj_size))
+ state.man_alloc_size += DBLOCK_SIZE(fh, max_dblock_rows - 1);
+ if(add_obj(fh, dxpl, 10, obj_size, &state, NULL))
FAIL_STACK_ERROR
PASSED()
@@ -6461,10 +6723,8 @@ test_abs_fill_2nd_direct_skip_start_block_add_skipped(hid_t fapl, H5HF_create_t
H5HF_t *fh = NULL; /* Fractal heap wrapper */
haddr_t fh_addr; /* Address of fractal heap */
size_t id_len; /* Size of fractal heap IDs */
- unsigned nobjs = 0; /* Number of objects inserted */
size_t obj_size; /* Size of object */
- hsize_t free_space; /* Size of free space in heap */
- hsize_t heap_size; /* Total size of heap */
+ fheap_heap_state_t state; /* State of fractal heap */
/* Set the filename to use for this test (dependent on fapl) */
h5_fixname(FILENAME[0], fapl, filename, sizeof(filename));
@@ -6488,6 +6748,7 @@ test_abs_fill_2nd_direct_skip_start_block_add_skipped(hid_t fapl, H5HF_create_t
FAIL_STACK_ERROR
if(!H5F_addr_defined(fh_addr))
FAIL_STACK_ERROR
+ HDmemset(&state, 0, sizeof(fheap_heap_state_t));
/*
* Test absolute heap
@@ -6495,9 +6756,7 @@ test_abs_fill_2nd_direct_skip_start_block_add_skipped(hid_t fapl, H5HF_create_t
TESTING("filling direct blocks, filling 2nd level indirect blocks, and skip first rows of direct blocks of 3rd level indirect block, then backfill and extend");
/* Fill direct blocks in root indirect block */
- heap_size = 0;
- free_space = 0;
- if(fill_root_direct(fh, dxpl, cparam, &heap_size, &free_space, &nobjs))
+ if(fill_root_direct(fh, dxpl, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -6512,7 +6771,7 @@ test_abs_fill_2nd_direct_skip_start_block_add_skipped(hid_t fapl, H5HF_create_t
} /* end if */
/* Fill all rows of 2nd level indirect blocks */
- if(fill_all_2nd_indirect_rows(fh, dxpl, cparam, &heap_size, &free_space, &nobjs))
+ if(fill_all_2nd_indirect_rows(fh, dxpl, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -6530,8 +6789,9 @@ test_abs_fill_2nd_direct_skip_start_block_add_skipped(hid_t fapl, H5HF_create_t
* range of skipped (indirect) blocks that are too small to hold the large
* object
*/
- obj_size = (cparam->managed.start_block_size * 2) + 1;
- if(add_obj(fh, dxpl, heap_size, &free_space, &nobjs, 10, obj_size))
+ obj_size = DBLOCK_SIZE(fh, 2) + 1;
+ state.man_alloc_size += DBLOCK_SIZE(fh, 3);
+ if(add_obj(fh, dxpl, 10, obj_size, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -6547,7 +6807,7 @@ test_abs_fill_2nd_direct_skip_start_block_add_skipped(hid_t fapl, H5HF_create_t
/* Insert object to fill space in (large) block created */
obj_size = DBLOCK_FREE(fh, 3) - obj_size;
- if(add_obj(fh, dxpl, heap_size, &free_space, &nobjs, 20, obj_size))
+ if(add_obj(fh, dxpl, 20, obj_size, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -6562,11 +6822,11 @@ test_abs_fill_2nd_direct_skip_start_block_add_skipped(hid_t fapl, H5HF_create_t
} /* end if */
/* Fill rows skipped over in 3rd level indirect block's direct blocks */
- if(fill_row(fh, dxpl, cparam, &heap_size, &free_space, 0, &nobjs))
+ if(fill_row(fh, dxpl, 0, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
- if(fill_row(fh, dxpl, cparam, &heap_size, &free_space, 1, &nobjs))
+ if(fill_row(fh, dxpl, 1, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
- if(fill_row(fh, dxpl, cparam, &heap_size, &free_space, 2, &nobjs))
+ if(fill_row(fh, dxpl, 2, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -6582,7 +6842,8 @@ test_abs_fill_2nd_direct_skip_start_block_add_skipped(hid_t fapl, H5HF_create_t
/* Add one more object, to create another "large" block */
obj_size = SMALL_OBJ_SIZE1;
- if(add_obj(fh, dxpl, heap_size, &free_space, &nobjs, 10, obj_size))
+ state.man_alloc_size += DBLOCK_SIZE(fh, 3);
+ if(add_obj(fh, dxpl, 10, obj_size, &state, NULL))
FAIL_STACK_ERROR
PASSED()
@@ -6638,10 +6899,8 @@ test_abs_fill_2nd_direct_skip_2nd_indirect_start_block_add_skipped(hid_t fapl, H
H5HF_t *fh = NULL; /* Fractal heap wrapper */
haddr_t fh_addr; /* Address of fractal heap */
size_t id_len; /* Size of fractal heap IDs */
- unsigned nobjs = 0; /* Number of objects inserted */
size_t obj_size; /* Size of object */
- hsize_t free_space; /* Size of free space in heap */
- hsize_t heap_size; /* Total size of heap */
+ fheap_heap_state_t state; /* State of fractal heap */
/* Set the filename to use for this test (dependent on fapl) */
h5_fixname(FILENAME[0], fapl, filename, sizeof(filename));
@@ -6665,6 +6924,7 @@ test_abs_fill_2nd_direct_skip_2nd_indirect_start_block_add_skipped(hid_t fapl, H
FAIL_STACK_ERROR
if(!H5F_addr_defined(fh_addr))
FAIL_STACK_ERROR
+ HDmemset(&state, 0, sizeof(fheap_heap_state_t));
/*
* Test absolute heap
@@ -6672,9 +6932,7 @@ test_abs_fill_2nd_direct_skip_2nd_indirect_start_block_add_skipped(hid_t fapl, H
TESTING("filling direct blocks, filling 2nd level indirect blocks, filling 3rd level indirect block's direct blocks, and skip first rows of direct blocks of 3rd level indirect block's 2nd level indirect block, then backfill and extend");
/* Fill direct blocks in root indirect block */
- heap_size = 0;
- free_space = 0;
- if(fill_root_direct(fh, dxpl, cparam, &heap_size, &free_space, &nobjs))
+ if(fill_root_direct(fh, dxpl, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -6689,7 +6947,7 @@ test_abs_fill_2nd_direct_skip_2nd_indirect_start_block_add_skipped(hid_t fapl, H
} /* end if */
/* Fill all rows of 2nd level indirect blocks */
- if(fill_all_2nd_indirect_rows(fh, dxpl, cparam, &heap_size, &free_space, &nobjs))
+ if(fill_all_2nd_indirect_rows(fh, dxpl, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -6704,7 +6962,7 @@ test_abs_fill_2nd_direct_skip_2nd_indirect_start_block_add_skipped(hid_t fapl, H
} /* end if */
/* Fill all direct block rows in third level indirect block */
- if(fill_all_direct(fh, dxpl, cparam, &heap_size, &free_space, &nobjs))
+ if(fill_all_direct(fh, dxpl, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -6722,8 +6980,9 @@ test_abs_fill_2nd_direct_skip_2nd_indirect_start_block_add_skipped(hid_t fapl, H
* range of skipped (indirect) blocks that are too small to hold the large
* object
*/
- obj_size = (cparam->managed.start_block_size * 2) + 1;
- if(add_obj(fh, dxpl, heap_size, &free_space, &nobjs, 10, obj_size))
+ obj_size = DBLOCK_SIZE(fh, 2) + 1;
+ state.man_alloc_size += DBLOCK_SIZE(fh, 3);
+ if(add_obj(fh, dxpl, 10, obj_size, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -6739,7 +6998,7 @@ test_abs_fill_2nd_direct_skip_2nd_indirect_start_block_add_skipped(hid_t fapl, H
/* Insert object to fill space in (large) block created */
obj_size = DBLOCK_FREE(fh, 3) - obj_size;
- if(add_obj(fh, dxpl, heap_size, &free_space, &nobjs, 20, obj_size))
+ if(add_obj(fh, dxpl, 20, obj_size, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -6756,11 +7015,11 @@ test_abs_fill_2nd_direct_skip_2nd_indirect_start_block_add_skipped(hid_t fapl, H
/* Fill rows skipped over in (3rd level indirect block's) 2nd level
* indirect block's direct blocks
*/
- if(fill_row(fh, dxpl, cparam, &heap_size, &free_space, 0, &nobjs))
+ if(fill_row(fh, dxpl, 0, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
- if(fill_row(fh, dxpl, cparam, &heap_size, &free_space, 1, &nobjs))
+ if(fill_row(fh, dxpl, 1, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
- if(fill_row(fh, dxpl, cparam, &heap_size, &free_space, 2, &nobjs))
+ if(fill_row(fh, dxpl, 2, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -6776,7 +7035,8 @@ test_abs_fill_2nd_direct_skip_2nd_indirect_start_block_add_skipped(hid_t fapl, H
/* Add one more object, to create another "large" block */
obj_size = SMALL_OBJ_SIZE1;
- if(add_obj(fh, dxpl, heap_size, &free_space, &nobjs, 10, obj_size))
+ state.man_alloc_size += DBLOCK_SIZE(fh, 3);
+ if(add_obj(fh, dxpl, 10, obj_size, &state, NULL))
FAIL_STACK_ERROR
PASSED()
@@ -6831,13 +7091,9 @@ test_abs_fill_2nd_direct_fill_direct_skip_3rd_indirect_start_block_add_skipped(h
H5HF_t *fh = NULL; /* Fractal heap wrapper */
haddr_t fh_addr; /* Address of fractal heap */
size_t id_len; /* Size of fractal heap IDs */
- unsigned first_row_bits; /* Number of bits used bit addresses in first row */
- unsigned first_indirect_block_size; /* Range of addresses covered by each of the first indirect blocks */
unsigned num_first_indirect_rows; /* Number of rows (of direct blocks) in each of the first indirect blocks */
- unsigned nobjs = 0; /* Number of objects inserted */
size_t obj_size; /* Size of object */
- hsize_t free_space; /* Size of free space in heap */
- hsize_t heap_size; /* Total size of heap */
+ fheap_heap_state_t state; /* State of fractal heap */
unsigned u, v; /* Local index variables */
/* Set the filename to use for this test (dependent on fapl) */
@@ -6862,15 +7118,11 @@ test_abs_fill_2nd_direct_fill_direct_skip_3rd_indirect_start_block_add_skipped(h
FAIL_STACK_ERROR
if(!H5F_addr_defined(fh_addr))
FAIL_STACK_ERROR
+ HDmemset(&state, 0, sizeof(fheap_heap_state_t));
- /* Compute # of bits used in first row */
- first_row_bits = H5V_log2_of2(cparam->managed.start_block_size) +
- H5V_log2_of2(cparam->managed.width);
- first_indirect_block_size = 2 * cparam->managed.max_direct_size;
- num_first_indirect_rows = (H5V_log2_of2(first_indirect_block_size) - first_row_bits) + 1;
+ /* Retrieve info about heap */
+ num_first_indirect_rows = IBLOCK_MAX_DROWS(fh, 1);
#ifdef QAK
-HDfprintf(stderr, "first_row_bits = %u\n", first_row_bits);
-HDfprintf(stderr, "first_indirect_block_size = %u\n", first_indirect_block_size);
HDfprintf(stderr, "num_first_indirect_rows = %u\n", num_first_indirect_rows);
#endif /* QAK */
@@ -6880,9 +7132,7 @@ HDfprintf(stderr, "num_first_indirect_rows = %u\n", num_first_indirect_rows);
TESTING("filling direct blocks, filling 2nd level indirect blocks, filling 3rd level indirect block's direct blocks, and skip first row of indirect blocks of 3rd level indirect block, then backfill and extend");
/* Fill direct blocks in root indirect block */
- heap_size = 0;
- free_space = 0;
- if(fill_root_direct(fh, dxpl, cparam, &heap_size, &free_space, &nobjs))
+ if(fill_root_direct(fh, dxpl, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -6897,7 +7147,7 @@ HDfprintf(stderr, "num_first_indirect_rows = %u\n", num_first_indirect_rows);
} /* end if */
/* Fill all rows of 2nd level indirect blocks */
- if(fill_all_2nd_indirect_rows(fh, dxpl, cparam, &heap_size, &free_space, &nobjs))
+ if(fill_all_2nd_indirect_rows(fh, dxpl, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -6912,7 +7162,7 @@ HDfprintf(stderr, "num_first_indirect_rows = %u\n", num_first_indirect_rows);
} /* end if */
/* Fill all direct block rows in third level indirect block */
- if(fill_all_direct(fh, dxpl, cparam, &heap_size, &free_space, &nobjs))
+ if(fill_all_direct(fh, dxpl, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -6930,11 +7180,12 @@ HDfprintf(stderr, "num_first_indirect_rows = %u\n", num_first_indirect_rows);
* range of skipped (indirect) blocks that are too small to hold the large
* object
*/
- obj_size = (1 << ((num_first_indirect_rows + H5V_log2_of2(cparam->managed.start_block_size)) - 2)) + 1;
+ obj_size = DBLOCK_SIZE(fh, num_first_indirect_rows - 1) + 1;
#ifdef QAK
HDfprintf(stderr, "obj_size = %Zu\n", obj_size);
#endif /* QAK */
- if(add_obj(fh, dxpl, heap_size, &free_space, &nobjs, 20, obj_size))
+ state.man_alloc_size += DBLOCK_SIZE(fh, num_first_indirect_rows);
+ if(add_obj(fh, dxpl, 20, obj_size, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -6950,7 +7201,7 @@ HDfprintf(stderr, "obj_size = %Zu\n", obj_size);
/* Insert object to fill space in (large) block created */
obj_size = DBLOCK_FREE(fh, num_first_indirect_rows) - obj_size;
- if(add_obj(fh, dxpl, heap_size, &free_space, &nobjs, 20, obj_size))
+ if(add_obj(fh, dxpl, 20, obj_size, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -6971,11 +7222,11 @@ HDfprintf(stderr, "obj_size = %Zu\n", obj_size);
for(u = 0; u < num_first_indirect_rows; u++) {
/* Direct block rows in 2nd level indirect blocks */
for(v = 0; v < cparam->managed.width; v++)
- if(fill_row(fh, dxpl, cparam, &heap_size, &free_space, u, &nobjs))
+ if(fill_row(fh, dxpl, u, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Direct block row in 3rd level indirect block */
- if(fill_row(fh, dxpl, cparam, &heap_size, &free_space, u, &nobjs))
+ if(fill_row(fh, dxpl, u, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
} /* end for */
@@ -6992,7 +7243,8 @@ HDfprintf(stderr, "obj_size = %Zu\n", obj_size);
/* Add one more object, to create another "large" block */
obj_size = SMALL_OBJ_SIZE1;
- if(add_obj(fh, dxpl, heap_size, &free_space, &nobjs, 10, obj_size))
+ state.man_alloc_size += DBLOCK_SIZE(fh, num_first_indirect_rows);
+ if(add_obj(fh, dxpl, 10, obj_size, &state, NULL))
FAIL_STACK_ERROR
PASSED()
@@ -7048,13 +7300,9 @@ test_abs_fill_2nd_direct_fill_direct_skip2_3rd_indirect_start_block_add_skipped(
H5HF_t *fh = NULL; /* Fractal heap wrapper */
haddr_t fh_addr; /* Address of fractal heap */
size_t id_len; /* Size of fractal heap IDs */
- unsigned first_row_bits; /* Number of bits used bit addresses in first row */
- unsigned first_indirect_block_size; /* Range of addresses covered by each of the first indirect blocks */
unsigned num_first_indirect_rows; /* Number of rows (of direct blocks) in each of the first indirect blocks */
- unsigned nobjs = 0; /* Number of objects inserted */
size_t obj_size; /* Size of object */
- hsize_t free_space; /* Size of free space in heap */
- hsize_t heap_size; /* Total size of heap */
+ fheap_heap_state_t state; /* State of fractal heap */
unsigned u, v; /* Local index variables */
/* Set the filename to use for this test (dependent on fapl) */
@@ -7079,15 +7327,11 @@ test_abs_fill_2nd_direct_fill_direct_skip2_3rd_indirect_start_block_add_skipped(
FAIL_STACK_ERROR
if(!H5F_addr_defined(fh_addr))
FAIL_STACK_ERROR
+ HDmemset(&state, 0, sizeof(fheap_heap_state_t));
- /* Compute # of bits used in first row */
- first_row_bits = H5V_log2_of2(cparam->managed.start_block_size) +
- H5V_log2_of2(cparam->managed.width);
- first_indirect_block_size = 2 * cparam->managed.max_direct_size;
- num_first_indirect_rows = (H5V_log2_of2(first_indirect_block_size) - first_row_bits) + 1;
+ /* Retrieve info about heap */
+ num_first_indirect_rows = IBLOCK_MAX_DROWS(fh, 1);
#ifdef QAK
-HDfprintf(stderr, "first_row_bits = %u\n", first_row_bits);
-HDfprintf(stderr, "first_indirect_block_size = %u\n", first_indirect_block_size);
HDfprintf(stderr, "num_first_indirect_rows = %u\n", num_first_indirect_rows);
#endif /* QAK */
@@ -7097,9 +7341,7 @@ HDfprintf(stderr, "num_first_indirect_rows = %u\n", num_first_indirect_rows);
TESTING("filling direct blocks, filling 2nd level indirect blocks, filling 3rd level indirect block's direct blocks, and skip first two rows of indirect blocks of 3rd level indirect block, then backfill and extend");
/* Fill direct blocks in root indirect block */
- heap_size = 0;
- free_space = 0;
- if(fill_root_direct(fh, dxpl, cparam, &heap_size, &free_space, &nobjs))
+ if(fill_root_direct(fh, dxpl, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -7114,7 +7356,7 @@ HDfprintf(stderr, "num_first_indirect_rows = %u\n", num_first_indirect_rows);
} /* end if */
/* Fill all rows of 2nd level indirect blocks */
- if(fill_all_2nd_indirect_rows(fh, dxpl, cparam, &heap_size, &free_space, &nobjs))
+ if(fill_all_2nd_indirect_rows(fh, dxpl, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -7129,7 +7371,7 @@ HDfprintf(stderr, "num_first_indirect_rows = %u\n", num_first_indirect_rows);
} /* end if */
/* Fill all direct block rows in third level indirect block */
- if(fill_all_direct(fh, dxpl, cparam, &heap_size, &free_space, &nobjs))
+ if(fill_all_direct(fh, dxpl, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -7147,11 +7389,12 @@ HDfprintf(stderr, "num_first_indirect_rows = %u\n", num_first_indirect_rows);
* range of skipped (indirect) blocks that are too small to hold the large
* object
*/
- obj_size = (1 << ((num_first_indirect_rows + H5V_log2_of2(cparam->managed.start_block_size)) - 1)) + 1;
+ obj_size = DBLOCK_SIZE(fh, num_first_indirect_rows) + 1;
#ifdef QAK
HDfprintf(stderr, "obj_size = %Zu\n", obj_size);
#endif /* QAK */
- if(add_obj(fh, dxpl, heap_size, &free_space, &nobjs, 20, obj_size))
+ state.man_alloc_size += DBLOCK_SIZE(fh, num_first_indirect_rows + 1);
+ if(add_obj(fh, dxpl, 20, obj_size, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -7170,7 +7413,7 @@ HDfprintf(stderr, "obj_size = %Zu\n", obj_size);
#ifdef QAK
HDfprintf(stderr, "obj_size = %Zu\n", obj_size);
#endif /* QAK */
- if(add_obj(fh, dxpl, heap_size, &free_space, &nobjs, 20, obj_size))
+ if(add_obj(fh, dxpl, 20, obj_size, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -7191,14 +7434,18 @@ HDfprintf(stderr, "obj_size = %Zu\n", obj_size);
for(u = 0; u < num_first_indirect_rows; u++) {
/* Direct block rows in 2nd level indirect blocks */
for(v = 0; v < cparam->managed.width; v++)
- if(fill_row(fh, dxpl, cparam, &heap_size, &free_space, u, &nobjs))
+ if(fill_row(fh, dxpl, u, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Direct block row in 3rd level indirect block */
- if(fill_row(fh, dxpl, cparam, &heap_size, &free_space, u, &nobjs))
+ if(fill_row(fh, dxpl, u, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
} /* end for */
+ /* Fill row of direct blocks in second 3rd level indirect block */
+ if(fill_row(fh, dxpl, num_first_indirect_rows, SMALL_OBJ_SIZE1, &state, NULL))
+ FAIL_STACK_ERROR
+
/* Check for closing & re-opening the heap */
if(tparam->reopen_heap) {
/* Close heap */
@@ -7212,7 +7459,8 @@ HDfprintf(stderr, "obj_size = %Zu\n", obj_size);
/* Add one more object, to create another "large" block */
obj_size = SMALL_OBJ_SIZE1;
- if(add_obj(fh, dxpl, heap_size, &free_space, &nobjs, 10, obj_size))
+ state.man_alloc_size += DBLOCK_SIZE(fh, num_first_indirect_rows + 1);
+ if(add_obj(fh, dxpl, 10, obj_size, &state, NULL))
FAIL_STACK_ERROR
PASSED()
@@ -7244,7 +7492,7 @@ error:
* Purpose: Test filling all direct blocks in root indirect block and all
* direct blocks in 2nd level indirect blocks, all 3rd level
* indirect blocks in first row except the last one, fill direct
- * blocks in lasts 3rd level indirect block, then insert object
+ * blocks in last 3rd level indirect block, then insert object
* insert object that is too large to hold in last 3rd level
* indirect block's row of 2nd level indirect blocks (forcing the
* use of the next row of 3rd level blocks), then backfill all
@@ -7269,13 +7517,9 @@ test_abs_fill_3rd_direct_less_one_fill_direct_wrap_start_block_add_skipped(hid_t
H5HF_t *fh = NULL; /* Fractal heap wrapper */
haddr_t fh_addr; /* Address of fractal heap */
size_t id_len; /* Size of fractal heap IDs */
- unsigned first_row_bits; /* Number of bits used bit addresses in first row */
- unsigned first_indirect_block_size; /* Range of addresses covered by each of the first indirect blocks */
unsigned num_first_indirect_rows; /* Number of rows (of direct blocks) in each of the first indirect blocks */
- unsigned nobjs = 0; /* Number of objects inserted */
size_t obj_size; /* Size of object */
- hsize_t free_space; /* Size of free space in heap */
- hsize_t heap_size; /* Total size of heap */
+ fheap_heap_state_t state; /* State of fractal heap */
unsigned u, v; /* Local index variables */
/* Set the filename to use for this test (dependent on fapl) */
@@ -7300,15 +7544,11 @@ test_abs_fill_3rd_direct_less_one_fill_direct_wrap_start_block_add_skipped(hid_t
FAIL_STACK_ERROR
if(!H5F_addr_defined(fh_addr))
FAIL_STACK_ERROR
+ HDmemset(&state, 0, sizeof(fheap_heap_state_t));
- /* Compute # of bits used in first row */
- first_row_bits = H5V_log2_of2(cparam->managed.start_block_size) +
- H5V_log2_of2(cparam->managed.width);
- first_indirect_block_size = 2 * cparam->managed.max_direct_size;
- num_first_indirect_rows = (H5V_log2_of2(first_indirect_block_size) - first_row_bits) + 1;
+ /* Retrieve info about heap */
+ num_first_indirect_rows = IBLOCK_MAX_DROWS(fh, 1);
#ifdef QAK
-HDfprintf(stderr, "first_row_bits = %u\n", first_row_bits);
-HDfprintf(stderr, "first_indirect_block_size = %u\n", first_indirect_block_size);
HDfprintf(stderr, "num_first_indirect_rows = %u\n", num_first_indirect_rows);
#endif /* QAK */
@@ -7318,9 +7558,7 @@ HDfprintf(stderr, "num_first_indirect_rows = %u\n", num_first_indirect_rows);
TESTING("filling direct blocks, filling 2nd level indirect blocks, filling first row of 3rd level indirect blocks, except last one, fill all direct blocks in last 3rd level indirect block, and insert object too large for it's 2nd level indirect blocks, then backfill and extend");
/* Fill direct blocks in root indirect block */
- heap_size = 0;
- free_space = 0;
- if(fill_root_direct(fh, dxpl, cparam, &heap_size, &free_space, &nobjs))
+ if(fill_root_direct(fh, dxpl, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -7334,8 +7572,8 @@ HDfprintf(stderr, "num_first_indirect_rows = %u\n", num_first_indirect_rows);
FAIL_STACK_ERROR
} /* end if */
- /* Fill all rows of 2nd level indirect blocks in 4th level indirect block */
- if(fill_all_2nd_indirect_rows(fh, dxpl, cparam, &heap_size, &free_space, &nobjs))
+ /* Fill all rows of 2nd level indirect blocks in root indirect block */
+ if(fill_all_2nd_indirect_rows(fh, dxpl, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -7352,7 +7590,7 @@ HDfprintf(stderr, "num_first_indirect_rows = %u\n", num_first_indirect_rows);
/* Fill first row (except one) of 3rd level indirect blocks */
for(u = 0; u < cparam->managed.width - 1; u++)
/* Fill 3rd level indirect block */
- if(fill_3rd_indirect(fh, dxpl, cparam, &heap_size, &free_space, &nobjs, 1))
+ if(fill_3rd_indirect(fh, dxpl, 1, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -7367,7 +7605,7 @@ HDfprintf(stderr, "num_first_indirect_rows = %u\n", num_first_indirect_rows);
} /* end if */
/* Fill all direct block rows in last third level indirect block */
- if(fill_all_direct(fh, dxpl, cparam, &heap_size, &free_space, &nobjs))
+ if(fill_all_direct(fh, dxpl, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -7385,11 +7623,12 @@ HDfprintf(stderr, "num_first_indirect_rows = %u\n", num_first_indirect_rows);
* range of skipped (indirect) blocks that are too small to hold the large
* object
*/
- obj_size = (1 << ((num_first_indirect_rows + H5V_log2_of2(cparam->managed.start_block_size)) - 2)) + 1;
+ obj_size = DBLOCK_SIZE(fh, num_first_indirect_rows - 1) + 1;
#ifdef QAK
HDfprintf(stderr, "obj_size = %Zu\n", obj_size);
#endif /* QAK */
- if(add_obj(fh, dxpl, heap_size, &free_space, &nobjs, 20, obj_size))
+ state.man_alloc_size += DBLOCK_SIZE(fh, num_first_indirect_rows);
+ if(add_obj(fh, dxpl, 20, obj_size, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -7405,7 +7644,7 @@ HDfprintf(stderr, "obj_size = %Zu\n", obj_size);
/* Insert object to fill space in (large) block created */
obj_size = DBLOCK_FREE(fh, num_first_indirect_rows) - obj_size;
- if(add_obj(fh, dxpl, heap_size, &free_space, &nobjs, 20, obj_size))
+ if(add_obj(fh, dxpl, 20, obj_size, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -7425,11 +7664,11 @@ HDfprintf(stderr, "obj_size = %Zu\n", obj_size);
for(u = 0; u < num_first_indirect_rows; u++) {
/* Direct block rows in 2nd level indirect blocks */
for(v = 0; v < cparam->managed.width; v++)
- if(fill_row(fh, dxpl, cparam, &heap_size, &free_space, u, &nobjs))
+ if(fill_row(fh, dxpl, u, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
- /* Direct block row in current 2nd level indirect block */
- if(fill_row(fh, dxpl, cparam, &heap_size, &free_space, u, &nobjs))
+ /* Direct block row in current 3rd level indirect block */
+ if(fill_row(fh, dxpl, u, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
} /* end for */
@@ -7446,7 +7685,8 @@ HDfprintf(stderr, "obj_size = %Zu\n", obj_size);
/* Add one more object, to create another "large" block */
obj_size = SMALL_OBJ_SIZE1;
- if(add_obj(fh, dxpl, heap_size, &free_space, &nobjs, 10, obj_size))
+ state.man_alloc_size += DBLOCK_SIZE(fh, num_first_indirect_rows);
+ if(add_obj(fh, dxpl, 10, obj_size, &state, NULL))
FAIL_STACK_ERROR
PASSED()
@@ -7504,13 +7744,9 @@ test_abs_fill_1st_row_3rd_direct_fill_2nd_direct_less_one_wrap_start_block_add_s
H5HF_t *fh = NULL; /* Fractal heap wrapper */
haddr_t fh_addr; /* Address of fractal heap */
size_t id_len; /* Size of fractal heap IDs */
- unsigned first_row_bits; /* Number of bits used bit addresses in first row */
- unsigned first_indirect_block_size; /* Range of addresses covered by each of the first indirect blocks */
unsigned num_first_indirect_rows; /* Number of rows (of direct blocks) in each of the first indirect blocks */
- unsigned nobjs = 0; /* Number of objects inserted */
size_t obj_size; /* Size of object */
- hsize_t free_space; /* Size of free space in heap */
- hsize_t heap_size; /* Total size of heap */
+ fheap_heap_state_t state; /* State of fractal heap */
unsigned u; /* Local index variables */
/* Set the filename to use for this test (dependent on fapl) */
@@ -7535,15 +7771,11 @@ test_abs_fill_1st_row_3rd_direct_fill_2nd_direct_less_one_wrap_start_block_add_s
FAIL_STACK_ERROR
if(!H5F_addr_defined(fh_addr))
FAIL_STACK_ERROR
+ HDmemset(&state, 0, sizeof(fheap_heap_state_t));
- /* Compute # of bits used in first row */
- first_row_bits = H5V_log2_of2(cparam->managed.start_block_size) +
- H5V_log2_of2(cparam->managed.width);
- first_indirect_block_size = 2 * cparam->managed.max_direct_size;
- num_first_indirect_rows = (H5V_log2_of2(first_indirect_block_size) - first_row_bits) + 1;
+ /* Retrieve info about heap */
+ num_first_indirect_rows = IBLOCK_MAX_DROWS(fh, 1);
#ifdef QAK
-HDfprintf(stderr, "first_row_bits = %u\n", first_row_bits);
-HDfprintf(stderr, "first_indirect_block_size = %u\n", first_indirect_block_size);
HDfprintf(stderr, "num_first_indirect_rows = %u\n", num_first_indirect_rows);
#endif /* QAK */
@@ -7553,9 +7785,7 @@ HDfprintf(stderr, "num_first_indirect_rows = %u\n", num_first_indirect_rows);
TESTING("filling direct blocks, filling 2nd level indirect blocks, filling first row of 3rd level indirect blocks, fill all direct blocks in next 3rd level indirect block, fill all 1st row of 2nd level indirect blocks, except last one, and insert object too large for 2nd level indirect block, then backfill and extend");
/* Fill direct blocks in root indirect block */
- heap_size = 0;
- free_space = 0;
- if(fill_root_direct(fh, dxpl, cparam, &heap_size, &free_space, &nobjs))
+ if(fill_root_direct(fh, dxpl, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -7570,7 +7800,7 @@ HDfprintf(stderr, "num_first_indirect_rows = %u\n", num_first_indirect_rows);
} /* end if */
/* Fill all rows of 2nd level indirect blocks in 4th level indirect block */
- if(fill_all_2nd_indirect_rows(fh, dxpl, cparam, &heap_size, &free_space, &nobjs))
+ if(fill_all_2nd_indirect_rows(fh, dxpl, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -7585,7 +7815,7 @@ HDfprintf(stderr, "num_first_indirect_rows = %u\n", num_first_indirect_rows);
} /* end if */
/* Fill first row of 3rd level indirect blocks */
- if(fill_3rd_indirect_row(fh, dxpl, cparam, &heap_size, &free_space, &nobjs, 1))
+ if(fill_3rd_indirect_row(fh, dxpl, 1, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -7600,7 +7830,7 @@ HDfprintf(stderr, "num_first_indirect_rows = %u\n", num_first_indirect_rows);
} /* end if */
/* Fill all direct block rows in 2nd row third level indirect block */
- if(fill_all_direct(fh, dxpl, cparam, &heap_size, &free_space, &nobjs))
+ if(fill_all_direct(fh, dxpl, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -7615,10 +7845,9 @@ HDfprintf(stderr, "num_first_indirect_rows = %u\n", num_first_indirect_rows);
} /* end if */
/* Fill first row (except one) of 2nd level indirect blocks */
- for(u = 0; u < cparam->managed.width - 1; u++) {
- if(fill_2nd_indirect(fh, dxpl, cparam, &heap_size, &free_space, &nobjs, 1))
+ for(u = 0; u < cparam->managed.width - 1; u++)
+ if(fill_2nd_indirect(fh, dxpl, 1, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
- } /* end for */
/* Check for closing & re-opening the heap */
if(tparam->reopen_heap) {
@@ -7635,11 +7864,12 @@ HDfprintf(stderr, "num_first_indirect_rows = %u\n", num_first_indirect_rows);
* range of skipped (indirect) blocks that are too small to hold the large
* object
*/
- obj_size = (1 << ((num_first_indirect_rows + H5V_log2_of2(cparam->managed.start_block_size)) - 2)) + 1;
+ obj_size = DBLOCK_SIZE(fh, num_first_indirect_rows - 1) + 1;
#ifdef QAK
HDfprintf(stderr, "obj_size = %Zu\n", obj_size);
#endif /* QAK */
- if(add_obj(fh, dxpl, heap_size, &free_space, &nobjs, 20, obj_size))
+ state.man_alloc_size += DBLOCK_SIZE(fh, num_first_indirect_rows);
+ if(add_obj(fh, dxpl, 20, obj_size, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -7655,7 +7885,7 @@ HDfprintf(stderr, "obj_size = %Zu\n", obj_size);
/* Insert object to fill space in (large) block created */
obj_size = DBLOCK_FREE(fh, num_first_indirect_rows) - obj_size;
- if(add_obj(fh, dxpl, heap_size, &free_space, &nobjs, 20, obj_size))
+ if(add_obj(fh, dxpl, 20, obj_size, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -7674,11 +7904,11 @@ HDfprintf(stderr, "obj_size = %Zu\n", obj_size);
*/
for(u = 0; u < num_first_indirect_rows; u++) {
/* Direct block rows in skipped 2nd level indirect block */
- if(fill_row(fh, dxpl, cparam, &heap_size, &free_space, u, &nobjs))
+ if(fill_row(fh, dxpl, u, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Direct block row in current 2nd level indirect block */
- if(fill_row(fh, dxpl, cparam, &heap_size, &free_space, u, &nobjs))
+ if(fill_row(fh, dxpl, u, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
} /* end for */
@@ -7695,7 +7925,8 @@ HDfprintf(stderr, "obj_size = %Zu\n", obj_size);
/* Add one more object, to create another "large" block */
obj_size = SMALL_OBJ_SIZE1;
- if(add_obj(fh, dxpl, heap_size, &free_space, &nobjs, 10, obj_size))
+ state.man_alloc_size += DBLOCK_SIZE(fh, num_first_indirect_rows);
+ if(add_obj(fh, dxpl, 10, obj_size, &state, NULL))
FAIL_STACK_ERROR
PASSED()
@@ -7751,13 +7982,9 @@ test_abs_fill_3rd_direct_fill_direct_skip_start_block_add_skipped(hid_t fapl, H5
H5HF_t *fh = NULL; /* Fractal heap wrapper */
haddr_t fh_addr; /* Address of fractal heap */
size_t id_len; /* Size of fractal heap IDs */
- unsigned first_row_bits; /* Number of bits used bit addresses in first row */
- unsigned first_indirect_block_size; /* Range of addresses covered by each of the first indirect blocks */
unsigned num_first_indirect_rows; /* Number of rows (of direct blocks) in each of the first indirect blocks */
- unsigned nobjs = 0; /* Number of objects inserted */
size_t obj_size; /* Size of object */
- hsize_t free_space; /* Size of free space in heap */
- hsize_t heap_size; /* Total size of heap */
+ fheap_heap_state_t state; /* State of fractal heap */
unsigned u, v; /* Local index variables */
/* Set the filename to use for this test (dependent on fapl) */
@@ -7782,15 +8009,11 @@ test_abs_fill_3rd_direct_fill_direct_skip_start_block_add_skipped(hid_t fapl, H5
FAIL_STACK_ERROR
if(!H5F_addr_defined(fh_addr))
FAIL_STACK_ERROR
+ HDmemset(&state, 0, sizeof(fheap_heap_state_t));
- /* Compute # of bits used in first row */
- first_row_bits = H5V_log2_of2(cparam->managed.start_block_size) +
- H5V_log2_of2(cparam->managed.width);
- first_indirect_block_size = 2 * cparam->managed.max_direct_size;
- num_first_indirect_rows = (H5V_log2_of2(first_indirect_block_size) - first_row_bits) + 1;
+ /* Retrieve info about heap */
+ num_first_indirect_rows = IBLOCK_MAX_DROWS(fh, 1);
#ifdef QAK
-HDfprintf(stderr, "first_row_bits = %u\n", first_row_bits);
-HDfprintf(stderr, "first_indirect_block_size = %u\n", first_indirect_block_size);
HDfprintf(stderr, "num_first_indirect_rows = %u\n", num_first_indirect_rows);
#endif /* QAK */
@@ -7800,9 +8023,7 @@ HDfprintf(stderr, "num_first_indirect_rows = %u\n", num_first_indirect_rows);
TESTING("filling direct blocks, filling 2nd level indirect blocks, filling 3rd level indirect blocks, fill 4th level indirect block's direct blocks, and skip first row of 2nd indirect blocks of 4th level indirect block, then backfill and extend");
/* Fill direct blocks in root indirect block */
- heap_size = 0;
- free_space = 0;
- if(fill_root_direct(fh, dxpl, cparam, &heap_size, &free_space, &nobjs))
+ if(fill_root_direct(fh, dxpl, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -7817,7 +8038,7 @@ HDfprintf(stderr, "num_first_indirect_rows = %u\n", num_first_indirect_rows);
} /* end if */
/* Fill all rows of 2nd level indirect blocks */
- if(fill_all_2nd_indirect_rows(fh, dxpl, cparam, &heap_size, &free_space, &nobjs))
+ if(fill_all_2nd_indirect_rows(fh, dxpl, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -7832,7 +8053,7 @@ HDfprintf(stderr, "num_first_indirect_rows = %u\n", num_first_indirect_rows);
} /* end if */
/* Fill all rows of 3rd level indirect blocks */
- if(fill_all_3rd_indirect_rows(fh, dxpl, cparam, &heap_size, &free_space, &nobjs))
+ if(fill_all_3rd_indirect_rows(fh, dxpl, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -7847,7 +8068,7 @@ HDfprintf(stderr, "num_first_indirect_rows = %u\n", num_first_indirect_rows);
} /* end if */
/* Fill all direct block rows in fourth level indirect block */
- if(fill_all_direct(fh, dxpl, cparam, &heap_size, &free_space, &nobjs))
+ if(fill_all_direct(fh, dxpl, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -7865,11 +8086,12 @@ HDfprintf(stderr, "num_first_indirect_rows = %u\n", num_first_indirect_rows);
* range of skipped (indirect) blocks that are too small to hold the large
* object
*/
- obj_size = (1 << ((num_first_indirect_rows + H5V_log2_of2(cparam->managed.start_block_size)) - 2)) + 1;
+ obj_size = DBLOCK_SIZE(fh, num_first_indirect_rows - 1) + 1;
#ifdef QAK
HDfprintf(stderr, "obj_size = %Zu\n", obj_size);
#endif /* QAK */
- if(add_obj(fh, dxpl, heap_size, &free_space, &nobjs, 20, obj_size))
+ state.man_alloc_size += DBLOCK_SIZE(fh, num_first_indirect_rows);
+ if(add_obj(fh, dxpl, 20, obj_size, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -7885,7 +8107,7 @@ HDfprintf(stderr, "obj_size = %Zu\n", obj_size);
/* Insert object to fill space in (large) block created */
obj_size = DBLOCK_FREE(fh, num_first_indirect_rows) - obj_size;
- if(add_obj(fh, dxpl, heap_size, &free_space, &nobjs, 20, obj_size))
+ if(add_obj(fh, dxpl, 20, obj_size, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -7906,11 +8128,11 @@ HDfprintf(stderr, "obj_size = %Zu\n", obj_size);
for(u = 0; u < num_first_indirect_rows; u++) {
/* Direct block rows in 2nd level indirect blocks */
for(v = 0; v < cparam->managed.width; v++)
- if(fill_row(fh, dxpl, cparam, &heap_size, &free_space, u, &nobjs))
+ if(fill_row(fh, dxpl, u, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Direct block row in 2nd level indirect block */
- if(fill_row(fh, dxpl, cparam, &heap_size, &free_space, u, &nobjs))
+ if(fill_row(fh, dxpl, u, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
} /* end for */
@@ -7927,7 +8149,8 @@ HDfprintf(stderr, "obj_size = %Zu\n", obj_size);
/* Add one more object, to create another "large" block */
obj_size = SMALL_OBJ_SIZE1;
- if(add_obj(fh, dxpl, heap_size, &free_space, &nobjs, 10, obj_size))
+ state.man_alloc_size += DBLOCK_SIZE(fh, num_first_indirect_rows);
+ if(add_obj(fh, dxpl, 10, obj_size, &state, NULL))
FAIL_STACK_ERROR
PASSED()
@@ -7959,9 +8182,11 @@ error:
* Purpose: Test filling all direct blocks in root indirect block and all
* direct blocks in 2nd level indirect blocks, fill all direct
* blocks and indirect blocks in 3rd level indirect block, then
- * fill all direct blocks in 4th level indirect block, then
+ * fill all direct blocks and 2nd level indirect blocks in 4th
+ * level indirect block, then
* insert object that is too large to hold in first row of 2nd
- * level indirect blocks of 4th level indirect block, then
+ * level indirect blocks of 4th level indirect block's first
+ * 3rd level indirect block, then
* backfill all skipped direct blocks & extend.
*
* Return: Success: 0
@@ -7983,13 +8208,9 @@ test_abs_fill_3rd_direct_fill_2nd_direct_fill_direct_skip_3rd_indirect_start_blo
H5HF_t *fh = NULL; /* Fractal heap wrapper */
haddr_t fh_addr; /* Address of fractal heap */
size_t id_len; /* Size of fractal heap IDs */
- unsigned first_row_bits; /* Number of bits used bit addresses in first row */
- unsigned first_indirect_block_size; /* Range of addresses covered by each of the first indirect blocks */
unsigned num_first_indirect_rows; /* Number of rows (of direct blocks) in each of the first indirect blocks */
- unsigned nobjs = 0; /* Number of objects inserted */
size_t obj_size; /* Size of object */
- hsize_t free_space; /* Size of free space in heap */
- hsize_t heap_size; /* Total size of heap */
+ fheap_heap_state_t state; /* State of fractal heap */
unsigned u, v; /* Local index variables */
/* Set the filename to use for this test (dependent on fapl) */
@@ -8014,15 +8235,11 @@ test_abs_fill_3rd_direct_fill_2nd_direct_fill_direct_skip_3rd_indirect_start_blo
FAIL_STACK_ERROR
if(!H5F_addr_defined(fh_addr))
FAIL_STACK_ERROR
+ HDmemset(&state, 0, sizeof(fheap_heap_state_t));
- /* Compute # of bits used in first row */
- first_row_bits = H5V_log2_of2(cparam->managed.start_block_size) +
- H5V_log2_of2(cparam->managed.width);
- first_indirect_block_size = 2 * cparam->managed.max_direct_size;
- num_first_indirect_rows = (H5V_log2_of2(first_indirect_block_size) - first_row_bits) + 1;
+ /* Retrieve info about heap */
+ num_first_indirect_rows = IBLOCK_MAX_DROWS(fh, 1);
#ifdef QAK
-HDfprintf(stderr, "first_row_bits = %u\n", first_row_bits);
-HDfprintf(stderr, "first_indirect_block_size = %u\n", first_indirect_block_size);
HDfprintf(stderr, "num_first_indirect_rows = %u\n", num_first_indirect_rows);
#endif /* QAK */
@@ -8032,9 +8249,7 @@ HDfprintf(stderr, "num_first_indirect_rows = %u\n", num_first_indirect_rows);
TESTING("filling direct blocks, filling 2nd level indirect blocks, filling 3rd level indirect blocks, fill 4th level indirect block's direct, 2nd level indirect blocks and 3rd level direct block, and skip first row of 2nd indirect blocks of 4th level indirect block's 3rd level indirect block, then backfill and extend");
/* Fill direct blocks in root indirect block */
- heap_size = 0;
- free_space = 0;
- if(fill_root_direct(fh, dxpl, cparam, &heap_size, &free_space, &nobjs))
+ if(fill_root_direct(fh, dxpl, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -8049,7 +8264,7 @@ HDfprintf(stderr, "num_first_indirect_rows = %u\n", num_first_indirect_rows);
} /* end if */
/* Fill all rows of 2nd level indirect blocks */
- if(fill_all_2nd_indirect_rows(fh, dxpl, cparam, &heap_size, &free_space, &nobjs))
+ if(fill_all_2nd_indirect_rows(fh, dxpl, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -8064,7 +8279,7 @@ HDfprintf(stderr, "num_first_indirect_rows = %u\n", num_first_indirect_rows);
} /* end if */
/* Fill all rows of 3rd level indirect blocks */
- if(fill_all_3rd_indirect_rows(fh, dxpl, cparam, &heap_size, &free_space, &nobjs))
+ if(fill_all_3rd_indirect_rows(fh, dxpl, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -8079,7 +8294,7 @@ HDfprintf(stderr, "num_first_indirect_rows = %u\n", num_first_indirect_rows);
} /* end if */
/* Fill all direct block rows in fourth level indirect block */
- if(fill_all_direct(fh, dxpl, cparam, &heap_size, &free_space, &nobjs))
+ if(fill_all_direct(fh, dxpl, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -8094,7 +8309,7 @@ HDfprintf(stderr, "num_first_indirect_rows = %u\n", num_first_indirect_rows);
} /* end if */
/* Fill all rows of 2nd level indirect blocks in fourth level indirect block */
- if(fill_all_2nd_indirect_rows(fh, dxpl, cparam, &heap_size, &free_space, &nobjs))
+ if(fill_all_2nd_indirect_rows(fh, dxpl, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -8109,7 +8324,7 @@ HDfprintf(stderr, "num_first_indirect_rows = %u\n", num_first_indirect_rows);
} /* end if */
/* Fill all direct block rows in fourth level indirect block's 3rd level indirect block */
- if(fill_all_direct(fh, dxpl, cparam, &heap_size, &free_space, &nobjs))
+ if(fill_all_direct(fh, dxpl, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -8127,11 +8342,12 @@ HDfprintf(stderr, "num_first_indirect_rows = %u\n", num_first_indirect_rows);
* range of skipped (indirect) blocks that are too small to hold the large
* object
*/
- obj_size = (1 << ((num_first_indirect_rows + H5V_log2_of2(cparam->managed.start_block_size)) - 2)) + 1;
+ obj_size = DBLOCK_SIZE(fh, num_first_indirect_rows - 1) + 1;
#ifdef QAK
HDfprintf(stderr, "obj_size = %Zu\n", obj_size);
#endif /* QAK */
- if(add_obj(fh, dxpl, heap_size, &free_space, &nobjs, 20, obj_size))
+ state.man_alloc_size += DBLOCK_SIZE(fh, num_first_indirect_rows);
+ if(add_obj(fh, dxpl, 20, obj_size, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -8147,7 +8363,7 @@ HDfprintf(stderr, "obj_size = %Zu\n", obj_size);
/* Insert object to fill space in (large) block created */
obj_size = DBLOCK_FREE(fh, num_first_indirect_rows) - obj_size;
- if(add_obj(fh, dxpl, heap_size, &free_space, &nobjs, 20, obj_size))
+ if(add_obj(fh, dxpl, 20, obj_size, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -8168,11 +8384,11 @@ HDfprintf(stderr, "obj_size = %Zu\n", obj_size);
for(u = 0; u < num_first_indirect_rows; u++) {
/* Direct block rows in 2nd level indirect blocks */
for(v = 0; v < cparam->managed.width; v++)
- if(fill_row(fh, dxpl, cparam, &heap_size, &free_space, u, &nobjs))
+ if(fill_row(fh, dxpl, u, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Direct block row in 3rd level indirect block */
- if(fill_row(fh, dxpl, cparam, &heap_size, &free_space, u, &nobjs))
+ if(fill_row(fh, dxpl, u, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
} /* end for */
@@ -8189,7 +8405,8 @@ HDfprintf(stderr, "obj_size = %Zu\n", obj_size);
/* Add one more object, to create another "large" block */
obj_size = SMALL_OBJ_SIZE1;
- if(add_obj(fh, dxpl, heap_size, &free_space, &nobjs, 10, obj_size))
+ state.man_alloc_size += DBLOCK_SIZE(fh, num_first_indirect_rows);
+ if(add_obj(fh, dxpl, 10, obj_size, &state, NULL))
FAIL_STACK_ERROR
PASSED()
@@ -8249,13 +8466,9 @@ test_abs_fill_3rd_direct_fill_2nd_direct_fill_direct_skip_3rd_indirect_two_rows_
H5HF_t *fh = NULL; /* Fractal heap wrapper */
haddr_t fh_addr; /* Address of fractal heap */
size_t id_len; /* Size of fractal heap IDs */
- unsigned first_row_bits; /* Number of bits used bit addresses in first row */
- unsigned first_indirect_block_size; /* Range of addresses covered by each of the first indirect blocks */
unsigned num_first_indirect_rows; /* Number of rows (of direct blocks) in each of the first indirect blocks */
- unsigned nobjs = 0; /* Number of objects inserted */
size_t obj_size; /* Size of object */
- hsize_t free_space; /* Size of free space in heap */
- hsize_t heap_size; /* Total size of heap */
+ fheap_heap_state_t state; /* State of fractal heap */
unsigned u, v; /* Local index variables */
/* Set the filename to use for this test (dependent on fapl) */
@@ -8280,15 +8493,11 @@ test_abs_fill_3rd_direct_fill_2nd_direct_fill_direct_skip_3rd_indirect_two_rows_
FAIL_STACK_ERROR
if(!H5F_addr_defined(fh_addr))
FAIL_STACK_ERROR
+ HDmemset(&state, 0, sizeof(fheap_heap_state_t));
- /* Compute # of bits used in first row */
- first_row_bits = H5V_log2_of2(cparam->managed.start_block_size) +
- H5V_log2_of2(cparam->managed.width);
- first_indirect_block_size = 2 * cparam->managed.max_direct_size;
- num_first_indirect_rows = (H5V_log2_of2(first_indirect_block_size) - first_row_bits) + 1;
+ /* Retrieve info about heap */
+ num_first_indirect_rows = IBLOCK_MAX_DROWS(fh, 1);
#ifdef QAK
-HDfprintf(stderr, "first_row_bits = %u\n", first_row_bits);
-HDfprintf(stderr, "first_indirect_block_size = %u\n", first_indirect_block_size);
HDfprintf(stderr, "num_first_indirect_rows = %u\n", num_first_indirect_rows);
#endif /* QAK */
@@ -8298,9 +8507,7 @@ HDfprintf(stderr, "num_first_indirect_rows = %u\n", num_first_indirect_rows);
TESTING("filling direct blocks, filling 2nd level indirect blocks, filling 3rd level indirect blocks, fill first row of 4th level indirect blocks, fill 2nd row 4th level indirect block's direct, 2nd level indirect blocks, first row of 3rd level indirect blocks, 3rd level direct block in 2nd row, and skip first row of 2nd indirect blocks of 4th level indirect block's 3rd level indirect block, then backfill and extend");
/* Fill direct blocks in root indirect block */
- heap_size = 0;
- free_space = 0;
- if(fill_root_direct(fh, dxpl, cparam, &heap_size, &free_space, &nobjs))
+ if(fill_root_direct(fh, dxpl, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -8315,7 +8522,7 @@ HDfprintf(stderr, "num_first_indirect_rows = %u\n", num_first_indirect_rows);
} /* end if */
/* Fill all rows of 2nd level indirect blocks */
- if(fill_all_2nd_indirect_rows(fh, dxpl, cparam, &heap_size, &free_space, &nobjs))
+ if(fill_all_2nd_indirect_rows(fh, dxpl, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -8330,7 +8537,7 @@ HDfprintf(stderr, "num_first_indirect_rows = %u\n", num_first_indirect_rows);
} /* end if */
/* Fill all rows of 3rd level indirect blocks */
- if(fill_all_3rd_indirect_rows(fh, dxpl, cparam, &heap_size, &free_space, &nobjs))
+ if(fill_all_3rd_indirect_rows(fh, dxpl, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -8345,31 +8552,25 @@ HDfprintf(stderr, "num_first_indirect_rows = %u\n", num_first_indirect_rows);
} /* end if */
/* Fill first row of 4th level indirect blocks */
- if(fill_4th_indirect_row(fh, dxpl, cparam, &heap_size, &free_space, &nobjs, 1))
+ if(fill_4th_indirect_row(fh, dxpl, 1, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Account for root indirect block doubling # of rows again */
/* (From 16 rows to the max. # of rows: 22) */
+ /* (Note: this is tied to the particular doubling table/heap creation parameters) */
{
- hsize_t block_size; /* Current block size */
- hsize_t max_block_size; /* Maximum size of blocks in heap */
+ unsigned max_root_rows; /* Maximum # of rows in root indirect block */
unsigned row; /* Row in heap */
- /* Compute current & maximum block size in heap */
- block_size = cparam->managed.start_block_size * ((hsize_t)1 << 15);
- max_block_size = (((hsize_t)1 << cparam->managed.max_index) / 2) /
- cparam->managed.width;
+ /* Get some information for the heap */
+ max_root_rows = HEAP_MAX_ROOT_ROWS(fh);
/* Increase heap size & free space */
- row = 16;
- while(block_size <= max_block_size) {
- heap_size += cparam->managed.width * block_size;
- free_space += cparam->managed.width * DBLOCK_FREE(fh, row);
-
- /* Advance to next row */
- block_size *= 2;
- row++;
- } /* end while */
+ for(row = 16; row < max_root_rows; row++) {
+ state.heap_size += cparam->managed.width * DBLOCK_SIZE(fh, row);
+ state.man_size += cparam->managed.width * DBLOCK_SIZE(fh, row);
+ state.man_free_space += cparam->managed.width * DBLOCK_FREE(fh, row);
+ } /* end for */
} /* end if */
/* Check for closing & re-opening the heap */
@@ -8384,7 +8585,7 @@ HDfprintf(stderr, "num_first_indirect_rows = %u\n", num_first_indirect_rows);
} /* end if */
/* Fill all direct block rows in 2nd row 4th level indirect block */
- if(fill_all_direct(fh, dxpl, cparam, &heap_size, &free_space, &nobjs))
+ if(fill_all_direct(fh, dxpl, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -8399,7 +8600,7 @@ HDfprintf(stderr, "num_first_indirect_rows = %u\n", num_first_indirect_rows);
} /* end if */
/* Fill all rows of 2nd level indirect blocks in 2nd row 4th level indirect block */
- if(fill_all_2nd_indirect_rows(fh, dxpl, cparam, &heap_size, &free_space, &nobjs))
+ if(fill_all_2nd_indirect_rows(fh, dxpl, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -8414,7 +8615,7 @@ HDfprintf(stderr, "num_first_indirect_rows = %u\n", num_first_indirect_rows);
} /* end if */
/* Fill first row of 3rd level indirect blocks in 2nd row 4th level indirect block */
- if(fill_3rd_indirect_row(fh, dxpl, cparam, &heap_size, &free_space, &nobjs, 1))
+ if(fill_3rd_indirect_row(fh, dxpl, 1, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -8429,7 +8630,7 @@ HDfprintf(stderr, "num_first_indirect_rows = %u\n", num_first_indirect_rows);
} /* end if */
/* Fill all direct block rows in 4th level indirect block's 2nd row of 3rd level indirect block */
- if(fill_all_direct(fh, dxpl, cparam, &heap_size, &free_space, &nobjs))
+ if(fill_all_direct(fh, dxpl, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -8447,11 +8648,12 @@ HDfprintf(stderr, "num_first_indirect_rows = %u\n", num_first_indirect_rows);
* range of skipped (indirect) blocks that are too small to hold the large
* object
*/
- obj_size = (1 << ((num_first_indirect_rows + H5V_log2_of2(cparam->managed.start_block_size)) - 2)) + 1;
+ obj_size = DBLOCK_SIZE(fh, num_first_indirect_rows - 1) + 1;
#ifdef QAK
HDfprintf(stderr, "obj_size = %Zu\n", obj_size);
#endif /* QAK */
- if(add_obj(fh, dxpl, heap_size, &free_space, &nobjs, 20, obj_size))
+ state.man_alloc_size += DBLOCK_SIZE(fh, num_first_indirect_rows);
+ if(add_obj(fh, dxpl, 20, obj_size, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -8467,7 +8669,7 @@ HDfprintf(stderr, "obj_size = %Zu\n", obj_size);
/* Insert object to fill space in (large) block created */
obj_size = DBLOCK_FREE(fh, num_first_indirect_rows) - obj_size;
- if(add_obj(fh, dxpl, heap_size, &free_space, &nobjs, 20, obj_size))
+ if(add_obj(fh, dxpl, 20, obj_size, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -8488,11 +8690,11 @@ HDfprintf(stderr, "obj_size = %Zu\n", obj_size);
for(u = 0; u < num_first_indirect_rows; u++) {
/* Direct block rows in 2nd level indirect blocks */
for(v = 0; v < cparam->managed.width; v++)
- if(fill_row(fh, dxpl, cparam, &heap_size, &free_space, u, &nobjs))
+ if(fill_row(fh, dxpl, u, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Direct block row in 3rd level indirect block */
- if(fill_row(fh, dxpl, cparam, &heap_size, &free_space, u, &nobjs))
+ if(fill_row(fh, dxpl, u, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
} /* end for */
@@ -8509,7 +8711,8 @@ HDfprintf(stderr, "obj_size = %Zu\n", obj_size);
/* Add one more object, to create another "large" block */
obj_size = SMALL_OBJ_SIZE1;
- if(add_obj(fh, dxpl, heap_size, &free_space, &nobjs, 10, obj_size))
+ state.man_alloc_size += DBLOCK_SIZE(fh, num_first_indirect_rows);
+ if(add_obj(fh, dxpl, 10, obj_size, &state, NULL))
FAIL_STACK_ERROR
PASSED()
@@ -8571,13 +8774,9 @@ test_abs_fill_3rd_direct_fill_2nd_direct_fill_direct_skip_3rd_indirect_wrap_star
H5HF_t *fh = NULL; /* Fractal heap wrapper */
haddr_t fh_addr; /* Address of fractal heap */
size_t id_len; /* Size of fractal heap IDs */
- unsigned first_row_bits; /* Number of bits used bit addresses in first row */
- unsigned first_indirect_block_size; /* Range of addresses covered by each of the first indirect blocks */
unsigned num_first_indirect_rows; /* Number of rows (of direct blocks) in each of the first indirect blocks */
- unsigned nobjs = 0; /* Number of objects inserted */
size_t obj_size; /* Size of object */
- hsize_t free_space; /* Size of free space in heap */
- hsize_t heap_size; /* Total size of heap */
+ fheap_heap_state_t state; /* State of fractal heap */
unsigned u, v; /* Local index variables */
/* Set the filename to use for this test (dependent on fapl) */
@@ -8602,15 +8801,11 @@ test_abs_fill_3rd_direct_fill_2nd_direct_fill_direct_skip_3rd_indirect_wrap_star
FAIL_STACK_ERROR
if(!H5F_addr_defined(fh_addr))
FAIL_STACK_ERROR
+ HDmemset(&state, 0, sizeof(fheap_heap_state_t));
- /* Compute # of bits used in first row */
- first_row_bits = H5V_log2_of2(cparam->managed.start_block_size) +
- H5V_log2_of2(cparam->managed.width);
- first_indirect_block_size = 2 * cparam->managed.max_direct_size;
- num_first_indirect_rows = (H5V_log2_of2(first_indirect_block_size) - first_row_bits) + 1;
+ /* Retrieve info about heap */
+ num_first_indirect_rows = IBLOCK_MAX_DROWS(fh, 1);
#ifdef QAK
-HDfprintf(stderr, "first_row_bits = %u\n", first_row_bits);
-HDfprintf(stderr, "first_indirect_block_size = %u\n", first_indirect_block_size);
HDfprintf(stderr, "num_first_indirect_rows = %u\n", num_first_indirect_rows);
#endif /* QAK */
@@ -8620,9 +8815,7 @@ HDfprintf(stderr, "num_first_indirect_rows = %u\n", num_first_indirect_rows);
TESTING("filling direct blocks, filling 2nd level indirect blocks, filling 3rd level indirect blocks, fill first row of 3rd level indirect blocks in 4th level indirect block except last 3rd level block, fill direct blocks in 3rd level block, and skip row of 2nd indirect blocks of 4th level indirect block's 3rd level indirect block, then backfill and extend");
/* Fill direct blocks in root indirect block */
- heap_size = 0;
- free_space = 0;
- if(fill_root_direct(fh, dxpl, cparam, &heap_size, &free_space, &nobjs))
+ if(fill_root_direct(fh, dxpl, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -8637,7 +8830,7 @@ HDfprintf(stderr, "num_first_indirect_rows = %u\n", num_first_indirect_rows);
} /* end if */
/* Fill all rows of 2nd level indirect blocks */
- if(fill_all_2nd_indirect_rows(fh, dxpl, cparam, &heap_size, &free_space, &nobjs))
+ if(fill_all_2nd_indirect_rows(fh, dxpl, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -8652,7 +8845,7 @@ HDfprintf(stderr, "num_first_indirect_rows = %u\n", num_first_indirect_rows);
} /* end if */
/* Fill all rows of 3rd level indirect blocks */
- if(fill_all_3rd_indirect_rows(fh, dxpl, cparam, &heap_size, &free_space, &nobjs))
+ if(fill_all_3rd_indirect_rows(fh, dxpl, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -8667,7 +8860,7 @@ HDfprintf(stderr, "num_first_indirect_rows = %u\n", num_first_indirect_rows);
} /* end if */
/* Fill all direct block rows in 4th level indirect block */
- if(fill_all_direct(fh, dxpl, cparam, &heap_size, &free_space, &nobjs))
+ if(fill_all_direct(fh, dxpl, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -8682,7 +8875,7 @@ HDfprintf(stderr, "num_first_indirect_rows = %u\n", num_first_indirect_rows);
} /* end if */
/* Fill all rows of 2nd level indirect blocks in 4th level indirect block */
- if(fill_all_2nd_indirect_rows(fh, dxpl, cparam, &heap_size, &free_space, &nobjs))
+ if(fill_all_2nd_indirect_rows(fh, dxpl, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -8699,11 +8892,11 @@ HDfprintf(stderr, "num_first_indirect_rows = %u\n", num_first_indirect_rows);
/* Fill first row (except one) of 3rd level indirect blocks in 4th level indirect block */
for(u = 0; u < cparam->managed.width - 1; u++) {
/* Fill all direct block rows in 3rd level indirect block */
- if(fill_all_direct(fh, dxpl, cparam, &heap_size, &free_space, &nobjs))
+ if(fill_all_direct(fh, dxpl, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Fill row of 2nd level indirect blocks in 3rd level indirect block */
- if(fill_2nd_indirect_row(fh, dxpl, cparam, &heap_size, &free_space, &nobjs, 1))
+ if(fill_2nd_indirect_row(fh, dxpl, 1, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
} /* end for */
@@ -8719,7 +8912,7 @@ HDfprintf(stderr, "num_first_indirect_rows = %u\n", num_first_indirect_rows);
} /* end if */
/* Fill all direct block rows in 4th level indirect block's last 3rd level indirect block */
- if(fill_all_direct(fh, dxpl, cparam, &heap_size, &free_space, &nobjs))
+ if(fill_all_direct(fh, dxpl, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -8737,11 +8930,12 @@ HDfprintf(stderr, "num_first_indirect_rows = %u\n", num_first_indirect_rows);
* range of skipped (indirect) blocks that are too small to hold the large
* object
*/
- obj_size = (1 << ((num_first_indirect_rows + H5V_log2_of2(cparam->managed.start_block_size)) - 2)) + 1;
+ obj_size = DBLOCK_SIZE(fh, num_first_indirect_rows - 1) + 1;
#ifdef QAK
HDfprintf(stderr, "obj_size = %Zu\n", obj_size);
#endif /* QAK */
- if(add_obj(fh, dxpl, heap_size, &free_space, &nobjs, 20, obj_size))
+ state.man_alloc_size += DBLOCK_SIZE(fh, num_first_indirect_rows);
+ if(add_obj(fh, dxpl, 20, obj_size, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -8757,7 +8951,7 @@ HDfprintf(stderr, "obj_size = %Zu\n", obj_size);
/* Insert object to fill space in (large) block created */
obj_size = DBLOCK_FREE(fh, num_first_indirect_rows) - obj_size;
- if(add_obj(fh, dxpl, heap_size, &free_space, &nobjs, 20, obj_size))
+ if(add_obj(fh, dxpl, 20, obj_size, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -8778,11 +8972,11 @@ HDfprintf(stderr, "obj_size = %Zu\n", obj_size);
for(u = 0; u < num_first_indirect_rows; u++) {
/* Direct block rows in 2nd level indirect blocks */
for(v = 0; v < cparam->managed.width; v++)
- if(fill_row(fh, dxpl, cparam, &heap_size, &free_space, u, &nobjs))
+ if(fill_row(fh, dxpl, u, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Direct block row in 4th level indirect block */
- if(fill_row(fh, dxpl, cparam, &heap_size, &free_space, u, &nobjs))
+ if(fill_row(fh, dxpl, u, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
} /* end for */
@@ -8799,7 +8993,8 @@ HDfprintf(stderr, "obj_size = %Zu\n", obj_size);
/* Add one more object, to create another "large" block */
obj_size = SMALL_OBJ_SIZE1;
- if(add_obj(fh, dxpl, heap_size, &free_space, &nobjs, 10, obj_size))
+ state.man_alloc_size += DBLOCK_SIZE(fh, num_first_indirect_rows);
+ if(add_obj(fh, dxpl, 10, obj_size, &state, NULL))
FAIL_STACK_ERROR
PASSED()
@@ -8861,13 +9056,9 @@ test_abs_fill_4th_direct_less_one_fill_2nd_direct_fill_direct_skip_3rd_indirect_
H5HF_t *fh = NULL; /* Fractal heap wrapper */
haddr_t fh_addr; /* Address of fractal heap */
size_t id_len; /* Size of fractal heap IDs */
- unsigned first_row_bits; /* Number of bits used bit addresses in first row */
- unsigned first_indirect_block_size; /* Range of addresses covered by each of the first indirect blocks */
unsigned num_first_indirect_rows; /* Number of rows (of direct blocks) in each of the first indirect blocks */
- unsigned nobjs = 0; /* Number of objects inserted */
size_t obj_size; /* Size of object */
- hsize_t free_space; /* Size of free space in heap */
- hsize_t heap_size; /* Total size of heap */
+ fheap_heap_state_t state; /* State of fractal heap */
unsigned u, v; /* Local index variables */
/* Set the filename to use for this test (dependent on fapl) */
@@ -8892,15 +9083,11 @@ test_abs_fill_4th_direct_less_one_fill_2nd_direct_fill_direct_skip_3rd_indirect_
FAIL_STACK_ERROR
if(!H5F_addr_defined(fh_addr))
FAIL_STACK_ERROR
+ HDmemset(&state, 0, sizeof(fheap_heap_state_t));
- /* Compute # of bits used in first row */
- first_row_bits = H5V_log2_of2(cparam->managed.start_block_size) +
- H5V_log2_of2(cparam->managed.width);
- first_indirect_block_size = 2 * cparam->managed.max_direct_size;
- num_first_indirect_rows = (H5V_log2_of2(first_indirect_block_size) - first_row_bits) + 1;
+ /* Retrieve info about heap */
+ num_first_indirect_rows = IBLOCK_MAX_DROWS(fh, 1);
#ifdef QAK
-HDfprintf(stderr, "first_row_bits = %u\n", first_row_bits);
-HDfprintf(stderr, "first_indirect_block_size = %u\n", first_indirect_block_size);
HDfprintf(stderr, "num_first_indirect_rows = %u\n", num_first_indirect_rows);
#endif /* QAK */
@@ -8910,9 +9097,7 @@ HDfprintf(stderr, "num_first_indirect_rows = %u\n", num_first_indirect_rows);
TESTING("filling direct blocks, filling 2nd level indirect blocks, filling 3rd level indirect blocks, fill first row of 4th level indirect blocks, except last one, fill first row of 3rd level indirect blocks in last 4th level indirect block except last 3rd level block, fill direct blocks in 3rd level block, and skip row of 2nd indirect blocks of 4th level indirect block's 3rd level indirect block, then backfill and extend");
/* Fill direct blocks in root indirect block */
- heap_size = 0;
- free_space = 0;
- if(fill_root_direct(fh, dxpl, cparam, &heap_size, &free_space, &nobjs))
+ if(fill_root_direct(fh, dxpl, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -8927,7 +9112,7 @@ HDfprintf(stderr, "num_first_indirect_rows = %u\n", num_first_indirect_rows);
} /* end if */
/* Fill all rows of 2nd level indirect blocks */
- if(fill_all_2nd_indirect_rows(fh, dxpl, cparam, &heap_size, &free_space, &nobjs))
+ if(fill_all_2nd_indirect_rows(fh, dxpl, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -8942,7 +9127,7 @@ HDfprintf(stderr, "num_first_indirect_rows = %u\n", num_first_indirect_rows);
} /* end if */
/* Fill all rows of 3rd level indirect blocks */
- if(fill_all_3rd_indirect_rows(fh, dxpl, cparam, &heap_size, &free_space, &nobjs))
+ if(fill_all_3rd_indirect_rows(fh, dxpl, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -8959,15 +9144,15 @@ HDfprintf(stderr, "num_first_indirect_rows = %u\n", num_first_indirect_rows);
/* Fill first row (except one) of 4th level indirect blocks */
for(u = 0; u < cparam->managed.width - 1; u++) {
/* Fill all direct block rows in 4th level indirect block */
- if(fill_all_direct(fh, dxpl, cparam, &heap_size, &free_space, &nobjs))
+ if(fill_all_direct(fh, dxpl, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Fill all rows of 2nd level indirect blocks in 4th level indirect block */
- if(fill_all_2nd_indirect_rows(fh, dxpl, cparam, &heap_size, &free_space, &nobjs))
+ if(fill_all_2nd_indirect_rows(fh, dxpl, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Fill row of 3rd level indirect blocks in 4th level indirect block */
- if(fill_3rd_indirect_row(fh, dxpl, cparam, &heap_size, &free_space, &nobjs, 1))
+ if(fill_3rd_indirect_row(fh, dxpl, 1, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
} /* end for */
@@ -8983,7 +9168,7 @@ HDfprintf(stderr, "num_first_indirect_rows = %u\n", num_first_indirect_rows);
} /* end if */
/* Fill all direct block rows in 4th level indirect block */
- if(fill_all_direct(fh, dxpl, cparam, &heap_size, &free_space, &nobjs))
+ if(fill_all_direct(fh, dxpl, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -8998,7 +9183,7 @@ HDfprintf(stderr, "num_first_indirect_rows = %u\n", num_first_indirect_rows);
} /* end if */
/* Fill all rows of 2nd level indirect blocks in 4th level indirect block */
- if(fill_all_2nd_indirect_rows(fh, dxpl, cparam, &heap_size, &free_space, &nobjs))
+ if(fill_all_2nd_indirect_rows(fh, dxpl, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -9015,11 +9200,11 @@ HDfprintf(stderr, "num_first_indirect_rows = %u\n", num_first_indirect_rows);
/* Fill row (except one) of 3rd level indirect blocks in 4th level indirect block */
for(u = 0; u < cparam->managed.width - 1; u++) {
/* Fill all direct block rows in 3rd level indirect block */
- if(fill_all_direct(fh, dxpl, cparam, &heap_size, &free_space, &nobjs))
+ if(fill_all_direct(fh, dxpl, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Fill row of 2nd level indirect blocks in 3rd level indirect block */
- if(fill_2nd_indirect_row(fh, dxpl, cparam, &heap_size, &free_space, &nobjs, 1))
+ if(fill_2nd_indirect_row(fh, dxpl, 1, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
} /* end for */
@@ -9035,31 +9220,25 @@ HDfprintf(stderr, "num_first_indirect_rows = %u\n", num_first_indirect_rows);
} /* end if */
/* Fill all direct block rows in 4th level indirect block's last 3rd level indirect block */
- if(fill_all_direct(fh, dxpl, cparam, &heap_size, &free_space, &nobjs))
+ if(fill_all_direct(fh, dxpl, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Account for root indirect block doubling # of rows again */
/* (From 16 rows to the max. # of rows: 22) */
+ /* (Note: this is tied to the particular doubling table/heap creation parameters) */
{
- hsize_t block_size; /* Current block size */
- hsize_t max_block_size; /* Maximum size of blocks in heap */
+ unsigned max_root_rows; /* Maximum # of rows in root indirect block */
unsigned row; /* Row in heap */
- /* Compute current & maximum block size in heap */
- block_size = cparam->managed.start_block_size * ((hsize_t)1 << 15);
- max_block_size = (((hsize_t)1 << cparam->managed.max_index) / 2) /
- cparam->managed.width;
+ /* Get some information for the heap */
+ max_root_rows = HEAP_MAX_ROOT_ROWS(fh);
/* Increase heap size & free space */
- row = 16;
- while(block_size <= max_block_size) {
- heap_size += cparam->managed.width * block_size;
- free_space += cparam->managed.width * DBLOCK_FREE(fh, row);
-
- /* Advance to next row */
- block_size *= 2;
- row++;
- } /* end while */
+ for(row = 16; row < max_root_rows; row++) {
+ state.heap_size += cparam->managed.width * DBLOCK_SIZE(fh, row);
+ state.man_size += cparam->managed.width * DBLOCK_SIZE(fh, row);
+ state.man_free_space += cparam->managed.width * DBLOCK_FREE(fh, row);
+ } /* end for */
} /* end if */
/* Check for closing & re-opening the heap */
@@ -9077,11 +9256,12 @@ HDfprintf(stderr, "num_first_indirect_rows = %u\n", num_first_indirect_rows);
* range of skipped (indirect) blocks that are too small to hold the large
* object
*/
- obj_size = (1 << ((num_first_indirect_rows + H5V_log2_of2(cparam->managed.start_block_size)) - 2)) + 1;
+ obj_size = DBLOCK_SIZE(fh, num_first_indirect_rows - 1) + 1;
#ifdef QAK
HDfprintf(stderr, "obj_size = %Zu\n", obj_size);
#endif /* QAK */
- if(add_obj(fh, dxpl, heap_size, &free_space, &nobjs, 20, obj_size))
+ state.man_alloc_size += DBLOCK_SIZE(fh, num_first_indirect_rows);
+ if(add_obj(fh, dxpl, 20, obj_size, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -9097,7 +9277,7 @@ HDfprintf(stderr, "obj_size = %Zu\n", obj_size);
/* Insert object to fill space in (large) block created */
obj_size = DBLOCK_FREE(fh, num_first_indirect_rows) - obj_size;
- if(add_obj(fh, dxpl, heap_size, &free_space, &nobjs, 20, obj_size))
+ if(add_obj(fh, dxpl, 20, obj_size, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -9118,11 +9298,11 @@ HDfprintf(stderr, "obj_size = %Zu\n", obj_size);
for(u = 0; u < num_first_indirect_rows; u++) {
/* Direct block rows in 2nd level indirect blocks */
for(v = 0; v < cparam->managed.width; v++)
- if(fill_row(fh, dxpl, cparam, &heap_size, &free_space, u, &nobjs))
+ if(fill_row(fh, dxpl, u, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Direct block row in 4th level indirect block */
- if(fill_row(fh, dxpl, cparam, &heap_size, &free_space, u, &nobjs))
+ if(fill_row(fh, dxpl, u, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
} /* end for */
@@ -9139,7 +9319,8 @@ HDfprintf(stderr, "obj_size = %Zu\n", obj_size);
/* Add one more object, to create another "large" block */
obj_size = SMALL_OBJ_SIZE1;
- if(add_obj(fh, dxpl, heap_size, &free_space, &nobjs, 10, obj_size))
+ state.man_alloc_size += DBLOCK_SIZE(fh, num_first_indirect_rows);
+ if(add_obj(fh, dxpl, 10, obj_size, &state, NULL))
FAIL_STACK_ERROR
PASSED()
@@ -9163,9 +9344,7 @@ error:
} H5E_END_TRY;
return(1);
} /* test_abs_fill_4th_direct_less_one_fill_2nd_direct_fill_direct_skip_3rd_indirect_wrap_start_block_add_skipped() */
-#endif /* QAK */
-#ifndef QAK
/*-------------------------------------------------------------------------
* Function: test_abs_skip_direct_skip_indirect_two_rows_add_skipped
@@ -9197,10 +9376,8 @@ test_abs_skip_direct_skip_indirect_two_rows_add_skipped(hid_t fapl, H5HF_create_
size_t id_len; /* Size of fractal heap IDs */
unsigned num_direct_rows; /* Number of rows (of direct blocks) in root indirect block */
unsigned row; /* Current row */
- unsigned nobjs = 0; /* Number of objects inserted */
size_t obj_size; /* Size of object */
- hsize_t free_space; /* Size of free space in heap */
- hsize_t heap_size; /* Total size of heap */
+ fheap_heap_state_t state; /* State of fractal heap */
unsigned v; /* Local index variables */
/* Set the filename to use for this test (dependent on fapl) */
@@ -9225,10 +9402,10 @@ test_abs_skip_direct_skip_indirect_two_rows_add_skipped(hid_t fapl, H5HF_create_
FAIL_STACK_ERROR
if(!H5F_addr_defined(fh_addr))
FAIL_STACK_ERROR
+ HDmemset(&state, 0, sizeof(fheap_heap_state_t));
/* Compute # direct block rows in root indirect block */
- num_direct_rows = (H5V_log2_of2(cparam->managed.max_direct_size) -
- H5V_log2_of2(cparam->managed.start_block_size)) + 3;
+ num_direct_rows = DTABLE_MAX_DROWS(fh);
/*
* Test absolute heap
@@ -9236,25 +9413,26 @@ test_abs_skip_direct_skip_indirect_two_rows_add_skipped(hid_t fapl, H5HF_create_
TESTING("skipping direct blocks to last row and skipping two rows of root indirect block, then backfill and extend");
/* Compute heap size & free space when half direct blocks allocated */
- heap_size = 0;
- free_space = 0;
row = 0;
do{
- heap_size += cparam->managed.width * DBLOCK_SIZE(fh, row);
- free_space += cparam->managed.width * DBLOCK_FREE(fh, row);
+ state.heap_size += cparam->managed.width * DBLOCK_SIZE(fh, row);
+ state.man_size += cparam->managed.width * DBLOCK_SIZE(fh, row);
+ state.man_free_space += cparam->managed.width * DBLOCK_FREE(fh, row);
row++;
} while(row < (num_direct_rows / 2));
/* Insert object to extend root block to middle of root direct blocks
*/
- obj_size = (DBLOCK_SIZE(fh, row - 1) / 2) + 1;
- if(add_obj(fh, dxpl, heap_size, &free_space, &nobjs, 10, obj_size))
+ obj_size = DBLOCK_SIZE(fh, row - 2) + 1;
+ state.man_alloc_size += DBLOCK_SIZE(fh, row -1);
+ if(add_obj(fh, dxpl, 10, obj_size, &state, NULL))
FAIL_STACK_ERROR
/* Compute heap size & free space when all direct blocks allocated */
do{
- heap_size += cparam->managed.width * DBLOCK_SIZE(fh, row);
- free_space += cparam->managed.width * DBLOCK_FREE(fh, row);
+ state.heap_size += cparam->managed.width * DBLOCK_SIZE(fh, row);
+ state.man_size += cparam->managed.width * DBLOCK_SIZE(fh, row);
+ state.man_free_space += cparam->managed.width * DBLOCK_FREE(fh, row);
row++;
} while(row < num_direct_rows);
@@ -9262,10 +9440,12 @@ test_abs_skip_direct_skip_indirect_two_rows_add_skipped(hid_t fapl, H5HF_create_
* block, to force extension of root indirect block that covers the first
* row of indirect blocks in root indirect block
*/
- obj_size = (cparam->managed.max_direct_size / 2) + 1;
- for(v = 0; v < cparam->managed.width; v++)
- if(add_obj(fh, dxpl, heap_size, &free_space, &nobjs, 20, obj_size))
+ obj_size = DBLOCK_SIZE(fh, num_direct_rows - 2) + 1;
+ for(v = 0; v < cparam->managed.width; v++) {
+ state.man_alloc_size += DBLOCK_SIZE(fh, num_direct_rows -1);
+ if(add_obj(fh, dxpl, 20, obj_size, &state, NULL))
FAIL_STACK_ERROR
+ } /* end for */
/* Check for closing & re-opening the heap */
if(tparam->reopen_heap) {
@@ -9280,16 +9460,18 @@ test_abs_skip_direct_skip_indirect_two_rows_add_skipped(hid_t fapl, H5HF_create_
/* Compute heap size & free space when root indirect block doubles again */
do{
- heap_size += cparam->managed.width * DBLOCK_SIZE(fh, row);
- free_space += cparam->managed.width * DBLOCK_FREE(fh, row);
+ state.heap_size += cparam->managed.width * DBLOCK_SIZE(fh, row);
+ state.man_size += cparam->managed.width * DBLOCK_SIZE(fh, row);
+ state.man_free_space += cparam->managed.width * DBLOCK_FREE(fh, row);
row++;
} while(row < (2 * num_direct_rows));
/* Insert large object, to force creation of indirect blocks with
* range of skipped blocks that are too small to hold the large object
*/
- obj_size = (cparam->managed.max_direct_size / 2) + 1;
- if(add_obj(fh, dxpl, heap_size, &free_space, &nobjs, 20, obj_size))
+ obj_size = DBLOCK_SIZE(fh, num_direct_rows - 2) + 1;
+ state.man_alloc_size += DBLOCK_SIZE(fh, num_direct_rows -1);
+ if(add_obj(fh, dxpl, 20, obj_size, &state, NULL))
FAIL_STACK_ERROR
PASSED()
@@ -9320,11 +9502,10 @@ error:
/*-------------------------------------------------------------------------
* Function: test_abs_frag_simple
*
- * Purpose: Test inserting small object to create root direct block, then
- * insert objects small enough to fit into first row of direct
- * blocks, but not to share a block with another object, until
- * initial-block-size * 2 blocks are reached. Then, go back and
- * fill in the space in the blocks skipped.
+ * Purpose: Test inserting objects small enough to fit into first row of
+ * direct blocks, but not to share a block with another object,
+ * until start-block-size * 2 blocks are reached. Then, go back
+ * and fill in the space in the blocks skipped.
*
* Return: Success: 0
*
@@ -9345,10 +9526,8 @@ test_abs_frag_simple(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tpar
H5HF_t *fh = NULL; /* Fractal heap wrapper */
haddr_t fh_addr; /* Address of fractal heap */
size_t id_len; /* Size of fractal heap IDs */
- unsigned nobjs = 0; /* Number of objects inserted */
size_t obj_size; /* Size of object */
- hsize_t free_space; /* Size of free space in heap */
- hsize_t heap_size; /* Total size of heap */
+ fheap_heap_state_t state; /* State of fractal heap */
unsigned u; /* Local index variables */
/* Set the filename to use for this test (dependent on fapl) */
@@ -9373,6 +9552,7 @@ test_abs_frag_simple(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tpar
FAIL_STACK_ERROR
if(!H5F_addr_defined(fh_addr))
FAIL_STACK_ERROR
+ HDmemset(&state, 0, sizeof(fheap_heap_state_t));
/*
* Test absolute heap
@@ -9383,22 +9563,28 @@ test_abs_frag_simple(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tpar
* share them with other objects of the same size, until the next larger
* block size is reached.
*/
- obj_size = cparam->managed.start_block_size / 2;
- heap_size = cparam->managed.start_block_size;
- free_space = DBLOCK_FREE(fh, 0);
+ obj_size = DBLOCK_SIZE(fh, 0) / 2;
+ state.heap_size = DBLOCK_SIZE(fh, 0);
+ state.man_size = DBLOCK_SIZE(fh, 0);
+ state.man_free_space = DBLOCK_FREE(fh, 0);
for(u = 0; u < cparam->managed.width; u++) {
- if(add_obj(fh, dxpl, heap_size, &free_space, &nobjs, 10, obj_size))
+ state.man_alloc_size += DBLOCK_SIZE(fh, 0);
+ if(add_obj(fh, dxpl, 10, obj_size, &state, NULL))
FAIL_STACK_ERROR
if(u == 0) {
- heap_size = cparam->managed.start_block_size * cparam->managed.width;
- free_space += DBLOCK_FREE(fh, 0) * (cparam->managed.width - 1);
+ state.heap_size = cparam->managed.width * DBLOCK_SIZE(fh, 0);
+ state.man_size = cparam->managed.width * DBLOCK_SIZE(fh, 0);
+ state.man_free_space += (cparam->managed.width - 1) * DBLOCK_FREE(fh, 0);
} /* end if */
} /* end for */
- heap_size += cparam->managed.start_block_size * cparam->managed.width;
- free_space += DBLOCK_FREE(fh, 1) * cparam->managed.width;
- for(u = 0; u < cparam->managed.width; u++)
- if(add_obj(fh, dxpl, heap_size, &free_space, &nobjs, 10, obj_size))
+ state.heap_size += DBLOCK_SIZE(fh, 1) * cparam->managed.width;
+ state.man_size += DBLOCK_SIZE(fh, 1) * cparam->managed.width;
+ state.man_free_space += DBLOCK_FREE(fh, 1) * cparam->managed.width;
+ for(u = 0; u < cparam->managed.width; u++) {
+ state.man_alloc_size += DBLOCK_SIZE(fh, 1);
+ if(add_obj(fh, dxpl, 10, obj_size, &state, NULL))
FAIL_STACK_ERROR
+ } /* end for */
/* Check for closing & re-opening the heap */
if(tparam->reopen_heap) {
@@ -9411,13 +9597,16 @@ test_abs_frag_simple(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tpar
FAIL_STACK_ERROR
} /* end if */
+ /* (Account for doubling root indirect block for rows 3-4 */
+ for(u = 0; u < 2; u++) {
+ state.heap_size += DBLOCK_SIZE(fh, u + 2) * cparam->managed.width;
+ state.man_size += DBLOCK_SIZE(fh, u + 2) * cparam->managed.width;
+ state.man_free_space += DBLOCK_FREE(fh, u + 2) * cparam->managed.width;
+ } /* end for */
+
/* Add one more object, to create a 2 * start_block_size block */
- /* (Account for doubling root indirect block in calc. below) */
- heap_size += (cparam->managed.start_block_size * 2) * cparam->managed.width;
- heap_size += (cparam->managed.start_block_size * 4) * cparam->managed.width;
- free_space += DBLOCK_FREE(fh, 2) * cparam->managed.width;
- free_space += DBLOCK_FREE(fh, 3) * cparam->managed.width;
- if(add_obj(fh, dxpl, heap_size, &free_space, &nobjs, 10, obj_size))
+ state.man_alloc_size += DBLOCK_SIZE(fh, 2);
+ if(add_obj(fh, dxpl, 10, obj_size, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -9434,10 +9623,10 @@ test_abs_frag_simple(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tpar
/* Go back and fill in direct blocks of initial block size (which have large free space in them) */
obj_size = DBLOCK_FREE(fh, 0) - obj_size;
for(u = 0; u < cparam->managed.width; u++)
- if(add_obj(fh, dxpl, heap_size, &free_space, &nobjs, 20, obj_size))
+ if(add_obj(fh, dxpl, 20, obj_size, &state, NULL))
FAIL_STACK_ERROR
for(u = 0; u < cparam->managed.width; u++)
- if(add_obj(fh, dxpl, heap_size, &free_space, &nobjs, 20, obj_size))
+ if(add_obj(fh, dxpl, 20, obj_size, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -9452,8 +9641,8 @@ test_abs_frag_simple(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tpar
} /* end if */
/* Fill in 2 * start_block_size block */
- obj_size = DBLOCK_FREE(fh, 2) - (cparam->managed.start_block_size / 2);
- if(add_obj(fh, dxpl, heap_size, &free_space, &nobjs, 20, obj_size))
+ obj_size = DBLOCK_FREE(fh, 2) - (DBLOCK_SIZE(fh, 0) / 2);
+ if(add_obj(fh, dxpl, 20, obj_size, &state, NULL))
FAIL_STACK_ERROR
PASSED()
@@ -9505,13 +9694,9 @@ test_abs_frag_direct(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tpar
H5HF_t *fh = NULL; /* Fractal heap wrapper */
haddr_t fh_addr; /* Address of fractal heap */
size_t id_len; /* Size of fractal heap IDs */
- hsize_t block_mult; /* Base block size multiplier */
- unsigned base_row; /* Base row for adding new rows */
- unsigned nobjs = 0; /* Number of objects inserted */
unsigned root_direct_rows; /* Number of rows in root indirect block */
size_t obj_size; /* Size of object */
- hsize_t free_space; /* Size of free space in heap */
- hsize_t heap_size; /* Total size of heap */
+ fheap_heap_state_t state; /* State of fractal heap */
unsigned u, v; /* Local index variables */
/* Set the filename to use for this test (dependent on fapl) */
@@ -9536,9 +9721,10 @@ test_abs_frag_direct(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tpar
FAIL_STACK_ERROR
if(!H5F_addr_defined(fh_addr))
FAIL_STACK_ERROR
+ HDmemset(&state, 0, sizeof(fheap_heap_state_t));
- /* Compute # of direct rows in root indirect block */
- root_direct_rows = (H5V_log2_of2(cparam->managed.max_direct_size) - H5V_log2_of2(cparam->managed.start_block_size)) + 2;
+ /* Retrieve # of direct rows in root indirect block */
+ root_direct_rows = H5HF_get_dtable_max_drows_test(fh);
/*
* Test absolute heap
@@ -9548,24 +9734,30 @@ test_abs_frag_direct(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tpar
/* Insert objects small enough to fit into each direct block, but not to
* share them with other objects of the same size.
*/
- obj_size = cparam->managed.start_block_size / 2;
- heap_size = cparam->managed.start_block_size;
- free_space = DBLOCK_FREE(fh, 0);
+ obj_size = DBLOCK_SIZE(fh, 0) / 2;
+ state.heap_size = DBLOCK_SIZE(fh, 0);
+ state.man_size = DBLOCK_SIZE(fh, 0);
+ state.man_free_space = DBLOCK_FREE(fh, 0);
/* First row */
for(u = 0; u < cparam->managed.width; u++) {
- if(add_obj(fh, dxpl, heap_size, &free_space, &nobjs, 10, obj_size))
+ state.man_alloc_size += DBLOCK_SIZE(fh, 0);
+ if(add_obj(fh, dxpl, 10, obj_size, &state, NULL))
FAIL_STACK_ERROR
if(u == 0) {
- heap_size = cparam->managed.start_block_size * cparam->managed.width;
- free_space += DBLOCK_FREE(fh, 0) * (cparam->managed.width - 1);
+ state.heap_size = cparam->managed.width * DBLOCK_SIZE(fh, 0);
+ state.man_size = cparam->managed.width * DBLOCK_SIZE(fh, 0);
+ state.man_free_space += (cparam->managed.width - 1) * DBLOCK_FREE(fh, 0);
} /* end if */
} /* end for */
- heap_size += cparam->managed.start_block_size * cparam->managed.width;
- free_space += DBLOCK_FREE(fh, 1) * cparam->managed.width;
+ state.heap_size += DBLOCK_SIZE(fh, 1) * cparam->managed.width;
+ state.man_size += DBLOCK_SIZE(fh, 1) * cparam->managed.width;
+ state.man_free_space += DBLOCK_FREE(fh, 1) * cparam->managed.width;
/* Second row */
- for(u = 0; u < cparam->managed.width; u++)
- if(add_obj(fh, dxpl, heap_size, &free_space, &nobjs, 10, obj_size))
+ for(u = 0; u < cparam->managed.width; u++) {
+ state.man_alloc_size += DBLOCK_SIZE(fh, 1);
+ if(add_obj(fh, dxpl, 10, obj_size, &state, NULL))
FAIL_STACK_ERROR
+ } /* end for */
/* Check for closing & re-opening the heap */
if(tparam->reopen_heap) {
@@ -9579,22 +9771,20 @@ test_abs_frag_direct(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tpar
} /* end if */
/* (Account for doubling root indirect block for rows 3-4 */
- base_row = 2;
- block_mult = 2;
for(u = 0; u < 2; u++) {
- heap_size += (cparam->managed.start_block_size * block_mult) * cparam->managed.width;
- free_space += DBLOCK_FREE(fh, base_row + u) * cparam->managed.width;
- block_mult *= 2;
+ state.heap_size += DBLOCK_SIZE(fh, u + 2) * cparam->managed.width;
+ state.man_size += DBLOCK_SIZE(fh, u + 2) * cparam->managed.width;
+ state.man_free_space += DBLOCK_FREE(fh, u + 2) * cparam->managed.width;
} /* end for */
/* Rows 3-4 */
- block_mult = 2;
for(u = 0; u < 2; u++) {
- obj_size = (cparam->managed.start_block_size * block_mult) / 2;
- for(v = 0; v < cparam->managed.width; v++)
- if(add_obj(fh, dxpl, heap_size, &free_space, &nobjs, 10, obj_size))
+ obj_size = DBLOCK_SIZE(fh, u + 2) / 2;
+ for(v = 0; v < cparam->managed.width; v++) {
+ state.man_alloc_size += DBLOCK_SIZE(fh, u + 2);
+ if(add_obj(fh, dxpl, 10, obj_size, &state, NULL))
FAIL_STACK_ERROR
- block_mult *= 2;
+ } /* end for */
} /* end for */
/* Check for closing & re-opening the heap */
@@ -9609,22 +9799,20 @@ test_abs_frag_direct(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tpar
} /* end if */
/* (Account for doubling root indirect block for rows 5-8 */
- base_row = 4;
- block_mult = 8;
for(u = 0; u < 4; u++) {
- heap_size += (cparam->managed.start_block_size * block_mult) * cparam->managed.width;
- free_space += DBLOCK_FREE(fh, base_row + u) * cparam->managed.width;
- block_mult *= 2;
+ state.heap_size += DBLOCK_SIZE(fh, u + 4) * cparam->managed.width;
+ state.man_size += DBLOCK_SIZE(fh, u + 4) * cparam->managed.width;
+ state.man_free_space += DBLOCK_FREE(fh, u + 4) * cparam->managed.width;
} /* end for */
/* Rows 5-8 */
- block_mult = 8;
for(u = 0; u < 4; u++) {
- obj_size = (cparam->managed.start_block_size * block_mult) / 2;
- for(v = 0; v < cparam->managed.width; v++)
- if(add_obj(fh, dxpl, heap_size, &free_space, &nobjs, 10, obj_size))
+ obj_size = DBLOCK_SIZE(fh, u + 4) / 2;
+ for(v = 0; v < cparam->managed.width; v++) {
+ state.man_alloc_size += DBLOCK_SIZE(fh, u + 4);
+ if(add_obj(fh, dxpl, 10, obj_size, &state, NULL))
FAIL_STACK_ERROR
- block_mult *= 2;
+ } /* end for */
} /* end for */
/* Check for closing & re-opening the heap */
@@ -9639,20 +9827,19 @@ test_abs_frag_direct(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tpar
} /* end if */
/* (Account for doubling root indirect block for rows 9-16 */
- base_row = 8;
- block_mult = 128;
for(u = 0; u < 8; u++) {
- heap_size += (cparam->managed.start_block_size * block_mult) * cparam->managed.width;
- free_space += DBLOCK_FREE(fh, base_row + u) * cparam->managed.width;
- block_mult *= 2;
+ state.heap_size += DBLOCK_SIZE(fh, u + 8) * cparam->managed.width;
+ state.man_size += DBLOCK_SIZE(fh, u + 8) * cparam->managed.width;
+ state.man_free_space += DBLOCK_FREE(fh, u + 8) * cparam->managed.width;
} /* end for */
/* Row 9 (last direct block row) */
- block_mult = 128;
- obj_size = (cparam->managed.start_block_size * block_mult) / 2;
- for(v = 0; v < cparam->managed.width; v++)
- if(add_obj(fh, dxpl, heap_size, &free_space, &nobjs, 10, obj_size))
+ obj_size = DBLOCK_SIZE(fh, 8) / 2;
+ for(v = 0; v < cparam->managed.width; v++) {
+ state.man_alloc_size += DBLOCK_SIZE(fh, 8);
+ if(add_obj(fh, dxpl, 10, obj_size, &state, NULL))
FAIL_STACK_ERROR
+ } /* end for */
/* Check for closing & re-opening the heap */
if(tparam->reopen_heap) {
@@ -9666,14 +9853,11 @@ test_abs_frag_direct(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tpar
} /* end if */
/* Go back and backfill all root block's direct blocks */
- block_mult = 1;
for(u = 0; u < root_direct_rows; u++) {
- obj_size = DBLOCK_FREE(fh, u) - ((cparam->managed.start_block_size * block_mult) / 2);
+ obj_size = DBLOCK_FREE(fh, u) - (DBLOCK_SIZE(fh, u) / 2);
for(v = 0; v < cparam->managed.width; v++)
- if(add_obj(fh, dxpl, heap_size, &free_space, &nobjs, 10, obj_size))
+ if(add_obj(fh, dxpl, 20, obj_size, &state, NULL))
FAIL_STACK_ERROR
- if(u != 0)
- block_mult *= 2;
} /* end for */
PASSED()
@@ -9727,14 +9911,9 @@ test_abs_frag_2nd_direct(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *
H5HF_t *fh = NULL; /* Fractal heap wrapper */
haddr_t fh_addr; /* Address of fractal heap */
size_t id_len; /* Size of fractal heap IDs */
- hsize_t block_mult; /* Base block size multiplier */
- unsigned first_row_bits; /* Number of bits used bit addresses in first row */
- unsigned first_indirect_block_size; /* Range of addresses covered by each of the first indirect blocks */
unsigned num_first_indirect_rows; /* Number of rows (of direct blocks) in each of the first indirect blocks */
- unsigned nobjs = 0; /* Number of objects inserted */
size_t obj_size; /* Size of object */
- hsize_t free_space; /* Size of free space in heap */
- hsize_t heap_size; /* Total size of heap */
+ fheap_heap_state_t state; /* State of fractal heap */
unsigned u, v; /* Local index variables */
/* Set the filename to use for this test (dependent on fapl) */
@@ -9759,15 +9938,11 @@ test_abs_frag_2nd_direct(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *
FAIL_STACK_ERROR
if(!H5F_addr_defined(fh_addr))
FAIL_STACK_ERROR
+ HDmemset(&state, 0, sizeof(fheap_heap_state_t));
/* Compute # of bits used in first row */
- first_row_bits = H5V_log2_of2(cparam->managed.start_block_size) +
- H5V_log2_of2(cparam->managed.width);
- first_indirect_block_size = 2 * cparam->managed.max_direct_size;
- num_first_indirect_rows = (H5V_log2_of2(first_indirect_block_size) - first_row_bits) + 1;
+ num_first_indirect_rows = IBLOCK_MAX_DROWS(fh, 1);
#ifdef QAK
-HDfprintf(stderr, "first_row_bits = %u\n", first_row_bits);
-HDfprintf(stderr, "first_indirect_block_size = %u\n", first_indirect_block_size);
HDfprintf(stderr, "num_first_indirect_rows = %u\n", num_first_indirect_rows);
#endif /* QAK */
@@ -9777,9 +9952,7 @@ HDfprintf(stderr, "num_first_indirect_rows = %u\n", num_first_indirect_rows);
TESTING("fill root direct blocks, then fragment 2nd level indirect block's direct blocks, then backfill and extend");
/* Fill direct blocks in root indirect block */
- heap_size = 0;
- free_space = 0;
- if(fill_root_direct(fh, dxpl, cparam, &heap_size, &free_space, &nobjs))
+ if(fill_root_direct(fh, dxpl, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -9796,14 +9969,13 @@ HDfprintf(stderr, "num_first_indirect_rows = %u\n", num_first_indirect_rows);
/* Insert objects small enough to fit into each direct block, but not to
* share them with other objects of the same size.
*/
- block_mult = 1;
for(u = 0; u < num_first_indirect_rows; u++) {
- obj_size = (cparam->managed.start_block_size * block_mult) / 2;
- for(v = 0; v < cparam->managed.width; v++)
- if(add_obj(fh, dxpl, heap_size, &free_space, &nobjs, 10, obj_size))
+ obj_size = DBLOCK_SIZE(fh, u) / 2;
+ for(v = 0; v < cparam->managed.width; v++) {
+ state.man_alloc_size += DBLOCK_SIZE(fh, u);
+ if(add_obj(fh, dxpl, 10, obj_size, &state, NULL))
FAIL_STACK_ERROR
- if(u != 0)
- block_mult *= 2;
+ } /* end for */
} /* end for */
/* Check for closing & re-opening the heap */
@@ -9818,14 +9990,11 @@ HDfprintf(stderr, "num_first_indirect_rows = %u\n", num_first_indirect_rows);
} /* end if */
/* Go back and backfill all 2nd level indirect block's direct blocks */
- block_mult = 1;
for(u = 0; u < num_first_indirect_rows; u++) {
- obj_size = DBLOCK_FREE(fh, u) - ((cparam->managed.start_block_size * block_mult) / 2);
+ obj_size = DBLOCK_FREE(fh, u) - (DBLOCK_SIZE(fh, u) / 2);
for(v = 0; v < cparam->managed.width; v++)
- if(add_obj(fh, dxpl, heap_size, &free_space, &nobjs, 10, obj_size))
+ if(add_obj(fh, dxpl, 20, obj_size, &state, NULL))
FAIL_STACK_ERROR
- if(u != 0)
- block_mult *= 2;
} /* end for */
PASSED()
@@ -9880,12 +10049,9 @@ test_abs_frag_3rd_direct(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *
H5HF_t *fh = NULL; /* Fractal heap wrapper */
haddr_t fh_addr; /* Address of fractal heap */
size_t id_len; /* Size of fractal heap IDs */
- hsize_t block_mult; /* Base block size multiplier */
unsigned root_direct_rows; /* Number of rows in root indirect block */
- unsigned nobjs = 0; /* Number of objects inserted */
size_t obj_size; /* Size of object */
- hsize_t free_space; /* Size of free space in heap */
- hsize_t heap_size; /* Total size of heap */
+ fheap_heap_state_t state; /* State of fractal heap */
unsigned u, v; /* Local index variables */
/* Set the filename to use for this test (dependent on fapl) */
@@ -9910,9 +10076,10 @@ test_abs_frag_3rd_direct(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *
FAIL_STACK_ERROR
if(!H5F_addr_defined(fh_addr))
FAIL_STACK_ERROR
+ HDmemset(&state, 0, sizeof(fheap_heap_state_t));
/* Compute # of direct rows in root indirect block */
- root_direct_rows = (H5V_log2_of2(cparam->managed.max_direct_size) - H5V_log2_of2(cparam->managed.start_block_size)) + 2;
+ root_direct_rows = DTABLE_MAX_DROWS(fh);
/*
* Test absolute heap
@@ -9920,9 +10087,7 @@ test_abs_frag_3rd_direct(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *
TESTING("fill root direct blocks and 2nd level indirect blocks, then fragment 3rd level indirect block's direct blocks, then backfill and extend");
/* Fill direct blocks in root indirect block */
- heap_size = 0;
- free_space = 0;
- if(fill_root_direct(fh, dxpl, cparam, &heap_size, &free_space, &nobjs))
+ if(fill_root_direct(fh, dxpl, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -9937,7 +10102,7 @@ test_abs_frag_3rd_direct(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *
} /* end if */
/* Fill all rows of 2nd level indirect blocks in root indirect block */
- if(fill_all_2nd_indirect_rows(fh, dxpl, cparam, &heap_size, &free_space, &nobjs))
+ if(fill_all_2nd_indirect_rows(fh, dxpl, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -9954,14 +10119,13 @@ test_abs_frag_3rd_direct(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *
/* Insert objects small enough to fit into each direct block, but not to
* share them with other objects of the same size.
*/
- block_mult = 1;
for(u = 0; u < root_direct_rows; u++) {
- obj_size = (cparam->managed.start_block_size * block_mult) / 2;
- for(v = 0; v < cparam->managed.width; v++)
- if(add_obj(fh, dxpl, heap_size, &free_space, &nobjs, 10, obj_size))
+ obj_size = DBLOCK_SIZE(fh, u) / 2;
+ for(v = 0; v < cparam->managed.width; v++) {
+ state.man_alloc_size += DBLOCK_SIZE(fh, u);
+ if(add_obj(fh, dxpl, 10, obj_size, &state, NULL))
FAIL_STACK_ERROR
- if(u != 0)
- block_mult *= 2;
+ } /* end for */
} /* end for */
/* Check for closing & re-opening the heap */
@@ -9976,14 +10140,11 @@ test_abs_frag_3rd_direct(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *
} /* end if */
/* Go back and backfill all 3rd level indirect block's direct blocks */
- block_mult = 1;
for(u = 0; u < root_direct_rows; u++) {
- obj_size = DBLOCK_FREE(fh, u) - ((cparam->managed.start_block_size * block_mult) / 2);
+ obj_size = DBLOCK_FREE(fh, u) - (DBLOCK_SIZE(fh, u) / 2);
for(v = 0; v < cparam->managed.width; v++)
- if(add_obj(fh, dxpl, heap_size, &free_space, &nobjs, 10, obj_size))
+ if(add_obj(fh, dxpl, 20, obj_size, &state, NULL))
FAIL_STACK_ERROR
- if(u != 0)
- block_mult *= 2;
} /* end for */
PASSED()
@@ -10039,8 +10200,6 @@ test_abs_random_managed(hsize_t size_limit, hid_t fapl, H5HF_create_t *cparam, f
unsigned long seed; /* Random # seed */
size_t num_ids = 0; /* # of heap IDs in array */
size_t alloc_ids = 0; /* # of heap IDs allocated in array */
- unsigned char *obj = NULL; /* Buffer for object to insert */
- unsigned char *robj = NULL; /* Buffer for reading object */
hsize_t total_obj_added; /* Size of objects added */
size_t obj_size; /* Size of object */
size_t obj_loc; /* Location of object in buffer */
@@ -10085,11 +10244,6 @@ HDfprintf(stderr, "Random # seed was: %lu\n", seed);
#endif /* QAK */
HDsrandom(seed);
- /* Initialize the buffer for objects to insert */
- obj = H5MM_malloc(cparam->standalone_size);
- for(u = 0; u < cparam->standalone_size; u++)
- obj[u] = (unsigned char)u;
-
/* Loop over adding objects to the heap, until the size limit is reached */
total_obj_added = 0;
while(total_obj_added < size_limit) {
@@ -10111,7 +10265,7 @@ HDfprintf(stderr, "num_ids = %Zu, total_obj_added = %Hu, obj_size = %Zu\n", num_
/* Insert object */
obj_loc = cparam->standalone_size - obj_size;
- if(H5HF_insert(fh, dxpl, obj_size, &obj[obj_loc], &ids[(num_ids - 1) * HEAP_ID_LEN]) < 0)
+ if(H5HF_insert(fh, dxpl, obj_size, &shared_wobj_g[obj_loc], &ids[(num_ids - 1) * HEAP_ID_LEN]) < 0)
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -10129,9 +10283,6 @@ HDfprintf(stderr, "num_ids = %Zu, total_obj_added = %Hu, obj_size = %Zu\n", num_
total_obj_added += obj_size;
} /* end while */
- /* Allocate buffer for reading objects */
- robj = H5MM_malloc(cparam->standalone_size);
-
/* Verify reading the objects written out */
for(u = 0; u < num_ids; u++) {
/* Get object length */
@@ -10139,15 +10290,15 @@ HDfprintf(stderr, "num_ids = %Zu, total_obj_added = %Hu, obj_size = %Zu\n", num_
FAIL_STACK_ERROR
/* Clear read buffer */
- HDmemset(robj, 0, obj_size);
+ HDmemset(shared_robj_g, 0, obj_size);
/* Read in object */
- if(H5HF_read(fh, dxpl, &ids[u * HEAP_ID_LEN], robj) < 0)
+ if(H5HF_read(fh, dxpl, &ids[u * HEAP_ID_LEN], shared_robj_g) < 0)
FAIL_STACK_ERROR
/* Check for correct object */
obj_loc = cparam->standalone_size - obj_size;
- if(HDmemcmp(&obj[obj_loc], robj, obj_size))
+ if(HDmemcmp(&shared_wobj_g[obj_loc], shared_robj_g, obj_size))
FAIL_STACK_ERROR
} /* end for */
@@ -10162,8 +10313,6 @@ HDfprintf(stderr, "num_ids = %Zu, total_obj_added = %Hu, obj_size = %Zu\n", num_
TEST_ERROR
/* All tests passed */
- H5MM_xfree(obj);
- H5MM_xfree(robj);
H5MM_xfree(ids);
return(0);
@@ -10172,8 +10321,6 @@ error:
if(fh)
H5HF_close(fh, dxpl);
H5Fclose(file);
- H5MM_xfree(obj);
- H5MM_xfree(robj);
H5MM_xfree(ids);
} H5E_END_TRY;
HDfprintf(stderr, "Random # seed was: %lu\n", seed);
@@ -10210,8 +10357,6 @@ test_abs_random_pow2_managed(hsize_t size_limit, hid_t fapl, H5HF_create_t *cpar
unsigned long seed; /* Random # seed */
size_t num_ids = 0; /* # of heap IDs in array */
size_t alloc_ids = 0; /* # of heap IDs allocated in array */
- unsigned char *obj = NULL; /* Buffer for object to insert */
- unsigned char *robj = NULL; /* Buffer for reading object */
hsize_t total_obj_added; /* Size of objects added */
size_t obj_size; /* Size of object */
size_t obj_loc; /* Location of object in buffer */
@@ -10256,11 +10401,6 @@ HDfprintf(stderr, "Random # seed was: %lu\n", seed);
#endif /* QAK */
HDsrandom(seed);
- /* Initialize the buffer for objects to insert */
- obj = H5MM_malloc(cparam->standalone_size);
- for(u = 0; u < cparam->standalone_size; u++)
- obj[u] = (unsigned char)u;
-
/* Loop over adding objects to the heap, until the size limit is reached */
total_obj_added = 0;
while(total_obj_added < size_limit) {
@@ -10295,7 +10435,7 @@ if((num_ids % 100000) == 1)
/* Insert object */
obj_loc = cparam->standalone_size - obj_size;
- if(H5HF_insert(fh, dxpl, obj_size, &obj[obj_loc], &ids[(num_ids - 1) * HEAP_ID_LEN]) < 0)
+ if(H5HF_insert(fh, dxpl, obj_size, &shared_wobj_g[obj_loc], &ids[(num_ids - 1) * HEAP_ID_LEN]) < 0)
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -10313,9 +10453,6 @@ if((num_ids % 100000) == 1)
total_obj_added += obj_size;
} /* end while */
- /* Allocate buffer for reading objects */
- robj = H5MM_malloc(cparam->standalone_size);
-
/* Verify reading the objects written out */
for(u = 0; u < num_ids; u++) {
/* Get object length */
@@ -10323,15 +10460,15 @@ if((num_ids % 100000) == 1)
FAIL_STACK_ERROR
/* Clear read buffer */
- HDmemset(robj, 0, obj_size);
+ HDmemset(shared_robj_g, 0, obj_size);
/* Read in object */
- if(H5HF_read(fh, dxpl, &ids[u * HEAP_ID_LEN], robj) < 0)
+ if(H5HF_read(fh, dxpl, &ids[u * HEAP_ID_LEN], shared_robj_g) < 0)
FAIL_STACK_ERROR
/* Check for correct object */
obj_loc = cparam->standalone_size - obj_size;
- if(HDmemcmp(&obj[obj_loc], robj, obj_size))
+ if(HDmemcmp(&shared_wobj_g[obj_loc], shared_robj_g, obj_size))
FAIL_STACK_ERROR
} /* end for */
@@ -10346,8 +10483,6 @@ if((num_ids % 100000) == 1)
TEST_ERROR
/* All tests passed */
- H5MM_xfree(obj);
- H5MM_xfree(robj);
H5MM_xfree(ids);
return(0);
@@ -10356,8 +10491,6 @@ error:
if(fh)
H5HF_close(fh, dxpl);
H5Fclose(file);
- H5MM_xfree(obj);
- H5MM_xfree(robj);
H5MM_xfree(ids);
} H5E_END_TRY;
HDfprintf(stderr, "Random # seed was: %lu\n", seed);
@@ -10392,10 +10525,8 @@ test_abs_remove_bogus(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tpa
haddr_t fh_addr; /* Address of fractal heap */
unsigned char heap_id[HEAP_ID_LEN]; /* Heap ID for object */
size_t id_len; /* Size of fractal heap IDs */
- unsigned nobjs = 0; /* Number of objects inserted */
- hsize_t free_space; /* Size of free space in heap */
- hsize_t heap_size; /* Total size of heap */
hsize_t obj_off; /* Offset of object in heap */
+ fheap_heap_state_t state; /* State of fractal heap */
unsigned u; /* Local index variable */
herr_t ret; /* Generic return value */
@@ -10421,7 +10552,8 @@ test_abs_remove_bogus(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tpa
FAIL_STACK_ERROR
if(!H5F_addr_defined(fh_addr))
FAIL_STACK_ERROR
- if(check_stats(fh, (hsize_t)0, (hsize_t)0, (hsize_t)0, (hsize_t)0, (hsize_t)0))
+ HDmemset(&state, 0, sizeof(fheap_heap_state_t));
+ if(check_stats(fh, &state))
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -10452,9 +10584,7 @@ test_abs_remove_bogus(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tpa
FAIL_STACK_ERROR
/* Fill root direct blocks */
- heap_size = 0;
- free_space = 0;
- if(fill_root_direct(fh, dxpl, cparam, &heap_size, &free_space, &nobjs))
+ if(fill_root_direct(fh, dxpl, SMALL_OBJ_SIZE1, &state, NULL))
FAIL_STACK_ERROR
/* Get offset of random heap ID */
@@ -10462,7 +10592,7 @@ test_abs_remove_bogus(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tpa
FAIL_STACK_ERROR
/* Make certain we can't accidentally use a valid heap ID */
- while(obj_off < heap_size) {
+ while(obj_off < state.heap_size) {
/* Set heap ID to random (non-null) value */
for(u = 0; u < HEAP_ID_LEN; u++)
heap_id[u] = HDrandom() + 1;
@@ -10472,7 +10602,7 @@ test_abs_remove_bogus(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tpa
FAIL_STACK_ERROR
} /* end while */
- /* Try removing bogus heap ID from empty heap */
+ /* Try removing bogus heap ID from heap w/objects */
H5E_BEGIN_TRY {
ret = H5HF_remove(fh, dxpl, heap_id);
} H5E_END_TRY;
@@ -10500,7 +10630,6 @@ error:
} H5E_END_TRY;
return(1);
} /* test_abs_remove_bogus() */
-#endif /* QAK */
/*-------------------------------------------------------------------------
@@ -10529,8 +10658,9 @@ test_abs_remove_one(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tpara
unsigned char heap_id[HEAP_ID_LEN]; /* Heap ID for object */
unsigned char obj[SMALL_OBJ_SIZE1]; /* Buffer for object to insert */
size_t id_len; /* Size of fractal heap IDs */
- hsize_t free_space; /* Size of free space in heap */
- hsize_t heap_size; /* Total size of heap */
+ off_t empty_size; /* Size of a file with an empty heap */
+ off_t file_size; /* Size of file currently */
+ fheap_heap_state_t state; /* State of fractal heap */
unsigned u; /* Local index variable */
/* Set the filename to use for this test (dependent on fapl) */
@@ -10555,7 +10685,70 @@ test_abs_remove_one(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tpara
FAIL_STACK_ERROR
if(!H5F_addr_defined(fh_addr))
FAIL_STACK_ERROR
- if(check_stats(fh, (hsize_t)0, (hsize_t)0, (hsize_t)0, (hsize_t)0, (hsize_t)0))
+ HDmemset(&state, 0, sizeof(fheap_heap_state_t));
+ if(check_stats(fh, &state))
+ FAIL_STACK_ERROR
+
+ /* Prepare for querying the size of a file with an empty heap */
+
+ /* Close (empty) heap */
+ if(H5HF_close(fh, dxpl) < 0)
+ TEST_ERROR
+
+ /* Close file */
+ if(H5Fclose(file)<0) TEST_ERROR;
+
+ /* Get the size of a file w/empty heap*/
+ if((empty_size = h5_get_file_size(filename)) == 0)
+ TEST_ERROR
+
+ /* Re-open the file */
+ if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0)
+ TEST_ERROR
+
+ /* Get a pointer to the internal file object */
+ if(NULL == (f = H5I_object(file)))
+ STACK_ERROR
+
+ /* Re-open heap */
+ if(NULL == (fh = H5HF_open(f, dxpl, fh_addr)))
+ FAIL_STACK_ERROR
+
+ /*
+ * Test removing first (small) object from absolute heap
+ */
+ TESTING("removing single object from absolute heap");
+
+ /* Initialize the buffer for objects to insert */
+ for(u = 0; u < sizeof(obj); u++)
+ obj[u] = u;
+
+ /* Insert object into heap */
+ if(H5HF_insert(fh, dxpl, sizeof(obj), obj, &heap_id) < 0)
+ FAIL_STACK_ERROR
+
+ /* Check for closing & re-opening the heap */
+ if(tparam->reopen_heap) {
+ /* Close (empty) heap */
+ if(H5HF_close(fh, dxpl) < 0)
+ TEST_ERROR
+
+ /* Re-open heap */
+ if(NULL == (fh = H5HF_open(f, dxpl, fh_addr)))
+ FAIL_STACK_ERROR
+ } /* end if */
+
+ /* Check up on heap... */
+ state.heap_size = DBLOCK_SIZE(fh, 0);
+ state.man_size = DBLOCK_SIZE(fh, 0);
+ state.man_alloc_size = DBLOCK_SIZE(fh, 0);
+ state.man_free_space = DBLOCK_FREE(fh, 0) - sizeof(obj);
+ state.nobjs = 1;
+ if(check_stats(fh, &state))
+ FAIL_STACK_ERROR
+
+ /* Remove object from heap */
+ if(H5HF_remove(fh, dxpl, heap_id) < 0)
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -10569,17 +10762,354 @@ test_abs_remove_one(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tpara
FAIL_STACK_ERROR
} /* end if */
+ /* Check up on heap... */
+ state.heap_size = 0;
+ state.man_size = 0;
+ state.man_alloc_size = 0;
+ state.man_free_space = 0;
+ state.nobjs = 0;
+ if(check_stats(fh, &state))
+ FAIL_STACK_ERROR
+
+ /* Close the fractal heap */
+ if(H5HF_close(fh, dxpl) < 0)
+ TEST_ERROR
+
+ /* Close the file */
+ if(H5Fclose(file) < 0)
+ TEST_ERROR
+
+ /* Get the size of the file */
+ if((file_size = h5_get_file_size(filename)) == 0)
+ TEST_ERROR
+
+ /* Verify the file is correct size */
+ if(file_size != empty_size)
+ TEST_ERROR
+
+ PASSED()
+
+ /* All tests passed */
+ return(0);
+
+error:
+ H5E_BEGIN_TRY {
+ if(fh)
+ H5HF_close(fh, dxpl);
+ H5Fclose(file);
+ } H5E_END_TRY;
+ return(1);
+} /* test_abs_remove_one() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: test_abs_remove_two
+ *
+ * Purpose: Test removing two objects from heap
+ *
+ * Return: Success: 0
+ *
+ * Failure: 1
+ *
+ * Programmer: Quincey Koziol
+ * Monday, May 22, 2006
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+test_abs_remove_two(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam)
+{
+ hid_t file = -1; /* File ID */
+ hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */
+ char filename[1024]; /* Filename to use */
+ H5F_t *f = NULL; /* Internal file object pointer */
+ H5HF_t *fh = NULL; /* Fractal heap wrapper */
+ haddr_t fh_addr; /* Address of fractal heap */
+ unsigned char heap_id1[HEAP_ID_LEN]; /* Heap ID for first object */
+ unsigned char heap_id2[HEAP_ID_LEN]; /* Heap ID for second object */
+ unsigned char obj[SMALL_OBJ_SIZE1]; /* Buffer for object to insert */
+ size_t id_len; /* Size of fractal heap IDs */
+ off_t empty_size; /* Size of a file with an empty heap */
+ off_t file_size; /* Size of file currently */
+ fheap_heap_state_t state; /* State of fractal heap */
+ unsigned u; /* Local index variable */
+
+ /* Set the filename to use for this test (dependent on fapl) */
+ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename));
+
+ /* Create the file to work on */
+ if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
+ TEST_ERROR
+
+ /* Get a pointer to the internal file object */
+ if(NULL == (f = H5I_object(file)))
+ STACK_ERROR
+
+ /* Create absolute heap */
+ if(NULL == (fh = H5HF_create(f, dxpl, cparam)))
+ FAIL_STACK_ERROR
+ if(H5HF_get_id_len(fh, &id_len) < 0)
+ FAIL_STACK_ERROR
+ if(id_len > HEAP_ID_LEN)
+ FAIL_STACK_ERROR
+ if(H5HF_get_heap_addr(fh, &fh_addr) < 0)
+ FAIL_STACK_ERROR
+ if(!H5F_addr_defined(fh_addr))
+ FAIL_STACK_ERROR
+ HDmemset(&state, 0, sizeof(fheap_heap_state_t));
+ if(check_stats(fh, &state))
+ FAIL_STACK_ERROR
+
+ /* Prepare for querying the size of a file with an empty heap */
+
+ /* Close (empty) heap */
+ if(H5HF_close(fh, dxpl) < 0)
+ TEST_ERROR
+
+ /* Close file */
+ if(H5Fclose(file)<0) TEST_ERROR;
+
+ /* Get the size of a file w/empty heap*/
+ if((empty_size = h5_get_file_size(filename)) == 0)
+ TEST_ERROR
+
+ /* Re-open the file */
+ if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0)
+ TEST_ERROR
+
+ /* Get a pointer to the internal file object */
+ if(NULL == (f = H5I_object(file)))
+ STACK_ERROR
+
+ /* Re-open heap */
+ if(NULL == (fh = H5HF_open(f, dxpl, fh_addr)))
+ FAIL_STACK_ERROR
+
/*
- * Test removing first (small) object from absolute heap
+ * Test removing two (small) objects from absolute heap
*/
- TESTING("removing single object from absolute heap");
+ TESTING("removing two objects from absolute heap");
/* Initialize the buffer for objects to insert */
for(u = 0; u < sizeof(obj); u++)
obj[u] = u;
+ /* Insert first object into heap */
+ if(H5HF_insert(fh, dxpl, sizeof(obj), obj, &heap_id1) < 0)
+ FAIL_STACK_ERROR
+
+ /* Check for closing & re-opening the heap */
+ if(tparam->reopen_heap) {
+ /* Close (empty) heap */
+ if(H5HF_close(fh, dxpl) < 0)
+ TEST_ERROR
+
+ /* Re-open heap */
+ if(NULL == (fh = H5HF_open(f, dxpl, fh_addr)))
+ FAIL_STACK_ERROR
+ } /* end if */
+
+ /* Check up on heap... */
+ state.heap_size = DBLOCK_SIZE(fh, 0);
+ state.man_size = DBLOCK_SIZE(fh, 0);
+ state.man_alloc_size = DBLOCK_SIZE(fh, 0);
+ state.man_free_space = DBLOCK_FREE(fh, 0) - sizeof(obj);
+ state.nobjs = 1;
+ if(check_stats(fh, &state))
+ FAIL_STACK_ERROR
+
+ /* Insert second object into heap */
+ if(H5HF_insert(fh, dxpl, sizeof(obj), obj, &heap_id2) < 0)
+ FAIL_STACK_ERROR
+
+ /* Check for closing & re-opening the heap */
+ if(tparam->reopen_heap) {
+ /* Close (empty) heap */
+ if(H5HF_close(fh, dxpl) < 0)
+ TEST_ERROR
+
+ /* Re-open heap */
+ if(NULL == (fh = H5HF_open(f, dxpl, fh_addr)))
+ FAIL_STACK_ERROR
+ } /* end if */
+
+ /* Check up on heap... */
+ state.man_free_space -= sizeof(obj);
+ state.nobjs++;
+ if(check_stats(fh, &state))
+ FAIL_STACK_ERROR
+
+ /* Remove first object from heap */
+ if(H5HF_remove(fh, dxpl, heap_id1) < 0)
+ FAIL_STACK_ERROR
+
+ /* Check for closing & re-opening the heap */
+ if(tparam->reopen_heap) {
+ /* Close (empty) heap */
+ if(H5HF_close(fh, dxpl) < 0)
+ TEST_ERROR
+
+ /* Re-open heap */
+ if(NULL == (fh = H5HF_open(f, dxpl, fh_addr)))
+ FAIL_STACK_ERROR
+ } /* end if */
+
+ /* Check up on heap... */
+ state.man_free_space += sizeof(obj);
+ state.nobjs--;
+ if(check_stats(fh, &state))
+ FAIL_STACK_ERROR
+
+ /* Remove second object from heap */
+ if(H5HF_remove(fh, dxpl, heap_id2) < 0)
+ FAIL_STACK_ERROR
+
+ /* Check for closing & re-opening the heap */
+ if(tparam->reopen_heap) {
+ /* Close (empty) heap */
+ if(H5HF_close(fh, dxpl) < 0)
+ TEST_ERROR
+
+ /* Re-open heap */
+ if(NULL == (fh = H5HF_open(f, dxpl, fh_addr)))
+ FAIL_STACK_ERROR
+ } /* end if */
+
+ /* Check up on heap... */
+ state.heap_size = 0;
+ state.man_size = 0;
+ state.man_alloc_size = 0;
+ state.man_free_space = 0;
+ state.nobjs = 0;
+ if(check_stats(fh, &state))
+ FAIL_STACK_ERROR
+
+ /* Close the fractal heap */
+ if(H5HF_close(fh, dxpl) < 0)
+ TEST_ERROR
+
+ /* Close the file */
+ if(H5Fclose(file) < 0)
+ TEST_ERROR
+
+ /* Get the size of the file */
+ if((file_size = h5_get_file_size(filename)) == 0)
+ TEST_ERROR
+
+ /* Verify the file is correct size */
+ if(file_size != empty_size)
+ TEST_ERROR
+
+ PASSED()
+
+ /* All tests passed */
+ return(0);
+
+error:
+ H5E_BEGIN_TRY {
+ if(fh)
+ H5HF_close(fh, dxpl);
+ H5Fclose(file);
+ } H5E_END_TRY;
+ return(1);
+} /* test_abs_remove_two() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: test_abs_remove_one_larger
+ *
+ * Purpose: Test removing single larger (but < standalone size) object
+ * from heap
+ *
+ * Return: Success: 0
+ *
+ * Failure: 1
+ *
+ * Programmer: Quincey Koziol
+ * Tuesday, June 6, 2006
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+test_abs_remove_one_larger(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam)
+{
+ hid_t file = -1; /* File ID */
+ hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */
+ char filename[1024]; /* Filename to use */
+ H5F_t *f = NULL; /* Internal file object pointer */
+ H5HF_t *fh = NULL; /* Fractal heap wrapper */
+ haddr_t fh_addr; /* Address of fractal heap */
+ unsigned char heap_id[HEAP_ID_LEN]; /* Heap ID for object */
+ unsigned char *obj; /* Buffer for object to insert */
+ size_t obj_len; /* Length of object to insert */
+ size_t id_len; /* Size of fractal heap IDs */
+ off_t empty_size; /* Size of a file with an empty heap */
+ off_t file_size; /* Size of file currently */
+ fheap_heap_state_t state; /* State of fractal heap */
+ unsigned u; /* Local index variable */
+
+ /* Set the filename to use for this test (dependent on fapl) */
+ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename));
+
+ /* Create the file to work on */
+ if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
+ TEST_ERROR
+
+ /* Get a pointer to the internal file object */
+ if(NULL == (f = H5I_object(file)))
+ STACK_ERROR
+
+ /* Create absolute heap */
+ if(NULL == (fh = H5HF_create(f, dxpl, cparam)))
+ FAIL_STACK_ERROR
+ if(H5HF_get_id_len(fh, &id_len) < 0)
+ FAIL_STACK_ERROR
+ if(id_len > HEAP_ID_LEN)
+ FAIL_STACK_ERROR
+ if(H5HF_get_heap_addr(fh, &fh_addr) < 0)
+ FAIL_STACK_ERROR
+ if(!H5F_addr_defined(fh_addr))
+ FAIL_STACK_ERROR
+ HDmemset(&state, 0, sizeof(fheap_heap_state_t));
+ if(check_stats(fh, &state))
+ FAIL_STACK_ERROR
+
+ /* Prepare for querying the size of a file with an empty heap */
+
+ /* Close (empty) heap */
+ if(H5HF_close(fh, dxpl) < 0)
+ TEST_ERROR
+
+ /* Close file */
+ if(H5Fclose(file)<0) TEST_ERROR;
+
+ /* Get the size of a file w/empty heap*/
+ if((empty_size = h5_get_file_size(filename)) == 0)
+ TEST_ERROR
+
+ /* Re-open the file */
+ if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0)
+ TEST_ERROR
+
+ /* Get a pointer to the internal file object */
+ if(NULL == (f = H5I_object(file)))
+ STACK_ERROR
+
+ /* Re-open heap */
+ if(NULL == (fh = H5HF_open(f, dxpl, fh_addr)))
+ FAIL_STACK_ERROR
+
+ /*
+ * Test removing one larger object from absolute heap
+ */
+ TESTING("removing single larger object from absolute heap");
+
+ /* Set up object to insert */
+ obj_len = DBLOCK_SIZE(fh, 2) + 1;
+ obj = shared_wobj_g;
+
/* Insert object into heap */
- if(H5HF_insert(fh, dxpl, sizeof(obj), obj, &heap_id) < 0)
+ if(H5HF_insert(fh, dxpl, obj_len, obj, &heap_id) < 0)
FAIL_STACK_ERROR
/* Check for closing & re-opening the heap */
@@ -10594,9 +11124,15 @@ test_abs_remove_one(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tpara
} /* end if */
/* Check up on heap... */
- heap_size = DBLOCK_SIZE(fh, 0);
- free_space = DBLOCK_FREE(fh, 0) - sizeof(obj);
- if(check_stats(fh, heap_size, heap_size, (hsize_t)0, free_space, (hsize_t)1))
+ for(u = 0; u < 4; u++) {
+ state.heap_size += DBLOCK_SIZE(fh, u) * cparam->managed.width;
+ state.man_size += DBLOCK_SIZE(fh, u) * cparam->managed.width;
+ state.man_free_space += DBLOCK_FREE(fh, u) * cparam->managed.width;
+ } /* end for */
+ state.man_alloc_size = DBLOCK_SIZE(fh, 3);
+ state.man_free_space -= obj_len;
+ state.nobjs = 1;
+ if(check_stats(fh, &state))
FAIL_STACK_ERROR
/* Remove object from heap */
@@ -10615,11 +11151,283 @@ test_abs_remove_one(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tpara
} /* end if */
/* Check up on heap... */
- if(check_stats(fh, (hsize_t)0, (hsize_t)0, (hsize_t)0, (hsize_t)0, (hsize_t)0))
+ state.heap_size = 0;
+ state.man_size = 0;
+ state.man_alloc_size = 0;
+ state.man_free_space = 0;
+ state.nobjs = 0;
+ if(check_stats(fh, &state))
FAIL_STACK_ERROR
+ /* Close the fractal heap */
+ if(H5HF_close(fh, dxpl) < 0)
+ TEST_ERROR
+
+ /* Close the file */
+ if(H5Fclose(file) < 0)
+ TEST_ERROR
+
+ /* Get the size of the file */
+ if((file_size = h5_get_file_size(filename)) == 0)
+ TEST_ERROR
+
+ /* Verify the file is correct size */
+ if(file_size != empty_size)
+ TEST_ERROR
+
PASSED()
+ /* All tests passed */
+ return(0);
+
+error:
+ H5E_BEGIN_TRY {
+ if(fh)
+ H5HF_close(fh, dxpl);
+ H5Fclose(file);
+ } H5E_END_TRY;
+ return(1);
+} /* test_abs_remove_one_larger() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: test_abs_remove_two_larger
+ *
+ * Purpose: Test removing two larger (but < standalone size) objects
+ * from heap
+ *
+ * Return: Success: 0
+ *
+ * Failure: 1
+ *
+ * Programmer: Quincey Koziol
+ * Saturday, June 10, 2006
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+test_abs_remove_two_larger(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam)
+{
+ hid_t file = -1; /* File ID */
+ hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */
+ char filename[1024]; /* Filename to use */
+ H5F_t *f = NULL; /* Internal file object pointer */
+ H5HF_t *fh = NULL; /* Fractal heap wrapper */
+ haddr_t fh_addr; /* Address of fractal heap */
+ unsigned char heap_id1[HEAP_ID_LEN]; /* Heap ID for first object */
+ unsigned char heap_id2[HEAP_ID_LEN]; /* Heap ID for second object */
+ unsigned char *obj; /* Buffer for object to insert */
+ size_t obj_len; /* Length of object to insert */
+ size_t id_len; /* Size of fractal heap IDs */
+ off_t empty_size; /* Size of a file with an empty heap */
+ off_t file_size; /* Size of file currently */
+ fheap_heap_state_t state; /* State of fractal heap */
+ unsigned u; /* Local index variable */
+
+ /* Set the filename to use for this test (dependent on fapl) */
+ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename));
+
+ /* Create the file to work on */
+ if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
+ TEST_ERROR
+
+ /* Get a pointer to the internal file object */
+ if(NULL == (f = H5I_object(file)))
+ STACK_ERROR
+
+ /* Create absolute heap */
+ if(NULL == (fh = H5HF_create(f, dxpl, cparam)))
+ FAIL_STACK_ERROR
+ if(H5HF_get_id_len(fh, &id_len) < 0)
+ FAIL_STACK_ERROR
+ if(id_len > HEAP_ID_LEN)
+ FAIL_STACK_ERROR
+ if(H5HF_get_heap_addr(fh, &fh_addr) < 0)
+ FAIL_STACK_ERROR
+ if(!H5F_addr_defined(fh_addr))
+ FAIL_STACK_ERROR
+ HDmemset(&state, 0, sizeof(fheap_heap_state_t));
+ if(check_stats(fh, &state))
+ FAIL_STACK_ERROR
+
+ /* Prepare for querying the size of a file with an empty heap */
+
+ /* Close (empty) heap */
+ if(H5HF_close(fh, dxpl) < 0)
+ TEST_ERROR
+
+ /* Close file */
+ if(H5Fclose(file)<0) TEST_ERROR;
+
+ /* Get the size of a file w/empty heap*/
+ if((empty_size = h5_get_file_size(filename)) == 0)
+ TEST_ERROR
+
+ /* Re-open the file */
+ if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0)
+ TEST_ERROR
+
+ /* Get a pointer to the internal file object */
+ if(NULL == (f = H5I_object(file)))
+ STACK_ERROR
+
+ /* Re-open heap */
+ if(NULL == (fh = H5HF_open(f, dxpl, fh_addr)))
+ FAIL_STACK_ERROR
+
+ /*
+ * Test removing two larger objects from absolute heap
+ */
+ if(tparam->del_dir == HEAP_DEL_FORWARD)
+ TESTING("removing two larger objects from absolute heap (forward)")
+ else
+ TESTING("removing two larger objects from absolute heap (reverse)")
+
+ /* Set up first object to insert */
+ obj_len = DBLOCK_SIZE(fh, 2) + 1;
+ obj = shared_wobj_g;
+
+ /* Insert object into heap */
+ if(H5HF_insert(fh, dxpl, obj_len, obj, &heap_id1) < 0)
+ FAIL_STACK_ERROR
+
+ /* Check for closing & re-opening the heap */
+ if(tparam->reopen_heap) {
+ /* Close (empty) heap */
+ if(H5HF_close(fh, dxpl) < 0)
+ TEST_ERROR
+
+ /* Re-open heap */
+ if(NULL == (fh = H5HF_open(f, dxpl, fh_addr)))
+ FAIL_STACK_ERROR
+ } /* end if */
+
+ /* Check up on heap... */
+ for(u = 0; u < 4; u++) {
+ state.heap_size += DBLOCK_SIZE(fh, u) * cparam->managed.width;
+ state.man_size += DBLOCK_SIZE(fh, u) * cparam->managed.width;
+ state.man_free_space += DBLOCK_FREE(fh, u) * cparam->managed.width;
+ } /* end for */
+ state.man_alloc_size = DBLOCK_SIZE(fh, 3);
+ state.man_free_space -= obj_len;
+ state.nobjs = 1;
+ if(check_stats(fh, &state))
+ FAIL_STACK_ERROR
+
+ /* Set up second object to insert */
+ obj_len = DBLOCK_SIZE(fh, 4) + 1;
+ obj = shared_wobj_g;
+
+ /* Insert object into heap */
+ if(H5HF_insert(fh, dxpl, obj_len, obj, &heap_id2) < 0)
+ FAIL_STACK_ERROR
+
+ /* Check for closing & re-opening the heap */
+ if(tparam->reopen_heap) {
+ /* Close (empty) heap */
+ if(H5HF_close(fh, dxpl) < 0)
+ TEST_ERROR
+
+ /* Re-open heap */
+ if(NULL == (fh = H5HF_open(f, dxpl, fh_addr)))
+ FAIL_STACK_ERROR
+ } /* end if */
+
+ /* Check up on heap... */
+ /* (Goes to 8 rows because of doubling) */
+ for(u = 4; u < 8; u++) {
+ state.heap_size += DBLOCK_SIZE(fh, u) * cparam->managed.width;
+ state.man_size += DBLOCK_SIZE(fh, u) * cparam->managed.width;
+ state.man_free_space += DBLOCK_FREE(fh, u) * cparam->managed.width;
+ } /* end for */
+ state.man_alloc_size += DBLOCK_SIZE(fh, 5);
+ state.man_free_space -= obj_len;
+ state.nobjs = 2;
+ if(check_stats(fh, &state))
+ FAIL_STACK_ERROR
+
+ /* Remove objects in different orders */
+ if(tparam->del_dir == HEAP_DEL_FORWARD) {
+ /* Remove first object from heap */
+ if(H5HF_remove(fh, dxpl, heap_id1) < 0)
+ FAIL_STACK_ERROR
+
+ /* Check for closing & re-opening the heap */
+ if(tparam->reopen_heap) {
+ /* Close (empty) heap */
+ if(H5HF_close(fh, dxpl) < 0)
+ TEST_ERROR
+
+ /* Re-open heap */
+ if(NULL == (fh = H5HF_open(f, dxpl, fh_addr)))
+ FAIL_STACK_ERROR
+ } /* end if */
+
+ /* Check up on heap... */
+ state.man_alloc_size -= DBLOCK_SIZE(fh, 3);
+ state.man_free_space += DBLOCK_SIZE(fh, 2) + 1;
+ state.nobjs = 1;
+ if(check_stats(fh, &state))
+ FAIL_STACK_ERROR
+
+ /* Remove second object from heap */
+ if(H5HF_remove(fh, dxpl, heap_id2) < 0)
+ FAIL_STACK_ERROR
+ } /* end if */
+ else {
+ /* Remove second object from heap */
+ if(H5HF_remove(fh, dxpl, heap_id2) < 0)
+ FAIL_STACK_ERROR
+
+ /* Check for closing & re-opening the heap */
+ if(tparam->reopen_heap) {
+ /* Close (empty) heap */
+ if(H5HF_close(fh, dxpl) < 0)
+ TEST_ERROR
+
+ /* Re-open heap */
+ if(NULL == (fh = H5HF_open(f, dxpl, fh_addr)))
+ FAIL_STACK_ERROR
+ } /* end if */
+
+ /* Check up on heap... */
+ /* (Goes to 4 rows because of halving) */
+ for(u = 4; u < 8; u++) {
+ state.heap_size -= DBLOCK_SIZE(fh, u) * cparam->managed.width;
+ state.man_size -= DBLOCK_SIZE(fh, u) * cparam->managed.width;
+ state.man_free_space -= DBLOCK_FREE(fh, u) * cparam->managed.width;
+ } /* end for */
+ state.man_alloc_size -= DBLOCK_SIZE(fh, 5);
+ state.man_free_space += DBLOCK_SIZE(fh, 4) + 1;
+ state.nobjs = 1;
+ if(check_stats(fh, &state))
+ FAIL_STACK_ERROR
+
+ /* Remove first object from heap */
+ if(H5HF_remove(fh, dxpl, heap_id1) < 0)
+ FAIL_STACK_ERROR
+ } /* end else */
+
+ /* Check for closing & re-opening the heap */
+ if(tparam->reopen_heap) {
+ /* Close (empty) heap */
+ if(H5HF_close(fh, dxpl) < 0)
+ TEST_ERROR
+
+ /* Re-open heap */
+ if(NULL == (fh = H5HF_open(f, dxpl, fh_addr)))
+ FAIL_STACK_ERROR
+ } /* end if */
+
+ /* Check up on heap... */
+ state.heap_size = 0;
+ state.man_size = 0;
+ state.man_alloc_size = 0;
+ state.man_free_space = 0;
+ state.nobjs = 0;
+ if(check_stats(fh, &state))
+ FAIL_STACK_ERROR
+
/* Close the fractal heap */
if(H5HF_close(fh, dxpl) < 0)
TEST_ERROR
@@ -10628,6 +11436,20 @@ test_abs_remove_one(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tpara
if(H5Fclose(file) < 0)
TEST_ERROR
+ /* Get the size of the file */
+ if((file_size = h5_get_file_size(filename)) == 0)
+ TEST_ERROR
+
+ /* Verify the file is correct size */
+#ifdef QAK
+HDfprintf(stderr, "empty_size = %lu\n", (unsigned long)empty_size);
+HDfprintf(stderr, "file_size = %lu\n", (unsigned long)file_size);
+#endif /* QAK */
+ if(file_size != empty_size)
+ TEST_ERROR
+
+ PASSED()
+
/* All tests passed */
return(0);
@@ -10638,7 +11460,1590 @@ error:
H5Fclose(file);
} H5E_END_TRY;
return(1);
-} /* test_abs_remove_one() */
+} /* test_abs_remove_two_larger() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: test_abs_remove_three_larger
+ *
+ * Purpose: Test removing three larger (but < standalone size) objects
+ * from heap
+ *
+ * Return: Success: 0
+ *
+ * Failure: 1
+ *
+ * Programmer: Quincey Koziol
+ * Monday, June 12, 2006
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+test_abs_remove_three_larger(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam)
+{
+ hid_t file = -1; /* File ID */
+ hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */
+ char filename[1024]; /* Filename to use */
+ H5F_t *f = NULL; /* Internal file object pointer */
+ H5HF_t *fh = NULL; /* Fractal heap wrapper */
+ haddr_t fh_addr; /* Address of fractal heap */
+ unsigned char heap_id1[HEAP_ID_LEN]; /* Heap ID for first object */
+ unsigned char heap_id2[HEAP_ID_LEN]; /* Heap ID for second object */
+ unsigned char heap_id3[HEAP_ID_LEN]; /* Heap ID for third object */
+ unsigned char *obj; /* Buffer for object to insert */
+ size_t obj_len; /* Length of object to insert */
+ size_t id_len; /* Size of fractal heap IDs */
+ off_t empty_size; /* Size of a file with an empty heap */
+ off_t file_size; /* Size of file currently */
+ fheap_heap_state_t state; /* State of fractal heap */
+ unsigned u; /* Local index variable */
+
+ /* Set the filename to use for this test (dependent on fapl) */
+ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename));
+
+ /* Create the file to work on */
+ if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
+ TEST_ERROR
+
+ /* Get a pointer to the internal file object */
+ if(NULL == (f = H5I_object(file)))
+ STACK_ERROR
+
+ /* Create absolute heap */
+ if(NULL == (fh = H5HF_create(f, dxpl, cparam)))
+ FAIL_STACK_ERROR
+ if(H5HF_get_id_len(fh, &id_len) < 0)
+ FAIL_STACK_ERROR
+ if(id_len > HEAP_ID_LEN)
+ FAIL_STACK_ERROR
+ if(H5HF_get_heap_addr(fh, &fh_addr) < 0)
+ FAIL_STACK_ERROR
+ if(!H5F_addr_defined(fh_addr))
+ FAIL_STACK_ERROR
+ HDmemset(&state, 0, sizeof(fheap_heap_state_t));
+ if(check_stats(fh, &state))
+ FAIL_STACK_ERROR
+
+ /* Prepare for querying the size of a file with an empty heap */
+
+ /* Close (empty) heap */
+ if(H5HF_close(fh, dxpl) < 0)
+ TEST_ERROR
+
+ /* Close file */
+ if(H5Fclose(file)<0) TEST_ERROR;
+
+ /* Get the size of a file w/empty heap*/
+ if((empty_size = h5_get_file_size(filename)) == 0)
+ TEST_ERROR
+
+ /* Re-open the file */
+ if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0)
+ TEST_ERROR
+
+ /* Get a pointer to the internal file object */
+ if(NULL == (f = H5I_object(file)))
+ STACK_ERROR
+
+ /* Re-open heap */
+ if(NULL == (fh = H5HF_open(f, dxpl, fh_addr)))
+ FAIL_STACK_ERROR
+
+ /*
+ * Test removing three larger objects from absolute heap
+ */
+ if(tparam->del_dir == HEAP_DEL_FORWARD)
+ TESTING("removing three larger objects from absolute heap (forward)")
+ else
+ TESTING("removing three larger objects from absolute heap (reverse)")
+
+ /* Set up first object to insert */
+ obj_len = DBLOCK_SIZE(fh, 2) + 1;
+ obj = shared_wobj_g;
+
+ /* Insert object into heap */
+ if(H5HF_insert(fh, dxpl, obj_len, obj, &heap_id1) < 0)
+ FAIL_STACK_ERROR
+
+ /* Check for closing & re-opening the heap */
+ if(tparam->reopen_heap) {
+ /* Close (empty) heap */
+ if(H5HF_close(fh, dxpl) < 0)
+ TEST_ERROR
+
+ /* Re-open heap */
+ if(NULL == (fh = H5HF_open(f, dxpl, fh_addr)))
+ FAIL_STACK_ERROR
+ } /* end if */
+
+ /* Check up on heap... */
+ for(u = 0; u < 4; u++) {
+ state.heap_size += DBLOCK_SIZE(fh, u) * cparam->managed.width;
+ state.man_size += DBLOCK_SIZE(fh, u) * cparam->managed.width;
+ state.man_free_space += DBLOCK_FREE(fh, u) * cparam->managed.width;
+ } /* end for */
+ state.man_alloc_size = DBLOCK_SIZE(fh, 3);
+ state.man_free_space -= obj_len;
+ state.nobjs = 1;
+ if(check_stats(fh, &state))
+ FAIL_STACK_ERROR
+
+ /* Set up second object to insert */
+ obj_len = DBLOCK_SIZE(fh, 4) + 1;
+ obj = shared_wobj_g;
+
+ /* Insert object into heap */
+ if(H5HF_insert(fh, dxpl, obj_len, obj, &heap_id2) < 0)
+ FAIL_STACK_ERROR
+
+ /* Check for closing & re-opening the heap */
+ if(tparam->reopen_heap) {
+ /* Close (empty) heap */
+ if(H5HF_close(fh, dxpl) < 0)
+ TEST_ERROR
+
+ /* Re-open heap */
+ if(NULL == (fh = H5HF_open(f, dxpl, fh_addr)))
+ FAIL_STACK_ERROR
+ } /* end if */
+
+ /* Check up on heap... */
+ /* (Goes to 8 rows because of doubling) */
+ for(u = 4; u < 8; u++) {
+ state.heap_size += DBLOCK_SIZE(fh, u) * cparam->managed.width;
+ state.man_size += DBLOCK_SIZE(fh, u) * cparam->managed.width;
+ state.man_free_space += DBLOCK_FREE(fh, u) * cparam->managed.width;
+ } /* end for */
+ state.man_alloc_size += DBLOCK_SIZE(fh, 5);
+ state.man_free_space -= obj_len;
+ state.nobjs = 2;
+ if(check_stats(fh, &state))
+ FAIL_STACK_ERROR
+
+ /* Set up third object to insert */
+ obj_len = DBLOCK_SIZE(fh, 7) + 1;
+ obj = shared_wobj_g;
+
+ /* Insert object into heap */
+ if(H5HF_insert(fh, dxpl, obj_len, obj, &heap_id3) < 0)
+ FAIL_STACK_ERROR
+
+ /* Check for closing & re-opening the heap */
+ if(tparam->reopen_heap) {
+ /* Close (empty) heap */
+ if(H5HF_close(fh, dxpl) < 0)
+ TEST_ERROR
+
+ /* Re-open heap */
+ if(NULL == (fh = H5HF_open(f, dxpl, fh_addr)))
+ FAIL_STACK_ERROR
+ } /* end if */
+
+ /* Check up on heap... */
+ /* (Goes to 16 rows because of doubling) */
+ for(u = 8; u < 16; u++) {
+ state.heap_size += DBLOCK_SIZE(fh, u) * cparam->managed.width;
+ state.man_size += DBLOCK_SIZE(fh, u) * cparam->managed.width;
+ state.man_free_space += DBLOCK_FREE(fh, u) * cparam->managed.width;
+ } /* end for */
+ state.man_alloc_size += DBLOCK_SIZE(fh, 8);
+ state.man_free_space -= obj_len;
+ state.nobjs = 3;
+ if(check_stats(fh, &state))
+ FAIL_STACK_ERROR
+
+ /* Remove objects in different orders */
+ if(tparam->del_dir == HEAP_DEL_FORWARD) {
+ /* Remove first object from heap */
+ if(H5HF_remove(fh, dxpl, heap_id1) < 0)
+ FAIL_STACK_ERROR
+
+ /* Check for closing & re-opening the heap */
+ if(tparam->reopen_heap) {
+ /* Close (empty) heap */
+ if(H5HF_close(fh, dxpl) < 0)
+ TEST_ERROR
+
+ /* Re-open heap */
+ if(NULL == (fh = H5HF_open(f, dxpl, fh_addr)))
+ FAIL_STACK_ERROR
+ } /* end if */
+
+ /* Check up on heap... */
+ state.man_alloc_size -= DBLOCK_SIZE(fh, 3);
+ state.man_free_space += DBLOCK_SIZE(fh, 2) + 1;
+ state.nobjs = 2;
+ if(check_stats(fh, &state))
+ FAIL_STACK_ERROR
+
+ /* Remove second object from heap */
+ if(H5HF_remove(fh, dxpl, heap_id2) < 0)
+ FAIL_STACK_ERROR
+
+ /* Check for closing & re-opening the heap */
+ if(tparam->reopen_heap) {
+ /* Close (empty) heap */
+ if(H5HF_close(fh, dxpl) < 0)
+ TEST_ERROR
+
+ /* Re-open heap */
+ if(NULL == (fh = H5HF_open(f, dxpl, fh_addr)))
+ FAIL_STACK_ERROR
+ } /* end if */
+
+ /* Check up on heap... */
+ state.man_alloc_size -= DBLOCK_SIZE(fh, 5);
+ state.man_free_space += DBLOCK_SIZE(fh, 4) + 1;
+ state.nobjs = 1;
+ if(check_stats(fh, &state))
+ FAIL_STACK_ERROR
+
+ /* Remove third object from heap */
+ if(H5HF_remove(fh, dxpl, heap_id3) < 0)
+ FAIL_STACK_ERROR
+ } /* end if */
+ else {
+ /* Remove third object from heap */
+ if(H5HF_remove(fh, dxpl, heap_id3) < 0)
+ FAIL_STACK_ERROR
+
+ /* Check for closing & re-opening the heap */
+ if(tparam->reopen_heap) {
+ /* Close (empty) heap */
+ if(H5HF_close(fh, dxpl) < 0)
+ TEST_ERROR
+
+ /* Re-open heap */
+ if(NULL == (fh = H5HF_open(f, dxpl, fh_addr)))
+ FAIL_STACK_ERROR
+ } /* end if */
+
+ /* Check up on heap... */
+ /* (Goes to 8 rows because of halving) */
+ for(u = 8; u < 16; u++) {
+ state.heap_size -= DBLOCK_SIZE(fh, u) * cparam->managed.width;
+ state.man_size -= DBLOCK_SIZE(fh, u) * cparam->managed.width;
+ state.man_free_space -= DBLOCK_FREE(fh, u) * cparam->managed.width;
+ } /* end for */
+ state.man_alloc_size -= DBLOCK_SIZE(fh, 8);
+ state.man_free_space += DBLOCK_SIZE(fh, 7) + 1;
+ state.nobjs = 2;
+ if(check_stats(fh, &state))
+ FAIL_STACK_ERROR
+
+ /* Remove second object from heap */
+ if(H5HF_remove(fh, dxpl, heap_id2) < 0)
+ FAIL_STACK_ERROR
+
+ /* Check for closing & re-opening the heap */
+ if(tparam->reopen_heap) {
+ /* Close (empty) heap */
+ if(H5HF_close(fh, dxpl) < 0)
+ TEST_ERROR
+
+ /* Re-open heap */
+ if(NULL == (fh = H5HF_open(f, dxpl, fh_addr)))
+ FAIL_STACK_ERROR
+ } /* end if */
+
+ /* Check up on heap... */
+ /* (Goes to 4 rows because of halving) */
+ for(u = 4; u < 8; u++) {
+ state.heap_size -= DBLOCK_SIZE(fh, u) * cparam->managed.width;
+ state.man_size -= DBLOCK_SIZE(fh, u) * cparam->managed.width;
+ state.man_free_space -= DBLOCK_FREE(fh, u) * cparam->managed.width;
+ } /* end for */
+ state.man_alloc_size -= DBLOCK_SIZE(fh, 5);
+ state.man_free_space += DBLOCK_SIZE(fh, 4) + 1;
+ state.nobjs = 1;
+ if(check_stats(fh, &state))
+ FAIL_STACK_ERROR
+
+ /* Remove first object from heap */
+ if(H5HF_remove(fh, dxpl, heap_id1) < 0)
+ FAIL_STACK_ERROR
+ } /* end else */
+
+ /* Check for closing & re-opening the heap */
+ if(tparam->reopen_heap) {
+ /* Close (empty) heap */
+ if(H5HF_close(fh, dxpl) < 0)
+ TEST_ERROR
+
+ /* Re-open heap */
+ if(NULL == (fh = H5HF_open(f, dxpl, fh_addr)))
+ FAIL_STACK_ERROR
+ } /* end if */
+
+ /* Check up on heap... */
+ state.heap_size = 0;
+ state.man_size = 0;
+ state.man_alloc_size = 0;
+ state.man_free_space = 0;
+ state.nobjs = 0;
+ if(check_stats(fh, &state))
+ FAIL_STACK_ERROR
+
+ /* Close the fractal heap */
+ if(H5HF_close(fh, dxpl) < 0)
+ TEST_ERROR
+
+ /* Close the file */
+ if(H5Fclose(file) < 0)
+ TEST_ERROR
+
+ /* Get the size of the file */
+ if((file_size = h5_get_file_size(filename)) == 0)
+ TEST_ERROR
+
+ /* Verify the file is correct size */
+#ifdef QAK
+HDfprintf(stderr, "empty_size = %lu\n", (unsigned long)empty_size);
+HDfprintf(stderr, "file_size = %lu\n", (unsigned long)file_size);
+#endif /* QAK */
+ if(file_size != empty_size)
+ TEST_ERROR
+
+ PASSED()
+
+ /* All tests passed */
+ return(0);
+
+error:
+ H5E_BEGIN_TRY {
+ if(fh)
+ H5HF_close(fh, dxpl);
+ H5Fclose(file);
+ } H5E_END_TRY;
+ return(1);
+} /* test_abs_remove_three_larger() */
+#endif /* QAK */
+
+#ifndef QAK
+#ifndef QAK2
+
+/*-------------------------------------------------------------------------
+ * Function: test_abs_remove_root_direct
+ *
+ * Purpose: Test filling and removing all objects from root direct block in
+ * heap
+ *
+ * Return: Success: 0
+ *
+ * Failure: 1
+ *
+ * Programmer: Quincey Koziol
+ * Monday, May 22, 2006
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+test_abs_remove_root_direct(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam)
+{
+ hid_t file = -1; /* File ID */
+ hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */
+ char filename[1024]; /* Filename to use */
+ H5F_t *f = NULL; /* Internal file object pointer */
+ H5HF_t *fh = NULL; /* Fractal heap wrapper */
+ haddr_t fh_addr; /* Address of fractal heap */
+ fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */
+ size_t id_len; /* Size of fractal heap IDs */
+ off_t empty_size; /* Size of a file with an empty heap */
+ off_t file_size; /* Size of file currently */
+ fheap_heap_state_t state; /* State of fractal heap */
+ const char *base_desc = "removing all objects from root direct block of absolute heap %s"; /* Test description */
+ char *del_str = NULL; /* Deletion order description */
+ char *test_desc = NULL; /* Test description */
+
+ /* Set the filename to use for this test (dependent on fapl) */
+ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename));
+
+ /* Create the file to work on */
+ if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
+ TEST_ERROR
+
+ /* Get a pointer to the internal file object */
+ if(NULL == (f = H5I_object(file)))
+ STACK_ERROR
+
+ /* Create absolute heap */
+ if(NULL == (fh = H5HF_create(f, dxpl, cparam)))
+ FAIL_STACK_ERROR
+ if(H5HF_get_id_len(fh, &id_len) < 0)
+ FAIL_STACK_ERROR
+ if(id_len > HEAP_ID_LEN)
+ FAIL_STACK_ERROR
+ if(H5HF_get_heap_addr(fh, &fh_addr) < 0)
+ FAIL_STACK_ERROR
+ if(!H5F_addr_defined(fh_addr))
+ FAIL_STACK_ERROR
+ HDmemset(&state, 0, sizeof(fheap_heap_state_t));
+ if(check_stats(fh, &state))
+ FAIL_STACK_ERROR
+
+ /* Prepare for querying the size of a file with an empty heap */
+
+ /* Close (empty) heap */
+ if(H5HF_close(fh, dxpl) < 0)
+ TEST_ERROR
+
+ /* Close file */
+ if(H5Fclose(file)<0) TEST_ERROR;
+
+ /* Get the size of a file w/empty heap*/
+ if((empty_size = h5_get_file_size(filename)) == 0)
+ TEST_ERROR
+
+ /* Re-open the file */
+ if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0)
+ TEST_ERROR
+
+ /* Get a pointer to the internal file object */
+ if(NULL == (f = H5I_object(file)))
+ STACK_ERROR
+
+ /* Re-open heap */
+ if(NULL == (fh = H5HF_open(f, dxpl, fh_addr)))
+ FAIL_STACK_ERROR
+
+ /*
+ * Test filling & removing all (small) objects from root direct block of absolute heap
+ */
+ del_str = get_del_string(tparam);
+ HDassert(del_str);
+ test_desc = H5MM_malloc(HDstrlen(del_str) + HDstrlen(base_desc));
+ sprintf(test_desc, base_desc, del_str);
+ TESTING(test_desc);
+ H5MM_xfree(del_str);
+ H5MM_xfree(test_desc);
+
+ /* Initialize the heap ID structure */
+ HDmemset(&keep_ids, 0, sizeof(fheap_heap_ids_t));
+
+ /* Fill the heap up */
+ state.heap_size = DBLOCK_SIZE(fh, 0);
+ state.man_size = DBLOCK_SIZE(fh, 0);
+ state.man_alloc_size = DBLOCK_SIZE(fh, 0);
+ state.man_free_space = DBLOCK_FREE(fh, 0);
+ if(fill_heap(fh, dxpl, 0, SMALL_OBJ_SIZE1, &state, &keep_ids))
+ FAIL_STACK_ERROR
+
+ /* Check for closing & re-opening the heap */
+ if(tparam->reopen_heap) {
+ /* Close heap */
+ if(H5HF_close(fh, dxpl) < 0)
+ TEST_ERROR
+
+ /* Re-open heap */
+ if(NULL == (fh = H5HF_open(f, dxpl, fh_addr)))
+ FAIL_STACK_ERROR
+ } /* end if */
+
+ /* Check up on heap... */
+ if(check_stats(fh, &state))
+ FAIL_STACK_ERROR
+
+ /* Delete objects inserted (either forward or reverse order) */
+ if(del_objs(f, dxpl, &fh, tparam, &state, &keep_ids))
+ FAIL_STACK_ERROR
+
+ /* Close the fractal heap */
+ if(H5HF_close(fh, dxpl) < 0)
+ TEST_ERROR
+
+ /* Close the file */
+ if(H5Fclose(file) < 0)
+ TEST_ERROR
+
+ /* Get the size of the file */
+ if((file_size = h5_get_file_size(filename)) == 0)
+ TEST_ERROR
+
+ /* Verify the file is correct size */
+ if(file_size != empty_size)
+ TEST_ERROR
+
+ /* Free resources */
+ H5MM_xfree(keep_ids.ids);
+ H5MM_xfree(keep_ids.lens);
+ H5MM_xfree(keep_ids.offs);
+
+ PASSED()
+
+ /* All tests passed */
+ return(0);
+
+error:
+ H5E_BEGIN_TRY {
+ H5MM_xfree(keep_ids.ids);
+ H5MM_xfree(keep_ids.lens);
+ H5MM_xfree(keep_ids.offs);
+ H5MM_xfree(del_str);
+ H5MM_xfree(test_desc);
+ if(fh)
+ H5HF_close(fh, dxpl);
+ H5Fclose(file);
+ } H5E_END_TRY;
+ return(1);
+} /* test_abs_remove_root_direct() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: test_abs_remove_two_direct
+ *
+ * Purpose: Test filling and removing all objects from (first) two direct
+ * blocks in heap
+ *
+ * Return: Success: 0
+ *
+ * Failure: 1
+ *
+ * Programmer: Quincey Koziol
+ * Monday, May 22, 2006
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+test_abs_remove_two_direct(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam)
+{
+ hid_t file = -1; /* File ID */
+ hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */
+ char filename[1024]; /* Filename to use */
+ H5F_t *f = NULL; /* Internal file object pointer */
+ H5HF_t *fh = NULL; /* Fractal heap wrapper */
+ haddr_t fh_addr; /* Address of fractal heap */
+ fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */
+ size_t id_len; /* Size of fractal heap IDs */
+ off_t empty_size; /* Size of a file with an empty heap */
+ off_t file_size; /* Size of file currently */
+ fheap_heap_state_t state; /* State of fractal heap */
+ const char *base_desc = "removing all objects from two direct blocks of absolute heap %s"; /* Test description */
+ char *del_str = NULL; /* Deletion order description */
+ char *test_desc = NULL; /* Test description */
+
+ /* Set the filename to use for this test (dependent on fapl) */
+ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename));
+
+ /* Create the file to work on */
+ if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
+ TEST_ERROR
+
+ /* Get a pointer to the internal file object */
+ if(NULL == (f = H5I_object(file)))
+ STACK_ERROR
+
+ /* Create absolute heap */
+ if(NULL == (fh = H5HF_create(f, dxpl, cparam)))
+ FAIL_STACK_ERROR
+ if(H5HF_get_id_len(fh, &id_len) < 0)
+ FAIL_STACK_ERROR
+ if(id_len > HEAP_ID_LEN)
+ FAIL_STACK_ERROR
+ if(H5HF_get_heap_addr(fh, &fh_addr) < 0)
+ FAIL_STACK_ERROR
+ if(!H5F_addr_defined(fh_addr))
+ FAIL_STACK_ERROR
+ HDmemset(&state, 0, sizeof(fheap_heap_state_t));
+ if(check_stats(fh, &state))
+ FAIL_STACK_ERROR
+
+ /* Prepare for querying the size of a file with an empty heap */
+
+ /* Close (empty) heap */
+ if(H5HF_close(fh, dxpl) < 0)
+ TEST_ERROR
+
+ /* Close file */
+ if(H5Fclose(file)<0) TEST_ERROR;
+
+ /* Get the size of a file w/empty heap*/
+ if((empty_size = h5_get_file_size(filename)) == 0)
+ TEST_ERROR
+#ifdef QAK
+HDfprintf(stderr, "empty_size = %lu\n", (unsigned long)empty_size);
+#endif /* QAK */
+
+ /* Re-open the file */
+ if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0)
+ TEST_ERROR
+
+ /* Get a pointer to the internal file object */
+ if(NULL == (f = H5I_object(file)))
+ STACK_ERROR
+
+ /* Re-open heap */
+ if(NULL == (fh = H5HF_open(f, dxpl, fh_addr)))
+ FAIL_STACK_ERROR
+
+ /*
+ * Test filling & removing all (small) objects from two direct blocks of absolute heap
+ */
+ del_str = get_del_string(tparam);
+ HDassert(del_str);
+ test_desc = H5MM_malloc(HDstrlen(del_str) + HDstrlen(base_desc));
+ sprintf(test_desc, base_desc, del_str);
+ TESTING(test_desc);
+ H5MM_xfree(del_str);
+ H5MM_xfree(test_desc);
+
+ /* Initialize the heap ID structure */
+ HDmemset(&keep_ids, 0, sizeof(fheap_heap_ids_t));
+
+ /* Fill the first block in heap */
+ state.heap_size = DBLOCK_SIZE(fh, 0);
+ state.man_size = DBLOCK_SIZE(fh, 0);
+ state.man_alloc_size = DBLOCK_SIZE(fh, 0);
+ state.man_free_space = DBLOCK_FREE(fh, 0);
+ if(fill_heap(fh, dxpl, 0, SMALL_OBJ_SIZE1, &state, &keep_ids))
+ FAIL_STACK_ERROR
+
+ /* Check for closing & re-opening the heap */
+ if(tparam->reopen_heap) {
+ /* Close heap */
+ if(H5HF_close(fh, dxpl) < 0)
+ TEST_ERROR
+
+ /* Re-open heap */
+ if(NULL == (fh = H5HF_open(f, dxpl, fh_addr)))
+ FAIL_STACK_ERROR
+ } /* end if */
+
+ /* Check up on heap... */
+ if(check_stats(fh, &state))
+ FAIL_STACK_ERROR
+
+ /* Fill the second block in heap */
+ state.heap_size = cparam->managed.width * DBLOCK_SIZE(fh, 0);
+ state.man_size = cparam->managed.width * DBLOCK_SIZE(fh, 0);
+ state.man_alloc_size += DBLOCK_SIZE(fh, 0);
+ state.man_free_space = (cparam->managed.width - 1) * DBLOCK_FREE(fh, 0);
+ if(fill_heap(fh, dxpl, 0, SMALL_OBJ_SIZE1, &state, &keep_ids))
+ FAIL_STACK_ERROR
+
+ /* Check for closing & re-opening the heap */
+ if(tparam->reopen_heap) {
+ /* Close heap */
+ if(H5HF_close(fh, dxpl) < 0)
+ TEST_ERROR
+
+ /* Re-open heap */
+ if(NULL == (fh = H5HF_open(f, dxpl, fh_addr)))
+ FAIL_STACK_ERROR
+ } /* end if */
+
+ /* Check up on heap... */
+ if(check_stats(fh, &state))
+ FAIL_STACK_ERROR
+
+ /* Delete objects inserted (either forward or reverse order) */
+ if(del_objs(f, dxpl, &fh, tparam, &state, &keep_ids))
+ FAIL_STACK_ERROR
+
+ /* Close the fractal heap */
+ if(H5HF_close(fh, dxpl) < 0)
+ TEST_ERROR
+ fh = NULL;
+
+ /* Close the file */
+ if(H5Fclose(file) < 0)
+ TEST_ERROR
+
+ /* Get the size of the file */
+ if((file_size = h5_get_file_size(filename)) == 0)
+ TEST_ERROR
+#ifdef QAK
+HDfprintf(stderr, "file_size = %lu\n", (unsigned long)file_size);
+#endif /* QAK */
+
+ /* Verify the file is correct size */
+ if(file_size != empty_size)
+ TEST_ERROR
+
+ /* Free resources */
+ H5MM_xfree(keep_ids.ids);
+ H5MM_xfree(keep_ids.lens);
+ H5MM_xfree(keep_ids.offs);
+
+ PASSED()
+
+ /* All tests passed */
+ return(0);
+
+error:
+ H5E_BEGIN_TRY {
+ H5MM_xfree(keep_ids.ids);
+ H5MM_xfree(keep_ids.lens);
+ H5MM_xfree(keep_ids.offs);
+ H5MM_xfree(del_str);
+ H5MM_xfree(test_desc);
+ if(fh)
+ H5HF_close(fh, dxpl);
+ H5Fclose(file);
+ } H5E_END_TRY;
+ return(1);
+} /* test_abs_remove_two_direct() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: test_abs_remove_first_row
+ *
+ * Purpose: Test filling and removing all objects from first row of direct
+ * blocks in heap
+ *
+ * Return: Success: 0
+ *
+ * Failure: 1
+ *
+ * Programmer: Quincey Koziol
+ * Monday, June 5, 2006
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+test_abs_remove_first_row(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam)
+{
+ hid_t file = -1; /* File ID */
+ hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */
+ char filename[1024]; /* Filename to use */
+ H5F_t *f = NULL; /* Internal file object pointer */
+ H5HF_t *fh = NULL; /* Fractal heap wrapper */
+ haddr_t fh_addr; /* Address of fractal heap */
+ fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */
+ size_t id_len; /* Size of fractal heap IDs */
+ off_t empty_size; /* Size of a file with an empty heap */
+ off_t file_size; /* Size of file currently */
+ fheap_heap_state_t state; /* State of fractal heap */
+ const char *base_desc = "removing all objects from first row of direct blocks of absolute heap %s"; /* Test description */
+ char *del_str = NULL; /* Deletion order description */
+ char *test_desc = NULL; /* Test description */
+
+ /* Set the filename to use for this test (dependent on fapl) */
+ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename));
+
+ /* Create the file to work on */
+ if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
+ TEST_ERROR
+
+ /* Get a pointer to the internal file object */
+ if(NULL == (f = H5I_object(file)))
+ STACK_ERROR
+
+ /* Create absolute heap */
+ if(NULL == (fh = H5HF_create(f, dxpl, cparam)))
+ FAIL_STACK_ERROR
+ if(H5HF_get_id_len(fh, &id_len) < 0)
+ FAIL_STACK_ERROR
+ if(id_len > HEAP_ID_LEN)
+ FAIL_STACK_ERROR
+ if(H5HF_get_heap_addr(fh, &fh_addr) < 0)
+ FAIL_STACK_ERROR
+ if(!H5F_addr_defined(fh_addr))
+ FAIL_STACK_ERROR
+ HDmemset(&state, 0, sizeof(fheap_heap_state_t));
+ if(check_stats(fh, &state))
+ FAIL_STACK_ERROR
+
+ /* Prepare for querying the size of a file with an empty heap */
+
+ /* Close (empty) heap */
+ if(H5HF_close(fh, dxpl) < 0)
+ TEST_ERROR
+
+ /* Close file */
+ if(H5Fclose(file)<0) TEST_ERROR;
+
+ /* Get the size of a file w/empty heap*/
+ if((empty_size = h5_get_file_size(filename)) == 0)
+ TEST_ERROR
+#ifdef QAK
+HDfprintf(stderr, "empty_size = %lu\n", (unsigned long)empty_size);
+#endif /* QAK */
+
+ /* Re-open the file */
+ if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0)
+ TEST_ERROR
+
+ /* Get a pointer to the internal file object */
+ if(NULL == (f = H5I_object(file)))
+ STACK_ERROR
+
+ /* Re-open heap */
+ if(NULL == (fh = H5HF_open(f, dxpl, fh_addr)))
+ FAIL_STACK_ERROR
+
+ /*
+ * Test filling & removing all (small) objects from first row of direct blocks of absolute heap
+ */
+ del_str = get_del_string(tparam);
+ HDassert(del_str);
+ test_desc = H5MM_malloc(HDstrlen(del_str) + HDstrlen(base_desc));
+ sprintf(test_desc, base_desc, del_str);
+ TESTING(test_desc);
+ H5MM_xfree(del_str);
+ H5MM_xfree(test_desc);
+
+ /* Initialize the heap ID structure */
+ HDmemset(&keep_ids, 0, sizeof(fheap_heap_ids_t));
+
+ /* Fill first row of direct blocks */
+ if(fill_root_row(fh, dxpl, 0, SMALL_OBJ_SIZE1, &state, &keep_ids))
+ FAIL_STACK_ERROR
+
+
+ /* Check for closing & re-opening the heap */
+ if(tparam->reopen_heap) {
+ /* Close heap */
+ if(H5HF_close(fh, dxpl) < 0)
+ TEST_ERROR
+
+ /* Re-open heap */
+ if(NULL == (fh = H5HF_open(f, dxpl, fh_addr)))
+ FAIL_STACK_ERROR
+ } /* end if */
+
+ /* Check up on heap... */
+ if(check_stats(fh, &state))
+ FAIL_STACK_ERROR
+
+ /* Delete objects inserted (either forward or reverse order) */
+ if(del_objs(f, dxpl, &fh, tparam, &state, &keep_ids))
+ FAIL_STACK_ERROR
+
+ /* Close the fractal heap */
+ if(H5HF_close(fh, dxpl) < 0)
+ TEST_ERROR
+ fh = NULL;
+
+ /* Close the file */
+ if(H5Fclose(file) < 0)
+ TEST_ERROR
+
+ /* Get the size of the file */
+ if((file_size = h5_get_file_size(filename)) == 0)
+ TEST_ERROR
+#ifdef QAK
+HDfprintf(stderr, "file_size = %lu\n", (unsigned long)file_size);
+#endif /* QAK */
+
+ /* Verify the file is correct size */
+ if(file_size != empty_size)
+ TEST_ERROR
+
+ /* Free resources */
+ H5MM_xfree(keep_ids.ids);
+ H5MM_xfree(keep_ids.lens);
+ H5MM_xfree(keep_ids.offs);
+
+ PASSED()
+
+ /* All tests passed */
+ return(0);
+
+error:
+ H5E_BEGIN_TRY {
+ H5MM_xfree(keep_ids.ids);
+ H5MM_xfree(keep_ids.lens);
+ H5MM_xfree(keep_ids.offs);
+ H5MM_xfree(del_str);
+ H5MM_xfree(test_desc);
+ if(fh)
+ H5HF_close(fh, dxpl);
+ H5Fclose(file);
+ } H5E_END_TRY;
+ return(1);
+} /* test_abs_remove_first_row() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: test_abs_remove_first_two_rows
+ *
+ * Purpose: Test filling and removing all objects from first two rows of
+ * direct blocks in heap
+ *
+ * Return: Success: 0
+ *
+ * Failure: 1
+ *
+ * Programmer: Quincey Koziol
+ * Monday, June 12, 2006
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+test_abs_remove_first_two_rows(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam)
+{
+ hid_t file = -1; /* File ID */
+ hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */
+ char filename[1024]; /* Filename to use */
+ H5F_t *f = NULL; /* Internal file object pointer */
+ H5HF_t *fh = NULL; /* Fractal heap wrapper */
+ haddr_t fh_addr; /* Address of fractal heap */
+ fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */
+ size_t id_len; /* Size of fractal heap IDs */
+ off_t empty_size; /* Size of a file with an empty heap */
+ off_t file_size; /* Size of file currently */
+ fheap_heap_state_t state; /* State of fractal heap */
+ const char *base_desc = "removing all objects from first two rows of direct blocks of absolute heap %s"; /* Test description */
+ char *del_str = NULL; /* Deletion order description */
+ char *test_desc = NULL; /* Test description */
+
+ /* Set the filename to use for this test (dependent on fapl) */
+ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename));
+
+ /* Create the file to work on */
+ if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
+ TEST_ERROR
+
+ /* Get a pointer to the internal file object */
+ if(NULL == (f = H5I_object(file)))
+ STACK_ERROR
+
+ /* Create absolute heap */
+ if(NULL == (fh = H5HF_create(f, dxpl, cparam)))
+ FAIL_STACK_ERROR
+ if(H5HF_get_id_len(fh, &id_len) < 0)
+ FAIL_STACK_ERROR
+ if(id_len > HEAP_ID_LEN)
+ FAIL_STACK_ERROR
+ if(H5HF_get_heap_addr(fh, &fh_addr) < 0)
+ FAIL_STACK_ERROR
+ if(!H5F_addr_defined(fh_addr))
+ FAIL_STACK_ERROR
+ HDmemset(&state, 0, sizeof(fheap_heap_state_t));
+ if(check_stats(fh, &state))
+ FAIL_STACK_ERROR
+
+ /* Prepare for querying the size of a file with an empty heap */
+
+ /* Close (empty) heap */
+ if(H5HF_close(fh, dxpl) < 0)
+ TEST_ERROR
+
+ /* Close file */
+ if(H5Fclose(file)<0) TEST_ERROR;
+
+ /* Get the size of a file w/empty heap*/
+ if((empty_size = h5_get_file_size(filename)) == 0)
+ TEST_ERROR
+#ifdef QAK
+HDfprintf(stderr, "empty_size = %lu\n", (unsigned long)empty_size);
+#endif /* QAK */
+
+ /* Re-open the file */
+ if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0)
+ TEST_ERROR
+
+ /* Get a pointer to the internal file object */
+ if(NULL == (f = H5I_object(file)))
+ STACK_ERROR
+
+ /* Re-open heap */
+ if(NULL == (fh = H5HF_open(f, dxpl, fh_addr)))
+ FAIL_STACK_ERROR
+
+ /*
+ * Test filling & removing all (small) objects from first row of direct blocks of absolute heap
+ */
+ del_str = get_del_string(tparam);
+ HDassert(del_str);
+ test_desc = H5MM_malloc(HDstrlen(del_str) + HDstrlen(base_desc));
+ sprintf(test_desc, base_desc, del_str);
+ TESTING(test_desc);
+ H5MM_xfree(del_str);
+ H5MM_xfree(test_desc);
+
+ /* Initialize the heap ID structure */
+ HDmemset(&keep_ids, 0, sizeof(fheap_heap_ids_t));
+
+ /* Fill first two rows of direct blocks */
+ if(fill_root_row(fh, dxpl, 0, SMALL_OBJ_SIZE1, &state, &keep_ids))
+ FAIL_STACK_ERROR
+ if(fill_root_row(fh, dxpl, 1, SMALL_OBJ_SIZE1, &state, &keep_ids))
+ FAIL_STACK_ERROR
+
+ /* Check for closing & re-opening the heap */
+ if(tparam->reopen_heap) {
+ /* Close heap */
+ if(H5HF_close(fh, dxpl) < 0)
+ TEST_ERROR
+
+ /* Re-open heap */
+ if(NULL == (fh = H5HF_open(f, dxpl, fh_addr)))
+ FAIL_STACK_ERROR
+ } /* end if */
+
+ /* Check up on heap... */
+ if(check_stats(fh, &state))
+ FAIL_STACK_ERROR
+
+ /* Delete objects inserted (either forward or reverse order) */
+ if(del_objs(f, dxpl, &fh, tparam, &state, &keep_ids))
+ FAIL_STACK_ERROR
+
+ /* Close the fractal heap */
+ if(H5HF_close(fh, dxpl) < 0)
+ TEST_ERROR
+ fh = NULL;
+
+ /* Close the file */
+ if(H5Fclose(file) < 0)
+ TEST_ERROR
+
+ /* Get the size of the file */
+ if((file_size = h5_get_file_size(filename)) == 0)
+ TEST_ERROR
+#ifdef QAK
+HDfprintf(stderr, "file_size = %lu\n", (unsigned long)file_size);
+#endif /* QAK */
+
+ /* Verify the file is correct size */
+ if(file_size != empty_size)
+ TEST_ERROR
+
+ /* Free resources */
+ H5MM_xfree(keep_ids.ids);
+ H5MM_xfree(keep_ids.lens);
+ H5MM_xfree(keep_ids.offs);
+
+ PASSED()
+
+ /* All tests passed */
+ return(0);
+
+error:
+ H5E_BEGIN_TRY {
+ H5MM_xfree(keep_ids.ids);
+ H5MM_xfree(keep_ids.lens);
+ H5MM_xfree(keep_ids.offs);
+ H5MM_xfree(del_str);
+ H5MM_xfree(test_desc);
+ if(fh)
+ H5HF_close(fh, dxpl);
+ H5Fclose(file);
+ } H5E_END_TRY;
+ return(1);
+} /* test_abs_remove_first_two_rows() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: test_abs_remove_first_four_rows
+ *
+ * Purpose: Test filling and removing all objects from first four rows of
+ * direct blocks in heap
+ *
+ * Return: Success: 0
+ *
+ * Failure: 1
+ *
+ * Programmer: Quincey Koziol
+ * Tuesday, June 13, 2006
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+test_abs_remove_first_four_rows(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam)
+{
+ hid_t file = -1; /* File ID */
+ hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */
+ char filename[1024]; /* Filename to use */
+ H5F_t *f = NULL; /* Internal file object pointer */
+ H5HF_t *fh = NULL; /* Fractal heap wrapper */
+ haddr_t fh_addr; /* Address of fractal heap */
+ fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */
+ size_t id_len; /* Size of fractal heap IDs */
+ off_t empty_size; /* Size of a file with an empty heap */
+ off_t file_size; /* Size of file currently */
+ fheap_heap_state_t state; /* State of fractal heap */
+ const char *base_desc = "removing all objects from first four rows of direct blocks of absolute heap %s"; /* Test description */
+ char *del_str = NULL; /* Deletion order description */
+ char *test_desc = NULL; /* Test description */
+
+ /* Set the filename to use for this test (dependent on fapl) */
+ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename));
+
+ /* Create the file to work on */
+ if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
+ TEST_ERROR
+
+ /* Get a pointer to the internal file object */
+ if(NULL == (f = H5I_object(file)))
+ STACK_ERROR
+
+ /* Create absolute heap */
+ if(NULL == (fh = H5HF_create(f, dxpl, cparam)))
+ FAIL_STACK_ERROR
+ if(H5HF_get_id_len(fh, &id_len) < 0)
+ FAIL_STACK_ERROR
+ if(id_len > HEAP_ID_LEN)
+ FAIL_STACK_ERROR
+ if(H5HF_get_heap_addr(fh, &fh_addr) < 0)
+ FAIL_STACK_ERROR
+ if(!H5F_addr_defined(fh_addr))
+ FAIL_STACK_ERROR
+ HDmemset(&state, 0, sizeof(fheap_heap_state_t));
+ if(check_stats(fh, &state))
+ FAIL_STACK_ERROR
+
+ /* Prepare for querying the size of a file with an empty heap */
+
+ /* Close (empty) heap */
+ if(H5HF_close(fh, dxpl) < 0)
+ TEST_ERROR
+
+ /* Close file */
+ if(H5Fclose(file)<0) TEST_ERROR;
+
+ /* Get the size of a file w/empty heap*/
+ if((empty_size = h5_get_file_size(filename)) == 0)
+ TEST_ERROR
+#ifdef QAK
+HDfprintf(stderr, "empty_size = %lu\n", (unsigned long)empty_size);
+#endif /* QAK */
+
+ /* Re-open the file */
+ if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0)
+ TEST_ERROR
+
+ /* Get a pointer to the internal file object */
+ if(NULL == (f = H5I_object(file)))
+ STACK_ERROR
+
+ /* Re-open heap */
+ if(NULL == (fh = H5HF_open(f, dxpl, fh_addr)))
+ FAIL_STACK_ERROR
+
+ /*
+ * Test filling & removing all (small) objects from first row of direct blocks of absolute heap
+ */
+ del_str = get_del_string(tparam);
+ HDassert(del_str);
+ test_desc = H5MM_malloc(HDstrlen(del_str) + HDstrlen(base_desc));
+ sprintf(test_desc, base_desc, del_str);
+ TESTING(test_desc);
+ H5MM_xfree(del_str);
+ H5MM_xfree(test_desc);
+
+ /* Initialize the heap ID structure */
+ HDmemset(&keep_ids, 0, sizeof(fheap_heap_ids_t));
+
+ /* Fill first two rows of direct blocks */
+ if(fill_root_row(fh, dxpl, 0, SMALL_OBJ_SIZE1, &state, &keep_ids))
+ FAIL_STACK_ERROR
+ if(fill_root_row(fh, dxpl, 1, SMALL_OBJ_SIZE1, &state, &keep_ids))
+ FAIL_STACK_ERROR
+ if(fill_root_row(fh, dxpl, 2, SMALL_OBJ_SIZE1, &state, &keep_ids))
+ FAIL_STACK_ERROR
+ if(fill_root_row(fh, dxpl, 3, SMALL_OBJ_SIZE1, &state, &keep_ids))
+ FAIL_STACK_ERROR
+
+ /* Check for closing & re-opening the heap */
+ if(tparam->reopen_heap) {
+ /* Close heap */
+ if(H5HF_close(fh, dxpl) < 0)
+ TEST_ERROR
+
+ /* Re-open heap */
+ if(NULL == (fh = H5HF_open(f, dxpl, fh_addr)))
+ FAIL_STACK_ERROR
+ } /* end if */
+
+ /* Check up on heap... */
+ if(check_stats(fh, &state))
+ FAIL_STACK_ERROR
+
+ /* Delete objects inserted (either forward or reverse order) */
+ if(del_objs(f, dxpl, &fh, tparam, &state, &keep_ids))
+ FAIL_STACK_ERROR
+
+ /* Close the fractal heap */
+ if(H5HF_close(fh, dxpl) < 0)
+ TEST_ERROR
+ fh = NULL;
+
+ /* Close the file */
+ if(H5Fclose(file) < 0)
+ TEST_ERROR
+
+ /* Get the size of the file */
+ if((file_size = h5_get_file_size(filename)) == 0)
+ TEST_ERROR
+#ifdef QAK
+HDfprintf(stderr, "file_size = %lu\n", (unsigned long)file_size);
+#endif /* QAK */
+
+ /* Verify the file is correct size */
+ if(file_size != empty_size)
+ TEST_ERROR
+
+ /* Free resources */
+ H5MM_xfree(keep_ids.ids);
+ H5MM_xfree(keep_ids.lens);
+ H5MM_xfree(keep_ids.offs);
+
+ PASSED()
+
+ /* All tests passed */
+ return(0);
+
+error:
+ H5E_BEGIN_TRY {
+ H5MM_xfree(keep_ids.ids);
+ H5MM_xfree(keep_ids.lens);
+ H5MM_xfree(keep_ids.offs);
+ H5MM_xfree(del_str);
+ H5MM_xfree(test_desc);
+ if(fh)
+ H5HF_close(fh, dxpl);
+ H5Fclose(file);
+ } H5E_END_TRY;
+ return(1);
+} /* test_abs_remove_first_four_rows() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: test_abs_remove_all_root_direct
+ *
+ * Purpose: Test filling and removing all objects from all direct blocks
+ * in root indirect block of heap
+ *
+ * Return: Success: 0
+ *
+ * Failure: 1
+ *
+ * Programmer: Quincey Koziol
+ * Tuesday, June 13, 2006
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+test_abs_remove_all_root_direct(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam)
+{
+ hid_t file = -1; /* File ID */
+ hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */
+ char filename[1024]; /* Filename to use */
+ H5F_t *f = NULL; /* Internal file object pointer */
+ H5HF_t *fh = NULL; /* Fractal heap wrapper */
+ haddr_t fh_addr; /* Address of fractal heap */
+ fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */
+ size_t id_len; /* Size of fractal heap IDs */
+ off_t empty_size; /* Size of a file with an empty heap */
+ off_t file_size; /* Size of file currently */
+ fheap_heap_state_t state; /* State of fractal heap */
+ const char *base_desc = "removing all objects from all direct blocks of root group in absolute heap %s"; /* Test description */
+ char *del_str = NULL; /* Deletion order description */
+ char *test_desc = NULL; /* Test description */
+
+ /* Set the filename to use for this test (dependent on fapl) */
+ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename));
+
+ /* Create the file to work on */
+ if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
+ TEST_ERROR
+
+ /* Get a pointer to the internal file object */
+ if(NULL == (f = H5I_object(file)))
+ STACK_ERROR
+
+ /* Create absolute heap */
+ if(NULL == (fh = H5HF_create(f, dxpl, cparam)))
+ FAIL_STACK_ERROR
+ if(H5HF_get_id_len(fh, &id_len) < 0)
+ FAIL_STACK_ERROR
+ if(id_len > HEAP_ID_LEN)
+ FAIL_STACK_ERROR
+ if(H5HF_get_heap_addr(fh, &fh_addr) < 0)
+ FAIL_STACK_ERROR
+ if(!H5F_addr_defined(fh_addr))
+ FAIL_STACK_ERROR
+ HDmemset(&state, 0, sizeof(fheap_heap_state_t));
+ if(check_stats(fh, &state))
+ FAIL_STACK_ERROR
+
+ /* Prepare for querying the size of a file with an empty heap */
+
+ /* Close (empty) heap */
+ if(H5HF_close(fh, dxpl) < 0)
+ TEST_ERROR
+
+ /* Close file */
+ if(H5Fclose(file)<0) TEST_ERROR;
+
+ /* Get the size of a file w/empty heap*/
+ if((empty_size = h5_get_file_size(filename)) == 0)
+ TEST_ERROR
+#ifdef QAK
+HDfprintf(stderr, "empty_size = %lu\n", (unsigned long)empty_size);
+#endif /* QAK */
+
+ /* Re-open the file */
+ if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0)
+ TEST_ERROR
+
+ /* Get a pointer to the internal file object */
+ if(NULL == (f = H5I_object(file)))
+ STACK_ERROR
+
+ /* Re-open heap */
+ if(NULL == (fh = H5HF_open(f, dxpl, fh_addr)))
+ FAIL_STACK_ERROR
+
+ /*
+ * Test filling & removing all (small) objects from first row of direct blocks of absolute heap
+ */
+ del_str = get_del_string(tparam);
+ HDassert(del_str);
+ test_desc = H5MM_malloc(HDstrlen(del_str) + HDstrlen(base_desc));
+ sprintf(test_desc, base_desc, del_str);
+ TESTING(test_desc);
+ H5MM_xfree(del_str);
+ H5MM_xfree(test_desc);
+
+ /* Initialize the heap ID structure */
+ HDmemset(&keep_ids, 0, sizeof(fheap_heap_ids_t));
+
+ /* Fill direct blocks in root indirect block */
+ if(fill_root_direct(fh, dxpl, SMALL_OBJ_SIZE1, &state, &keep_ids))
+ FAIL_STACK_ERROR
+
+ /* Check for closing & re-opening the heap */
+ if(tparam->reopen_heap) {
+ /* Close heap */
+ if(H5HF_close(fh, dxpl) < 0)
+ TEST_ERROR
+
+ /* Re-open heap */
+ if(NULL == (fh = H5HF_open(f, dxpl, fh_addr)))
+ FAIL_STACK_ERROR
+ } /* end if */
+
+ /* Check up on heap... */
+ if(check_stats(fh, &state))
+ FAIL_STACK_ERROR
+
+ /* Delete objects inserted (either forward or reverse order) */
+ if(del_objs(f, dxpl, &fh, tparam, &state, &keep_ids))
+ FAIL_STACK_ERROR
+
+ /* Close the fractal heap */
+ if(H5HF_close(fh, dxpl) < 0)
+ TEST_ERROR
+ fh = NULL;
+
+ /* Close the file */
+ if(H5Fclose(file) < 0)
+ TEST_ERROR
+
+ /* Get the size of the file */
+ if((file_size = h5_get_file_size(filename)) == 0)
+ TEST_ERROR
+#ifdef QAK
+HDfprintf(stderr, "file_size = %lu\n", (unsigned long)file_size);
+#endif /* QAK */
+
+ /* Verify the file is correct size */
+ if(file_size != empty_size)
+ TEST_ERROR
+
+ /* Free resources */
+ H5MM_xfree(keep_ids.ids);
+ H5MM_xfree(keep_ids.lens);
+ H5MM_xfree(keep_ids.offs);
+
+ PASSED()
+
+ /* All tests passed */
+ return(0);
+
+error:
+ H5E_BEGIN_TRY {
+ H5MM_xfree(keep_ids.ids);
+ H5MM_xfree(keep_ids.lens);
+ H5MM_xfree(keep_ids.offs);
+ H5MM_xfree(del_str);
+ H5MM_xfree(test_desc);
+ if(fh)
+ H5HF_close(fh, dxpl);
+ H5Fclose(file);
+ } H5E_END_TRY;
+ return(1);
+} /* test_abs_remove_all_root_direct() */
+#endif /* QAK2 */
+
+#ifdef NOT_YET
+
+/*-------------------------------------------------------------------------
+ * Function: test_abs_remove_2nd_indirect
+ *
+ * Purpose: Test filling and removing all objects up to 2nd level indirect
+ * blocks of heap
+ *
+ * Return: Success: 0
+ *
+ * Failure: 1
+ *
+ * Programmer: Quincey Koziol
+ * Tuesday, June 13, 2006
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+test_abs_remove_2nd_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam)
+{
+ hid_t file = -1; /* File ID */
+ hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */
+ char filename[1024]; /* Filename to use */
+ H5F_t *f = NULL; /* Internal file object pointer */
+ H5HF_t *fh = NULL; /* Fractal heap wrapper */
+ haddr_t fh_addr; /* Address of fractal heap */
+ fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */
+ size_t id_len; /* Size of fractal heap IDs */
+ off_t empty_size; /* Size of a file with an empty heap */
+ off_t file_size; /* Size of file currently */
+ fheap_heap_state_t state; /* State of fractal heap */
+ const char *base_desc = "removing all objects from 2nd level indirect blocks of absolute heap %s"; /* Test description */
+ char *del_str = NULL; /* Deletion order description */
+ char *test_desc = NULL; /* Test description */
+
+ /* Set the filename to use for this test (dependent on fapl) */
+ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename));
+
+ /* Create the file to work on */
+ if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
+ TEST_ERROR
+
+ /* Get a pointer to the internal file object */
+ if(NULL == (f = H5I_object(file)))
+ STACK_ERROR
+
+ /* Create absolute heap */
+ if(NULL == (fh = H5HF_create(f, dxpl, cparam)))
+ FAIL_STACK_ERROR
+ if(H5HF_get_id_len(fh, &id_len) < 0)
+ FAIL_STACK_ERROR
+ if(id_len > HEAP_ID_LEN)
+ FAIL_STACK_ERROR
+ if(H5HF_get_heap_addr(fh, &fh_addr) < 0)
+ FAIL_STACK_ERROR
+ if(!H5F_addr_defined(fh_addr))
+ FAIL_STACK_ERROR
+ HDmemset(&state, 0, sizeof(fheap_heap_state_t));
+ if(check_stats(fh, &state))
+ FAIL_STACK_ERROR
+
+ /* Prepare for querying the size of a file with an empty heap */
+
+ /* Close (empty) heap */
+ if(H5HF_close(fh, dxpl) < 0)
+ TEST_ERROR
+
+ /* Close file */
+ if(H5Fclose(file)<0) TEST_ERROR;
+
+ /* Get the size of a file w/empty heap*/
+ if((empty_size = h5_get_file_size(filename)) == 0)
+ TEST_ERROR
+#ifdef QAK
+HDfprintf(stderr, "empty_size = %lu\n", (unsigned long)empty_size);
+#endif /* QAK */
+
+ /* Re-open the file */
+ if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0)
+ TEST_ERROR
+
+ /* Get a pointer to the internal file object */
+ if(NULL == (f = H5I_object(file)))
+ STACK_ERROR
+
+ /* Re-open heap */
+ if(NULL == (fh = H5HF_open(f, dxpl, fh_addr)))
+ FAIL_STACK_ERROR
+
+ /*
+ * Test filling & removing all (small) objects from first row of direct blocks of absolute heap
+ */
+ del_str = get_del_string(tparam);
+ HDassert(del_str);
+ test_desc = H5MM_malloc(HDstrlen(del_str) + HDstrlen(base_desc));
+ sprintf(test_desc, base_desc, del_str);
+ TESTING(test_desc);
+ H5MM_xfree(del_str);
+ H5MM_xfree(test_desc);
+
+ /* Initialize the heap ID structure */
+ HDmemset(&keep_ids, 0, sizeof(fheap_heap_ids_t));
+
+ /* Fill direct blocks in root indirect block */
+ if(fill_root_direct(fh, dxpl, SMALL_OBJ_SIZE1, &state, &keep_ids))
+ FAIL_STACK_ERROR
+
+ /* Fill all rows of 2nd level indirect blocks */
+ if(fill_all_2nd_indirect_rows(fh, dxpl, SMALL_OBJ_SIZE1, &state, &keep_ids))
+ FAIL_STACK_ERROR
+
+ /* Check for closing & re-opening the heap */
+ if(tparam->reopen_heap) {
+ /* Close heap */
+ if(H5HF_close(fh, dxpl) < 0)
+ TEST_ERROR
+
+ /* Re-open heap */
+ if(NULL == (fh = H5HF_open(f, dxpl, fh_addr)))
+ FAIL_STACK_ERROR
+ } /* end if */
+
+ /* Check up on heap... */
+ if(check_stats(fh, &state))
+ FAIL_STACK_ERROR
+
+ /* Delete objects inserted (either forward or reverse order) */
+ if(del_objs(f, dxpl, &fh, tparam, &state, &keep_ids))
+ FAIL_STACK_ERROR
+
+ /* Close the fractal heap */
+ if(H5HF_close(fh, dxpl) < 0)
+ TEST_ERROR
+ fh = NULL;
+
+ /* Close the file */
+ if(H5Fclose(file) < 0)
+ TEST_ERROR
+
+ /* Get the size of the file */
+ if((file_size = h5_get_file_size(filename)) == 0)
+ TEST_ERROR
+#ifdef QAK
+HDfprintf(stderr, "file_size = %lu\n", (unsigned long)file_size);
+#endif /* QAK */
+
+ /* Verify the file is correct size */
+ if(file_size != empty_size)
+ TEST_ERROR
+
+ /* Free resources */
+ H5MM_xfree(keep_ids.ids);
+ H5MM_xfree(keep_ids.lens);
+ H5MM_xfree(keep_ids.offs);
+
+ PASSED()
+
+ /* All tests passed */
+ return(0);
+
+error:
+ H5E_BEGIN_TRY {
+ H5MM_xfree(keep_ids.ids);
+ H5MM_xfree(keep_ids.lens);
+ H5MM_xfree(keep_ids.offs);
+ H5MM_xfree(del_str);
+ H5MM_xfree(test_desc);
+ if(fh)
+ H5HF_close(fh, dxpl);
+ H5Fclose(file);
+ } H5E_END_TRY;
+ return(1);
+} /* test_abs_remove_2nd_indirect() */
+#endif /* NOT_YET */
+#endif /* QAK */
/*-------------------------------------------------------------------------
@@ -10662,6 +13067,7 @@ main(void)
H5HF_create_t cparam; /* Creation parameters for heap */
hid_t fapl = -1; /* File access property list for data files */
fheap_test_type_t curr_test; /* Current test being worked on */
+ unsigned u; /* Local index variable */
unsigned nerrors = 0; /* Cumulative error count */
int ExpressMode;
@@ -10670,18 +13076,27 @@ main(void)
fapl = h5_fileaccess();
ExpressMode = GetTestExpress();
if (ExpressMode)
- printf("***Express test mode on. Some tests maybe skipped\n");
+ printf("***Express test mode on. Some tests may be skipped\n");
/* Initialize heap's creation parameters */
init_small_cparam(&cparam);
+ /* Allocate space for the shared objects */
+ shared_obj_size_g = cparam.standalone_size + 256;
+ shared_wobj_g = H5MM_malloc(shared_obj_size_g);
+ shared_robj_g = H5MM_malloc(shared_obj_size_g);
+
+ /* Initialize the shared write buffer for objects */
+ for(u = 0; u < shared_obj_size_g; u++)
+ shared_wobj_g[u] = (unsigned char)u;
+
/* Iterate over the testing parameters */
#ifndef QAK
for(curr_test = FHEAP_TEST_NORMAL; curr_test < FHEAP_TEST_NTESTS; curr_test++) {
#else /* QAK */
HDfprintf(stderr, "Uncomment test loop!\n");
-curr_test = FHEAP_TEST_NORMAL;
-/* curr_test = FHEAP_TEST_REOPEN; */
+/* curr_test = FHEAP_TEST_NORMAL; */
+curr_test = FHEAP_TEST_REOPEN;
#endif /* QAK */
/* Clear the testing parameters */
HDmemset(&tparam, 0, sizeof(fheap_test_param_t));
@@ -10749,47 +13164,43 @@ curr_test = FHEAP_TEST_NORMAL;
if (ExpressMode)
printf("***Express test mode on. Some tests skipped\n");
else
- nerrors += test_abs_start_5th_recursive_indirect(fapl, &cparam, &tparam);
+ nerrors += test_abs_start_5th_recursive_indirect(fapl, &cparam, &tparam);
#else /* QAK */
HDfprintf(stderr, "Uncomment tests!\n");
#endif /* QAK */
#ifndef QAK
+ /* Skip blocks insertion */
if (ExpressMode)
printf("***Express test mode on. Some tests skipped\n");
else {
- /* Skip blocks insertion */
- nerrors += test_abs_skip_start_block(fapl, &cparam, &tparam);
- nerrors += test_abs_skip_start_block_add_back(fapl, &cparam, &tparam);
- nerrors += test_abs_skip_start_block_add_skipped(fapl, &cparam, &tparam);
- nerrors += test_abs_skip_2nd_block(fapl, &cparam, &tparam);
- nerrors += test_abs_skip_2nd_block_add_skipped(fapl, &cparam, &tparam);
- nerrors += test_abs_fill_one_partial_skip_2nd_block_add_skipped(fapl, &cparam, &tparam);
- nerrors += test_abs_fill_row_skip_add_skipped(fapl, &cparam, &tparam);
- nerrors += test_abs_fill_direct_skip_indirect_start_block_add_skipped(fapl, &cparam, &tparam);
- nerrors += test_abs_fill_direct_skip_2nd_indirect_start_block_add_skipped(fapl, &cparam, &tparam);
- nerrors += test_abs_fill_2nd_direct_less_one_wrap_start_block_add_skipped(fapl, &cparam, &tparam);
- nerrors += test_abs_fill_direct_skip_2nd_indirect_skip_2nd_block_add_skipped(fapl, &cparam, &tparam);
- nerrors += test_abs_fill_direct_skip_indirect_two_rows_add_skipped(fapl, &cparam, &tparam);
- nerrors += test_abs_fill_2nd_direct_skip_start_block_add_skipped(fapl, &cparam, &tparam);
- nerrors += test_abs_fill_2nd_direct_skip_2nd_indirect_start_block_add_skipped(fapl, &cparam, &tparam);
- nerrors += test_abs_fill_2nd_direct_fill_direct_skip_3rd_indirect_start_block_add_skipped(fapl, &cparam, &tparam);
- nerrors += test_abs_fill_2nd_direct_fill_direct_skip2_3rd_indirect_start_block_add_skipped(fapl, &cparam, &tparam);
- nerrors += test_abs_fill_3rd_direct_less_one_fill_direct_wrap_start_block_add_skipped(fapl, &cparam, &tparam);
- nerrors += test_abs_fill_1st_row_3rd_direct_fill_2nd_direct_less_one_wrap_start_block_add_skipped(fapl, &cparam, &tparam);
- nerrors += test_abs_fill_3rd_direct_fill_direct_skip_start_block_add_skipped(fapl, &cparam, &tparam);
- nerrors += test_abs_fill_3rd_direct_fill_2nd_direct_fill_direct_skip_3rd_indirect_start_block_add_skipped(fapl, &cparam, &tparam);
- nerrors += test_abs_fill_3rd_direct_fill_2nd_direct_fill_direct_skip_3rd_indirect_two_rows_start_block_add_skipped(fapl, &cparam, &tparam);
- nerrors += test_abs_fill_3rd_direct_fill_2nd_direct_fill_direct_skip_3rd_indirect_wrap_start_block_add_skipped(fapl, &cparam, &tparam);
- nerrors += test_abs_fill_4th_direct_less_one_fill_2nd_direct_fill_direct_skip_3rd_indirect_wrap_start_block_add_skipped(fapl, &cparam, &tparam);
- }
-#else /* QAK */
-HDfprintf(stderr, "Uncomment tests!\n");
-#endif /* QAK */
-
- /* Additional skipped block insertion tests */
-#ifndef QAK
- nerrors += test_abs_skip_direct_skip_indirect_two_rows_add_skipped(fapl, &cparam, &tparam);
+ nerrors += test_abs_skip_start_block(fapl, &cparam, &tparam);
+ nerrors += test_abs_skip_start_block_add_back(fapl, &cparam, &tparam);
+ nerrors += test_abs_skip_start_block_add_skipped(fapl, &cparam, &tparam);
+ nerrors += test_abs_skip_2nd_block(fapl, &cparam, &tparam);
+ nerrors += test_abs_skip_2nd_block_add_skipped(fapl, &cparam, &tparam);
+ nerrors += test_abs_fill_one_partial_skip_2nd_block_add_skipped(fapl, &cparam, &tparam);
+ nerrors += test_abs_fill_row_skip_add_skipped(fapl, &cparam, &tparam);
+ nerrors += test_abs_fill_direct_skip_indirect_start_block_add_skipped(fapl, &cparam, &tparam);
+ nerrors += test_abs_fill_direct_skip_2nd_indirect_start_block_add_skipped(fapl, &cparam, &tparam);
+ nerrors += test_abs_fill_2nd_direct_less_one_wrap_start_block_add_skipped(fapl, &cparam, &tparam);
+ nerrors += test_abs_fill_direct_skip_2nd_indirect_skip_2nd_block_add_skipped(fapl, &cparam, &tparam);
+ nerrors += test_abs_fill_direct_skip_indirect_two_rows_add_skipped(fapl, &cparam, &tparam);
+ nerrors += test_abs_fill_2nd_direct_skip_start_block_add_skipped(fapl, &cparam, &tparam);
+ nerrors += test_abs_fill_2nd_direct_skip_2nd_indirect_start_block_add_skipped(fapl, &cparam, &tparam);
+ nerrors += test_abs_fill_2nd_direct_fill_direct_skip_3rd_indirect_start_block_add_skipped(fapl, &cparam, &tparam);
+ nerrors += test_abs_fill_2nd_direct_fill_direct_skip2_3rd_indirect_start_block_add_skipped(fapl, &cparam, &tparam);
+ nerrors += test_abs_fill_3rd_direct_less_one_fill_direct_wrap_start_block_add_skipped(fapl, &cparam, &tparam);
+ nerrors += test_abs_fill_1st_row_3rd_direct_fill_2nd_direct_less_one_wrap_start_block_add_skipped(fapl, &cparam, &tparam);
+ nerrors += test_abs_fill_3rd_direct_fill_direct_skip_start_block_add_skipped(fapl, &cparam, &tparam);
+ nerrors += test_abs_fill_3rd_direct_fill_2nd_direct_fill_direct_skip_3rd_indirect_start_block_add_skipped(fapl, &cparam, &tparam);
+ nerrors += test_abs_fill_3rd_direct_fill_2nd_direct_fill_direct_skip_3rd_indirect_two_rows_start_block_add_skipped(fapl, &cparam, &tparam);
+ nerrors += test_abs_fill_3rd_direct_fill_2nd_direct_fill_direct_skip_3rd_indirect_wrap_start_block_add_skipped(fapl, &cparam, &tparam);
+ nerrors += test_abs_fill_4th_direct_less_one_fill_2nd_direct_fill_direct_skip_3rd_indirect_wrap_start_block_add_skipped(fapl, &cparam, &tparam);
+
+ /* Additional skipped block insertion tests */
+ nerrors += test_abs_skip_direct_skip_indirect_two_rows_add_skipped(fapl, &cparam, &tparam);
+ } /* end else */
#else /* QAK */
HDfprintf(stderr, "Uncomment tests!\n");
#endif /* QAK */
@@ -10809,9 +13220,9 @@ HDfprintf(stderr, "Uncomment tests!\n");
if (ExpressMode)
printf("***Express test mode on. Some tests skipped\n");
else {
- nerrors += test_abs_random_managed((hsize_t)(100*1000*1000), fapl, &cparam, &tparam);
- nerrors += test_abs_random_pow2_managed((hsize_t)(100*1000*1000), fapl, &cparam, &tparam);
- }
+ nerrors += test_abs_random_managed((hsize_t)(100*1000*1000), fapl, &cparam, &tparam);
+ nerrors += test_abs_random_pow2_managed((hsize_t)(100*1000*1000), fapl, &cparam, &tparam);
+ } /* end else */
#else /* QAK */
HDfprintf(stderr, "Uncomment tests!\n");
#endif /* QAK */
@@ -10822,10 +13233,64 @@ HDfprintf(stderr, "Uncomment tests!\n");
/* Simple removal */
#ifndef QAK
nerrors += test_abs_remove_bogus(fapl, &cparam, &tparam);
+ nerrors += test_abs_remove_one(fapl, &cparam, &tparam);
+ nerrors += test_abs_remove_two(fapl, &cparam, &tparam);
+ nerrors += test_abs_remove_one_larger(fapl, &cparam, &tparam);
+ tparam.del_dir = HEAP_DEL_FORWARD;
+ nerrors += test_abs_remove_two_larger(fapl, &cparam, &tparam);
+ tparam.del_dir = HEAP_DEL_REVERSE;
+ nerrors += test_abs_remove_two_larger(fapl, &cparam, &tparam);
+ tparam.del_dir = HEAP_DEL_FORWARD;
+ nerrors += test_abs_remove_three_larger(fapl, &cparam, &tparam);
+ tparam.del_dir = HEAP_DEL_REVERSE;
+ nerrors += test_abs_remove_three_larger(fapl, &cparam, &tparam);
+#else /* QAK */
+HDfprintf(stderr, "Uncomment tests!\n");
+#endif /* QAK */
+
+#ifndef QAK
+#ifndef QAK
+ {
+ fheap_test_del_dir_t del_dir; /* Deletion direction */
+ fheap_test_del_drain_t drain_half; /* Deletion draining */
+
+ /* More complex removals */
+ for(drain_half = HEAP_DEL_DRAIN_ALL; drain_half < HEAP_DEL_DRAIN_N; drain_half++) {
+ tparam.drain_half = drain_half;
+ for(del_dir = HEAP_DEL_FORWARD; del_dir < HEAP_DEL_NDIRS; del_dir++) {
+ tparam.del_dir = del_dir;
+#else /* QAK */
+HDfprintf(stderr, "Uncomment test loops!\n");
+tparam.drain_half = HEAP_DEL_DRAIN_ALL;
+/* tparam.drain_half = HEAP_DEL_DRAIN_HALF; */
+tparam.del_dir = HEAP_DEL_REVERSE;
+#endif /* QAK */
+
+#ifndef QAK
+#ifndef QAK2
+ nerrors += test_abs_remove_root_direct(fapl, &cparam, &tparam);
+ nerrors += test_abs_remove_two_direct(fapl, &cparam, &tparam);
+ nerrors += test_abs_remove_first_row(fapl, &cparam, &tparam);
+ nerrors += test_abs_remove_first_two_rows(fapl, &cparam, &tparam);
+ nerrors += test_abs_remove_first_four_rows(fapl, &cparam, &tparam);
+ nerrors += test_abs_remove_all_root_direct(fapl, &cparam, &tparam);
+#else /* QAK2 */
+HDfprintf(stderr, "Uncomment tests!\n");
+#endif /* QAK2 */
+#ifdef NOT_YET
+ nerrors += test_abs_remove_2nd_indirect(fapl, &cparam, &tparam);
+#endif /* NOT_YET */
+#else /* QAK */
+HDfprintf(stderr, "Uncomment tests!\n");
+#endif /* QAK */
+#ifndef QAK
+ } /* end for */
+ } /* end for */
+ } /* end block */
+#endif /* QAK */
#else /* QAK */
HDfprintf(stderr, "Uncomment tests!\n");
#endif /* QAK */
- nerrors += test_abs_remove_one(fapl, &cparam, &tparam);
#ifndef QAK
} /* end for */
#endif /* QAK */
@@ -10833,16 +13298,31 @@ HDfprintf(stderr, "Uncomment tests!\n");
if(nerrors)
goto error;
puts("All fractal heap tests passed.");
+
+ /* Release space for the shared objects */
+ H5MM_xfree(shared_wobj_g);
+ H5MM_xfree(shared_robj_g);
+ H5MM_xfree(shared_ids_g);
+ H5MM_xfree(shared_lens_g);
+ H5MM_xfree(shared_offs_g);
+
+ /* Clean up file used */
#ifndef QAK
h5_cleanup(FILENAME, fapl);
#else /* QAK */
HDfprintf(stderr, "Uncomment cleanup!\n");
#endif /* QAK */
+
return 0;
error:
puts("*** TESTS FAILED ***");
H5E_BEGIN_TRY {
+ H5MM_xfree(shared_wobj_g);
+ H5MM_xfree(shared_robj_g);
+ H5MM_xfree(shared_ids_g);
+ H5MM_xfree(shared_lens_g);
+ H5MM_xfree(shared_offs_g);
H5Pclose(fapl);
} H5E_END_TRY;
return 1;