summaryrefslogtreecommitdiffstats
path: root/src/H5HFiter.c
diff options
context:
space:
mode:
authorAllen Byrne <byrn@hdfgroup.org>2020-09-30 14:27:10 (GMT)
committerAllen Byrne <byrn@hdfgroup.org>2020-09-30 14:27:10 (GMT)
commitb2d661b508a7fc7a2592c13bc6bdc175551f075d (patch)
tree13baeb0d83a7c2a4c6299993c182b1227c2f6114 /src/H5HFiter.c
parent29ab58b58dce556639ea3154e262895773a8a8df (diff)
downloadhdf5-b2d661b508a7fc7a2592c13bc6bdc175551f075d.zip
hdf5-b2d661b508a7fc7a2592c13bc6bdc175551f075d.tar.gz
hdf5-b2d661b508a7fc7a2592c13bc6bdc175551f075d.tar.bz2
Clang-format of source files
Diffstat (limited to 'src/H5HFiter.c')
-rw-r--r--src/H5HFiter.c229
1 files changed, 109 insertions, 120 deletions
diff --git a/src/H5HFiter.c b/src/H5HFiter.c
index 43cb76a..f2e6916 100644
--- a/src/H5HFiter.c
+++ b/src/H5HFiter.c
@@ -26,47 +26,40 @@
/* Module Setup */
/****************/
-#include "H5HFmodule.h" /* This source code file is part of the H5HF module */
-
+#include "H5HFmodule.h" /* This source code file is part of the H5HF module */
/***********/
/* Headers */
/***********/
-#include "H5private.h" /* Generic Functions */
-#include "H5Eprivate.h" /* Error handling */
-#include "H5HFpkg.h" /* Fractal heaps */
-#include "H5VMprivate.h" /* Vectors and arrays */
+#include "H5private.h" /* Generic Functions */
+#include "H5Eprivate.h" /* Error handling */
+#include "H5HFpkg.h" /* Fractal heaps */
+#include "H5VMprivate.h" /* Vectors and arrays */
/****************/
/* Local Macros */
/****************/
-
/******************/
/* Local Typedefs */
/******************/
-
/********************/
/* Package Typedefs */
/********************/
-
/********************/
/* Local Prototypes */
/********************/
-
/*********************/
/* Package Variables */
/*********************/
-
/*****************************/
/* Library Private Variables */
/*****************************/
-
/*******************/
/* Local Variables */
/*******************/
@@ -74,8 +67,6 @@
/* Declare a free list to manage the H5HF_block_loc_t struct */
H5FL_DEFINE(H5HF_block_loc_t);
-
-
/*-------------------------------------------------------------------------
* Function: H5HF__man_iter_init
*
@@ -106,7 +97,6 @@ H5HF__man_iter_init(H5HF_block_iter_t *biter)
FUNC_LEAVE_NOAPI(SUCCEED)
} /* end H5HF__man_iter_init() */
-
/*-------------------------------------------------------------------------
* Function: H5HF__man_iter_start_offset
*
@@ -121,19 +111,18 @@ H5HF__man_iter_init(H5HF_block_iter_t *biter)
*-------------------------------------------------------------------------
*/
herr_t
-H5HF__man_iter_start_offset(H5HF_hdr_t *hdr, H5HF_block_iter_t *biter,
- hsize_t offset)
+H5HF__man_iter_start_offset(H5HF_hdr_t *hdr, H5HF_block_iter_t *biter, hsize_t offset)
{
- H5HF_indirect_t *iblock; /* Indirect block for location context */
- haddr_t iblock_addr; /* Address of indirect block */
- unsigned iblock_nrows; /* # of rows in indirect block */
- H5HF_indirect_t *iblock_parent; /* Parent indirect block of location context */
- unsigned iblock_par_entry; /* Entry within parent indirect block */
- hsize_t curr_offset; /* Current offset, as adjusted */
- unsigned row; /* Current row we are on */
- unsigned col; /* Column in row */
- hbool_t root_block = TRUE; /* Flag to indicate the current block is the root indirect block */
- herr_t ret_value = SUCCEED; /* Return value */
+ H5HF_indirect_t *iblock; /* Indirect block for location context */
+ haddr_t iblock_addr; /* Address of indirect block */
+ unsigned iblock_nrows; /* # of rows in indirect block */
+ H5HF_indirect_t *iblock_parent; /* Parent indirect block of location context */
+ unsigned iblock_par_entry; /* Entry within parent indirect block */
+ hsize_t curr_offset; /* Current offset, as adjusted */
+ unsigned row; /* Current row we are on */
+ unsigned col; /* Column in row */
+ hbool_t root_block = TRUE; /* Flag to indicate the current block is the root indirect block */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_PACKAGE
@@ -147,30 +136,31 @@ H5HF__man_iter_start_offset(H5HF_hdr_t *hdr, H5HF_block_iter_t *biter,
HDassert(offset >= hdr->man_dtable.cparam.start_block_size);
/* Allocate level structure */
- if(NULL == (biter->curr = H5FL_MALLOC(H5HF_block_loc_t)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for direct block free list section")
-
-/*
-1: <Scan down block offsets for dtable rows until find a row >= offset>
- <Set current location's row, col, entry & size>
- <If row < max_direct_rows>
- <Done>
- <Else - row > max_direct_rows>
- <Create new block level>
- <Link new block level into iterator>
- <Adjust offset for block offset for row>
- <Make new block level the current context>
- <Goto 1>
-
-*/
+ if (NULL == (biter->curr = H5FL_MALLOC(H5HF_block_loc_t)))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL,
+ "memory allocation failed for direct block free list section")
+
+ /*
+ 1: <Scan down block offsets for dtable rows until find a row >= offset>
+ <Set current location's row, col, entry & size>
+ <If row < max_direct_rows>
+ <Done>
+ <Else - row > max_direct_rows>
+ <Create new block level>
+ <Link new block level into iterator>
+ <Adjust offset for block offset for row>
+ <Make new block level the current context>
+ <Goto 1>
+
+ */
do {
- hbool_t did_protect; /* Whether we protected the indirect block or not */
+ hbool_t did_protect; /* Whether we protected the indirect block or not */
/* Walk down the rows in the doubling table until we've found the correct row for the next block */
- for(row = 0; row < hdr->man_dtable.max_root_rows; row++)
- if((offset >= hdr->man_dtable.row_block_off[row]) &&
- (offset < hdr->man_dtable.row_block_off[row] +
- (hdr->man_dtable.cparam.width * hdr->man_dtable.row_block_size[row])))
+ for (row = 0; row < hdr->man_dtable.max_root_rows; row++)
+ if ((offset >= hdr->man_dtable.row_block_off[row]) &&
+ (offset < hdr->man_dtable.row_block_off[row] +
+ (hdr->man_dtable.cparam.width * hdr->man_dtable.row_block_size[row])))
break;
/* Adjust offset by row offset */
@@ -181,15 +171,15 @@ H5HF__man_iter_start_offset(H5HF_hdr_t *hdr, H5HF_block_iter_t *biter,
col = (unsigned)(curr_offset / hdr->man_dtable.row_block_size[row]);
/* Set the current level's context */
- biter->curr->row = row;
- biter->curr->col = col;
+ biter->curr->row = row;
+ biter->curr->col = col;
biter->curr->entry = (row * hdr->man_dtable.cparam.width) + col;
/* Get the context indirect block's information */
- if(root_block) {
- iblock_addr = hdr->man_dtable.table_addr;
- iblock_nrows = hdr->man_dtable.curr_root_rows;
- iblock_parent = NULL;
+ if (root_block) {
+ iblock_addr = hdr->man_dtable.table_addr;
+ iblock_nrows = hdr->man_dtable.curr_root_rows;
+ iblock_parent = NULL;
iblock_par_entry = 0;
/* The root block can't go up further... */
@@ -199,49 +189,54 @@ H5HF__man_iter_start_offset(H5HF_hdr_t *hdr, H5HF_block_iter_t *biter,
root_block = FALSE;
} /* end if */
else {
- hsize_t child_size; /* Size of new indirect block to create */
+ hsize_t child_size; /* Size of new indirect block to create */
/* Retrieve the parent information from the previous context location */
- iblock_parent = biter->curr->up->context;
+ iblock_parent = biter->curr->up->context;
iblock_par_entry = biter->curr->up->entry;
/* Look up the address of context indirect block */
iblock_addr = iblock_parent->ents[iblock_par_entry].addr;
/* Compute # of rows in context indirect block */
- child_size = hdr->man_dtable.row_block_size[biter->curr->up->row];
+ child_size = hdr->man_dtable.row_block_size[biter->curr->up->row];
iblock_nrows = (H5VM_log2_gen(child_size) - hdr->man_dtable.first_row_bits) + 1;
} /* end else */
/* Load indirect block for this context location */
- if(NULL == (iblock = H5HF__man_iblock_protect(hdr, iblock_addr, iblock_nrows, iblock_parent, iblock_par_entry, FALSE, H5AC__NO_FLAGS_SET, &did_protect)))
+ if (NULL ==
+ (iblock = H5HF__man_iblock_protect(hdr, iblock_addr, iblock_nrows, iblock_parent,
+ iblock_par_entry, FALSE, H5AC__NO_FLAGS_SET, &did_protect)))
HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, FAIL, "unable to protect fractal heap indirect block")
/* Make indirect block the context for the current location */
biter->curr->context = iblock;
/* Hold the indirect block with the location */
- if(H5HF__iblock_incr(biter->curr->context) < 0)
- HGOTO_ERROR(H5E_HEAP, H5E_CANTINC, FAIL, "can't increment reference count on shared indirect block")
+ if (H5HF__iblock_incr(biter->curr->context) < 0)
+ HGOTO_ERROR(H5E_HEAP, H5E_CANTINC, FAIL,
+ "can't increment reference count on shared indirect block")
/* Release the current indirect block */
- if(H5HF__man_iblock_unprotect(iblock, H5AC__NO_FLAGS_SET, did_protect) < 0)
+ if (H5HF__man_iblock_unprotect(iblock, H5AC__NO_FLAGS_SET, did_protect) < 0)
HGOTO_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release fractal heap indirect block")
iblock = NULL;
/* See if the location falls in a direct block row */
/* Or, if the offset has just filled up a direct or indirect block */
- if(curr_offset == (col * hdr->man_dtable.row_block_size[row]) || row < hdr->man_dtable.max_direct_rows) {
+ if (curr_offset == (col * hdr->man_dtable.row_block_size[row]) ||
+ row < hdr->man_dtable.max_direct_rows) {
HDassert(curr_offset - (col * hdr->man_dtable.row_block_size[row]) == 0);
- break; /* Done now */
- } /* end if */
+ break; /* Done now */
+ } /* end if */
/* Indirect block row */
else {
- H5HF_block_loc_t *new_loc; /* Pointer to new block location */
+ H5HF_block_loc_t *new_loc; /* Pointer to new block location */
/* Allocate level structure */
- if(NULL == (new_loc = H5FL_MALLOC(H5HF_block_loc_t)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for direct block free list section")
+ if (NULL == (new_loc = H5FL_MALLOC(H5HF_block_loc_t)))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL,
+ "memory allocation failed for direct block free list section")
/* Link new level into iterator */
new_loc->up = biter->curr;
@@ -251,8 +246,8 @@ H5HF__man_iter_start_offset(H5HF_hdr_t *hdr, H5HF_block_iter_t *biter,
/* Make new block the current context */
biter->curr = new_loc;
- } /* end else */
- } while(1); /* Breaks out in middle */
+ } /* end else */
+ } while (1); /* Breaks out in middle */
/* Set flag to indicate block iterator finished initializing */
biter->ready = TRUE;
@@ -261,7 +256,6 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5HF__man_iter_start_offset() */
-
/*-------------------------------------------------------------------------
* Function: H5HF__man_iter_set_entry
*
@@ -286,13 +280,12 @@ H5HF__man_iter_set_entry(const H5HF_hdr_t *hdr, H5HF_block_iter_t *biter, unsign
/* Set location context */
biter->curr->entry = entry;
- biter->curr->row = entry / hdr->man_dtable.cparam.width;
- biter->curr->col = entry % hdr->man_dtable.cparam.width;
+ biter->curr->row = entry / hdr->man_dtable.cparam.width;
+ biter->curr->col = entry % hdr->man_dtable.cparam.width;
FUNC_LEAVE_NOAPI(SUCCEED)
} /* end H5HF__man_iter_set_entry() */
-
/*-------------------------------------------------------------------------
* Function: H5HF__man_iter_start_entry
*
@@ -307,11 +300,11 @@ H5HF__man_iter_set_entry(const H5HF_hdr_t *hdr, H5HF_block_iter_t *biter, unsign
*-------------------------------------------------------------------------
*/
herr_t
-H5HF__man_iter_start_entry(H5HF_hdr_t *hdr, H5HF_block_iter_t *biter,
- H5HF_indirect_t *iblock, unsigned start_entry)
+H5HF__man_iter_start_entry(H5HF_hdr_t *hdr, H5HF_block_iter_t *biter, H5HF_indirect_t *iblock,
+ unsigned start_entry)
{
- H5HF_block_loc_t *new_loc = NULL; /* Pointer to new block location */
- herr_t ret_value = SUCCEED; /* Return value */
+ H5HF_block_loc_t *new_loc = NULL; /* Pointer to new block location */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_PACKAGE
@@ -324,18 +317,19 @@ H5HF__man_iter_start_entry(H5HF_hdr_t *hdr, H5HF_block_iter_t *biter,
HDassert(iblock);
/* Create new location for iterator */
- if(NULL == (new_loc = H5FL_MALLOC(H5HF_block_loc_t)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for direct block free list section")
+ if (NULL == (new_loc = H5FL_MALLOC(H5HF_block_loc_t)))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL,
+ "memory allocation failed for direct block free list section")
/* Set up location context */
- new_loc->entry = start_entry;
- new_loc->row = start_entry / hdr->man_dtable.cparam.width;
- new_loc->col = start_entry % hdr->man_dtable.cparam.width;
+ new_loc->entry = start_entry;
+ new_loc->row = start_entry / hdr->man_dtable.cparam.width;
+ new_loc->col = start_entry % hdr->man_dtable.cparam.width;
new_loc->context = iblock;
- new_loc->up = NULL;
+ new_loc->up = NULL;
/* Increment reference count on indirect block */
- if(H5HF__iblock_incr(new_loc->context) < 0)
+ if (H5HF__iblock_incr(new_loc->context) < 0)
HGOTO_ERROR(H5E_HEAP, H5E_CANTINC, FAIL, "can't increment reference count on shared indirect block")
/* Make new location the current location */
@@ -345,13 +339,12 @@ H5HF__man_iter_start_entry(H5HF_hdr_t *hdr, H5HF_block_iter_t *biter,
biter->ready = TRUE;
done:
- if(ret_value < 0 && new_loc)
+ if (ret_value < 0 && new_loc)
new_loc = H5FL_FREE(H5HF_block_loc_t, new_loc);
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5HF__man_iter_start_entry() */
-
/*-------------------------------------------------------------------------
* Function: H5HF__man_iter_reset
*
@@ -368,7 +361,7 @@ done:
herr_t
H5HF__man_iter_reset(H5HF_block_iter_t *biter)
{
- herr_t ret_value = SUCCEED; /* Return value */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_PACKAGE
@@ -378,20 +371,21 @@ H5HF__man_iter_reset(H5HF_block_iter_t *biter)
HDassert(biter);
/* Free any location contexts that exist */
- if(biter->curr) {
- H5HF_block_loc_t *curr_loc; /* Pointer to current block location */
- H5HF_block_loc_t *next_loc; /* Pointer to next block location */
+ if (biter->curr) {
+ H5HF_block_loc_t *curr_loc; /* Pointer to current block location */
+ H5HF_block_loc_t *next_loc; /* Pointer to next block location */
/* Free location contexts */
curr_loc = biter->curr;
- while(curr_loc) {
+ while (curr_loc) {
/* Get pointer to next node */
next_loc = curr_loc->up;
/* If this node is holding an indirect block, release the block */
- if(curr_loc->context)
- if(H5HF__iblock_decr(curr_loc->context) < 0)
- HGOTO_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, "can't decrement reference count on shared indirect block")
+ if (curr_loc->context)
+ if (H5HF__iblock_decr(curr_loc->context) < 0)
+ HGOTO_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL,
+ "can't decrement reference count on shared indirect block")
/* Free the current location context */
curr_loc = H5FL_FREE(H5HF_block_loc_t, curr_loc);
@@ -411,7 +405,6 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5HF__man_iter_reset() */
-
/*-------------------------------------------------------------------------
* Function: H5HF__man_iter_next
*
@@ -441,12 +434,11 @@ H5HF__man_iter_next(H5HF_hdr_t *hdr, H5HF_block_iter_t *biter, unsigned nentries
biter->curr->entry += nentries;
biter->curr->row = biter->curr->entry / hdr->man_dtable.cparam.width;
biter->curr->col = biter->curr->entry % hdr->man_dtable.cparam.width;
-/* HDassert(biter->curr->row <= biter->curr->context->nrows); */
+ /* HDassert(biter->curr->row <= biter->curr->context->nrows); */
FUNC_LEAVE_NOAPI(SUCCEED)
} /* end H5HF__man_iter_next() */
-
/*-------------------------------------------------------------------------
* Function: H5HF__man_iter_up
*
@@ -462,8 +454,8 @@ H5HF__man_iter_next(H5HF_hdr_t *hdr, H5HF_block_iter_t *biter, unsigned nentries
herr_t
H5HF__man_iter_up(H5HF_block_iter_t *biter)
{
- H5HF_block_loc_t *up_loc; /* Pointer to 'up' block location */
- herr_t ret_value = SUCCEED; /* Return value */
+ H5HF_block_loc_t *up_loc; /* Pointer to 'up' block location */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_PACKAGE
@@ -477,7 +469,7 @@ H5HF__man_iter_up(H5HF_block_iter_t *biter)
HDassert(biter->curr->context);
/* Release hold on current location's indirect block */
- if(H5HF__iblock_decr(biter->curr->context) < 0)
+ if (H5HF__iblock_decr(biter->curr->context) < 0)
HGOTO_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, "can't decrement reference count on shared indirect block")
/* Get pointer to location context above this one */
@@ -493,7 +485,6 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5HF__man_iter_up() */
-
/*-------------------------------------------------------------------------
* Function: H5HF__man_iter_down
*
@@ -509,8 +500,8 @@ done:
herr_t
H5HF__man_iter_down(H5HF_block_iter_t *biter, H5HF_indirect_t *iblock)
{
- H5HF_block_loc_t *down_loc = NULL; /* Pointer to new 'down' block location */
- herr_t ret_value = SUCCEED; /* Return value */
+ H5HF_block_loc_t *down_loc = NULL; /* Pointer to new 'down' block location */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_PACKAGE
@@ -523,31 +514,31 @@ H5HF__man_iter_down(H5HF_block_iter_t *biter, H5HF_indirect_t *iblock)
HDassert(biter->curr->context);
/* Create new location to move down to */
- if(NULL == (down_loc = H5FL_MALLOC(H5HF_block_loc_t)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for direct block free list section")
+ if (NULL == (down_loc = H5FL_MALLOC(H5HF_block_loc_t)))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL,
+ "memory allocation failed for direct block free list section")
/* Initialize down location */
- down_loc->row = 0;
- down_loc->col = 0;
- down_loc->entry = 0;
+ down_loc->row = 0;
+ down_loc->col = 0;
+ down_loc->entry = 0;
down_loc->context = iblock;
- down_loc->up = biter->curr;
+ down_loc->up = biter->curr;
/* Increment reference count on indirect block */
- if(H5HF__iblock_incr(down_loc->context) < 0)
+ if (H5HF__iblock_incr(down_loc->context) < 0)
HGOTO_ERROR(H5E_HEAP, H5E_CANTINC, FAIL, "can't increment reference count on shared indirect block")
/* Make down location the current location */
biter->curr = down_loc;
done:
- if(ret_value < 0 && down_loc)
+ if (ret_value < 0 && down_loc)
down_loc = H5FL_FREE(H5HF_block_loc_t, down_loc);
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5HF__man_iter_down() */
-
/*-------------------------------------------------------------------------
* Function: H5HF__man_iter_curr
*
@@ -561,8 +552,8 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5HF__man_iter_curr(H5HF_block_iter_t *biter, unsigned *row, unsigned *col,
- unsigned *entry, H5HF_indirect_t **block)
+H5HF__man_iter_curr(H5HF_block_iter_t *biter, unsigned *row, unsigned *col, unsigned *entry,
+ H5HF_indirect_t **block)
{
FUNC_ENTER_PACKAGE_NOERR
@@ -573,19 +564,18 @@ H5HF__man_iter_curr(H5HF_block_iter_t *biter, unsigned *row, unsigned *col,
HDassert(biter->ready);
/* Retrieve the information asked for */
- if(row)
+ if (row)
*row = biter->curr->row;
- if(col)
+ if (col)
*col = biter->curr->col;
- if(entry)
+ if (entry)
*entry = biter->curr->entry;
- if(block)
+ if (block)
*block = biter->curr->context;
FUNC_LEAVE_NOAPI(SUCCEED)
} /* end H5HF__man_iter_curr() */
-
/*-------------------------------------------------------------------------
* Function: H5HF__man_iter_ready
*
@@ -610,4 +600,3 @@ H5HF__man_iter_ready(H5HF_block_iter_t *biter)
FUNC_LEAVE_NOAPI(biter->ready)
} /* end H5HF__man_iter_ready() */
-