summaryrefslogtreecommitdiffstats
path: root/src/H5Gbtree2.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/H5Gbtree2.c')
-rw-r--r--src/H5Gbtree2.c153
1 files changed, 65 insertions, 88 deletions
diff --git a/src/H5Gbtree2.c b/src/H5Gbtree2.c
index 918e18c..85e2c2b 100644
--- a/src/H5Gbtree2.c
+++ b/src/H5Gbtree2.c
@@ -26,23 +26,20 @@
/* Module Setup */
/****************/
-#include "H5Gmodule.h" /* This source code file is part of the H5G module */
-
+#include "H5Gmodule.h" /* This source code file is part of the H5G module */
/***********/
/* Headers */
/***********/
-#include "H5private.h" /* Generic Functions */
-#include "H5Eprivate.h" /* Error handling */
-#include "H5Gpkg.h" /* Groups */
-#include "H5MMprivate.h" /* Memory management */
-
+#include "H5private.h" /* Generic Functions */
+#include "H5Eprivate.h" /* Error handling */
+#include "H5Gpkg.h" /* Groups */
+#include "H5MMprivate.h" /* Memory management */
/****************/
/* Local Macros */
/****************/
-
/******************/
/* Local Typedefs */
/******************/
@@ -53,21 +50,19 @@
*/
typedef struct H5G_fh_ud_cmp_t {
/* downward */
- H5F_t *f; /* Pointer to file that fractal heap is in */
- const char *name; /* Name of link to compare */
- H5B2_found_t found_op; /* Callback when correct link is found */
- void *found_op_data; /* Callback data when correct link is found */
+ H5F_t * f; /* Pointer to file that fractal heap is in */
+ const char * name; /* Name of link to compare */
+ H5B2_found_t found_op; /* Callback when correct link is found */
+ void * found_op_data; /* Callback data when correct link is found */
/* upward */
- int cmp; /* Comparison of two link names */
+ int cmp; /* Comparison of two link names */
} H5G_fh_ud_cmp_t;
-
/********************/
/* Package Typedefs */
/********************/
-
/********************/
/* Local Prototypes */
/********************/
@@ -77,46 +72,43 @@ typedef struct H5G_fh_ud_cmp_t {
/* v2 B-tree driver callbacks for 'creation order' index */
static herr_t H5G__dense_btree2_corder_store(void *native, const void *udata);
static herr_t H5G__dense_btree2_corder_compare(const void *rec1, const void *rec2, int *result);
-static herr_t H5G__dense_btree2_corder_encode(uint8_t *raw, const void *native,
- void *ctx);
-static herr_t H5G__dense_btree2_corder_decode(const uint8_t *raw, void *native,
- void *ctx);
-static herr_t H5G__dense_btree2_corder_debug(FILE *stream, int indent, int fwidth,
- const void *record, const void *_udata);
+static herr_t H5G__dense_btree2_corder_encode(uint8_t *raw, const void *native, void *ctx);
+static herr_t H5G__dense_btree2_corder_decode(const uint8_t *raw, void *native, void *ctx);
+static herr_t H5G__dense_btree2_corder_debug(FILE *stream, int indent, int fwidth, const void *record,
+ const void *_udata);
/* v2 B-tree driver callbacks for 'name' index */
static herr_t H5G__dense_btree2_name_store(void *native, const void *udata);
static herr_t H5G__dense_btree2_name_compare(const void *rec1, const void *rec2, int *result);
-static herr_t H5G__dense_btree2_name_encode(uint8_t *raw, const void *native,
- void *ctx);
-static herr_t H5G__dense_btree2_name_decode(const uint8_t *raw, void *native,
- void *ctx);
-static herr_t H5G__dense_btree2_name_debug(FILE *stream, int indent, int fwidth,
- const void *record, const void *_udata);
+static herr_t H5G__dense_btree2_name_encode(uint8_t *raw, const void *native, void *ctx);
+static herr_t H5G__dense_btree2_name_decode(const uint8_t *raw, void *native, void *ctx);
+static herr_t H5G__dense_btree2_name_debug(FILE *stream, int indent, int fwidth, const void *record,
+ const void *_udata);
/* Fractal heap function callbacks */
static herr_t H5G__dense_fh_name_cmp(const void *obj, size_t obj_len, void *op_data);
-
/*********************/
/* Package Variables */
/*********************/
/* v2 B-tree class for indexing 'name' field of links */
-const H5B2_class_t H5G_BT2_NAME[1]={{ /* B-tree class information */
- H5B2_GRP_DENSE_NAME_ID, /* Type of B-tree */
- "H5B2_GRP_DENSE_NAME_ID", /* Name of B-tree class */
- sizeof(H5G_dense_bt2_name_rec_t), /* Size of native record */
- NULL, /* Create client callback context */
- NULL, /* Destroy client callback context */
- H5G__dense_btree2_name_store, /* Record storage callback */
- H5G__dense_btree2_name_compare, /* Record comparison callback */
- H5G__dense_btree2_name_encode, /* Record encoding callback */
- H5G__dense_btree2_name_decode, /* Record decoding callback */
- H5G__dense_btree2_name_debug /* Record debugging callback */
+const H5B2_class_t H5G_BT2_NAME[1] = {{
+ /* B-tree class information */
+ H5B2_GRP_DENSE_NAME_ID, /* Type of B-tree */
+ "H5B2_GRP_DENSE_NAME_ID", /* Name of B-tree class */
+ sizeof(H5G_dense_bt2_name_rec_t), /* Size of native record */
+ NULL, /* Create client callback context */
+ NULL, /* Destroy client callback context */
+ H5G__dense_btree2_name_store, /* Record storage callback */
+ H5G__dense_btree2_name_compare, /* Record comparison callback */
+ H5G__dense_btree2_name_encode, /* Record encoding callback */
+ H5G__dense_btree2_name_decode, /* Record decoding callback */
+ H5G__dense_btree2_name_debug /* Record debugging callback */
}};
/* v2 B-tree class for indexing 'creation order' field of links */
-const H5B2_class_t H5G_BT2_CORDER[1]={{ /* B-tree class information */
+const H5B2_class_t H5G_BT2_CORDER[1] = {{
+ /* B-tree class information */
H5B2_GRP_DENSE_CORDER_ID, /* Type of B-tree */
"H5B2_GRP_DENSE_CORDER_ID", /* Name of B-tree class */
sizeof(H5G_dense_bt2_corder_rec_t), /* Size of native record */
@@ -133,13 +125,10 @@ const H5B2_class_t H5G_BT2_CORDER[1]={{ /* B-tree class information */
/* Library Private Variables */
/*****************************/
-
/*******************/
/* Local Variables */
/*******************/
-
-
/*-------------------------------------------------------------------------
* Function: H5G__dense_fh_name_cmp
*
@@ -156,22 +145,23 @@ const H5B2_class_t H5G_BT2_CORDER[1]={{ /* B-tree class information */
static herr_t
H5G__dense_fh_name_cmp(const void *obj, size_t obj_len, void *_udata)
{
- H5G_fh_ud_cmp_t *udata = (H5G_fh_ud_cmp_t *)_udata; /* User data for 'op' callback */
- H5O_link_t *lnk; /* Pointer to link created from heap object */
- herr_t ret_value = SUCCEED; /* Return value */
+ H5G_fh_ud_cmp_t *udata = (H5G_fh_ud_cmp_t *)_udata; /* User data for 'op' callback */
+ H5O_link_t * lnk; /* Pointer to link created from heap object */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_STATIC
/* Decode link information */
- if(NULL == (lnk = (H5O_link_t *)H5O_msg_decode(udata->f, NULL, H5O_LINK_ID, obj_len, (const unsigned char *)obj)))
+ if (NULL == (lnk = (H5O_link_t *)H5O_msg_decode(udata->f, NULL, H5O_LINK_ID, obj_len,
+ (const unsigned char *)obj)))
HGOTO_ERROR(H5E_SYM, H5E_CANTDECODE, FAIL, "can't decode link")
/* Compare the string values */
udata->cmp = HDstrcmp(udata->name, lnk->name);
/* Check for correct link & callback to make */
- if(udata->cmp == 0 && udata->found_op) {
- if((udata->found_op)(lnk, udata->found_op_data) < 0)
+ if (udata->cmp == 0 && udata->found_op) {
+ if ((udata->found_op)(lnk, udata->found_op_data) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTOPERATE, FAIL, "link found callback failed")
} /* end if */
@@ -182,7 +172,6 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5G__dense_fh_name_cmp() */
-
/*-------------------------------------------------------------------------
* Function: H5G__dense_btree2_name_store
*
@@ -199,7 +188,7 @@ done:
static herr_t
H5G__dense_btree2_name_store(void *_nrecord, const void *_udata)
{
- const H5G_bt2_ud_ins_t *udata = (const H5G_bt2_ud_ins_t *)_udata;
+ const H5G_bt2_ud_ins_t * udata = (const H5G_bt2_ud_ins_t *)_udata;
H5G_dense_bt2_name_rec_t *nrecord = (H5G_dense_bt2_name_rec_t *)_nrecord;
FUNC_ENTER_STATIC_NOERR
@@ -211,7 +200,6 @@ H5G__dense_btree2_name_store(void *_nrecord, const void *_udata)
FUNC_LEAVE_NOAPI(SUCCEED)
} /* H5G__dense_btree2_name_store() */
-
/*-------------------------------------------------------------------------
* Function: H5G__dense_btree2_name_compare
*
@@ -229,9 +217,9 @@ H5G__dense_btree2_name_store(void *_nrecord, const void *_udata)
static herr_t
H5G__dense_btree2_name_compare(const void *_bt2_udata, const void *_bt2_rec, int *result)
{
- const H5G_bt2_ud_common_t *bt2_udata = (const H5G_bt2_ud_common_t *)_bt2_udata;
- const H5G_dense_bt2_name_rec_t *bt2_rec = (const H5G_dense_bt2_name_rec_t *)_bt2_rec;
- herr_t ret_value = SUCCEED; /* Return value */
+ const H5G_bt2_ud_common_t * bt2_udata = (const H5G_bt2_ud_common_t *)_bt2_udata;
+ const H5G_dense_bt2_name_rec_t *bt2_rec = (const H5G_dense_bt2_name_rec_t *)_bt2_rec;
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_STATIC
@@ -240,28 +228,28 @@ H5G__dense_btree2_name_compare(const void *_bt2_udata, const void *_bt2_rec, int
HDassert(bt2_rec);
/* Check hash value */
- if(bt2_udata->name_hash < bt2_rec->hash)
+ if (bt2_udata->name_hash < bt2_rec->hash)
*result = (-1);
- else if(bt2_udata->name_hash > bt2_rec->hash)
+ else if (bt2_udata->name_hash > bt2_rec->hash)
*result = 1;
else {
- H5G_fh_ud_cmp_t fh_udata; /* User data for fractal heap 'op' callback */
+ H5G_fh_ud_cmp_t fh_udata; /* User data for fractal heap 'op' callback */
/* Sanity check */
HDassert(bt2_udata->name_hash == bt2_rec->hash);
/* Prepare user data for callback */
/* down */
- fh_udata.f = bt2_udata->f;
- fh_udata.name = bt2_udata->name;
- fh_udata.found_op = bt2_udata->found_op;
+ fh_udata.f = bt2_udata->f;
+ fh_udata.name = bt2_udata->name;
+ fh_udata.found_op = bt2_udata->found_op;
fh_udata.found_op_data = bt2_udata->found_op_data;
/* up */
fh_udata.cmp = 0;
/* Check if the user's link and the B-tree's link have the same name */
- if(H5HF_op(bt2_udata->fheap, bt2_rec->id, H5G__dense_fh_name_cmp, &fh_udata) < 0)
+ if (H5HF_op(bt2_udata->fheap, bt2_rec->id, H5G__dense_fh_name_cmp, &fh_udata) < 0)
HGOTO_ERROR(H5E_HEAP, H5E_CANTCOMPARE, FAIL, "can't compare btree2 records")
/* Callback will set comparison value */
@@ -272,7 +260,6 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* H5G__dense_btree2_name_compare() */
-
/*-------------------------------------------------------------------------
* Function: H5G__dense_btree2_name_encode
*
@@ -300,7 +287,6 @@ H5G__dense_btree2_name_encode(uint8_t *raw, const void *_nrecord, void H5_ATTR_U
FUNC_LEAVE_NOAPI(SUCCEED)
} /* H5G__dense_btree2_name_encode() */
-
/*-------------------------------------------------------------------------
* Function: H5G__dense_btree2_name_decode
*
@@ -328,7 +314,6 @@ H5G__dense_btree2_name_decode(const uint8_t *raw, void *_nrecord, void H5_ATTR_U
FUNC_LEAVE_NOAPI(SUCCEED)
} /* H5G__dense_btree2_name_decode() */
-
/*-------------------------------------------------------------------------
* Function: H5G__dense_btree2_name_debug
*
@@ -343,23 +328,21 @@ H5G__dense_btree2_name_decode(const uint8_t *raw, void *_nrecord, void H5_ATTR_U
*-------------------------------------------------------------------------
*/
static herr_t
-H5G__dense_btree2_name_debug(FILE *stream, int indent, int fwidth,
- const void *_nrecord, const void H5_ATTR_UNUSED *_udata)
+H5G__dense_btree2_name_debug(FILE *stream, int indent, int fwidth, const void *_nrecord,
+ const void H5_ATTR_UNUSED *_udata)
{
const H5G_dense_bt2_name_rec_t *nrecord = (const H5G_dense_bt2_name_rec_t *)_nrecord;
- unsigned u; /* Local index variable */
+ unsigned u; /* Local index variable */
FUNC_ENTER_STATIC_NOERR
- HDfprintf(stream, "%*s%-*s {%x, ", indent, "", fwidth, "Record:",
- (unsigned)nrecord->hash);
- for(u = 0; u < H5G_DENSE_FHEAP_ID_LEN; u++)
+ HDfprintf(stream, "%*s%-*s {%x, ", indent, "", fwidth, "Record:", (unsigned)nrecord->hash);
+ for (u = 0; u < H5G_DENSE_FHEAP_ID_LEN; u++)
HDfprintf(stderr, "%02x%s", nrecord->id[u], (u < (H5G_DENSE_FHEAP_ID_LEN - 1) ? " " : "}\n"));
FUNC_LEAVE_NOAPI(SUCCEED)
} /* H5G__dense_btree2_name_debug() */
-
/*-------------------------------------------------------------------------
* Function: H5G__dense_btree2_corder_store
*
@@ -376,7 +359,7 @@ H5G__dense_btree2_name_debug(FILE *stream, int indent, int fwidth,
static herr_t
H5G__dense_btree2_corder_store(void *_nrecord, const void *_udata)
{
- const H5G_bt2_ud_ins_t *udata = (const H5G_bt2_ud_ins_t *)_udata;
+ const H5G_bt2_ud_ins_t * udata = (const H5G_bt2_ud_ins_t *)_udata;
H5G_dense_bt2_corder_rec_t *nrecord = (H5G_dense_bt2_corder_rec_t *)_nrecord;
FUNC_ENTER_STATIC_NOERR
@@ -388,7 +371,6 @@ H5G__dense_btree2_corder_store(void *_nrecord, const void *_udata)
FUNC_LEAVE_NOAPI(SUCCEED)
} /* H5G__dense_btree2_corder_store() */
-
/*-------------------------------------------------------------------------
* Function: H5G__dense_btree2_corder_compare
*
@@ -406,8 +388,8 @@ H5G__dense_btree2_corder_store(void *_nrecord, const void *_udata)
static herr_t
H5G__dense_btree2_corder_compare(const void *_bt2_udata, const void *_bt2_rec, int *result)
{
- const H5G_bt2_ud_common_t *bt2_udata = (const H5G_bt2_ud_common_t *)_bt2_udata;
- const H5G_dense_bt2_corder_rec_t *bt2_rec = (const H5G_dense_bt2_corder_rec_t *)_bt2_rec;
+ const H5G_bt2_ud_common_t * bt2_udata = (const H5G_bt2_ud_common_t *)_bt2_udata;
+ const H5G_dense_bt2_corder_rec_t *bt2_rec = (const H5G_dense_bt2_corder_rec_t *)_bt2_rec;
FUNC_ENTER_STATIC_NOERR
@@ -416,9 +398,9 @@ H5G__dense_btree2_corder_compare(const void *_bt2_udata, const void *_bt2_rec, i
HDassert(bt2_rec);
/* Check creation order value */
- if(bt2_udata->corder < bt2_rec->corder)
+ if (bt2_udata->corder < bt2_rec->corder)
*result = -1;
- else if(bt2_udata->corder > bt2_rec->corder)
+ else if (bt2_udata->corder > bt2_rec->corder)
*result = 1;
else
*result = 0;
@@ -426,7 +408,6 @@ H5G__dense_btree2_corder_compare(const void *_bt2_udata, const void *_bt2_rec, i
FUNC_LEAVE_NOAPI(SUCCEED)
} /* H5G__dense_btree2_corder_compare() */
-
/*-------------------------------------------------------------------------
* Function: H5G__dense_btree2_corder_encode
*
@@ -454,7 +435,6 @@ H5G__dense_btree2_corder_encode(uint8_t *raw, const void *_nrecord, void H5_ATTR
FUNC_LEAVE_NOAPI(SUCCEED)
} /* H5G__dense_btree2_corder_encode() */
-
/*-------------------------------------------------------------------------
* Function: H5G__dense_btree2_corder_decode
*
@@ -482,7 +462,6 @@ H5G__dense_btree2_corder_decode(const uint8_t *raw, void *_nrecord, void H5_ATTR
FUNC_LEAVE_NOAPI(SUCCEED)
} /* H5G__dense_btree2_corder_decode() */
-
/*-------------------------------------------------------------------------
* Function: H5G__dense_btree2_corder_debug
*
@@ -497,19 +476,17 @@ H5G__dense_btree2_corder_decode(const uint8_t *raw, void *_nrecord, void H5_ATTR
*-------------------------------------------------------------------------
*/
static herr_t
-H5G__dense_btree2_corder_debug(FILE *stream, int indent, int fwidth,
- const void *_nrecord, const void H5_ATTR_UNUSED *_udata)
+H5G__dense_btree2_corder_debug(FILE *stream, int indent, int fwidth, const void *_nrecord,
+ const void H5_ATTR_UNUSED *_udata)
{
const H5G_dense_bt2_corder_rec_t *nrecord = (const H5G_dense_bt2_corder_rec_t *)_nrecord;
- unsigned u; /* Local index variable */
+ unsigned u; /* Local index variable */
FUNC_ENTER_STATIC_NOERR
- HDfprintf(stream, "%*s%-*s {%llu, ", indent, "", fwidth, "Record:",
- (unsigned long long)nrecord->corder);
- for(u = 0; u < H5G_DENSE_FHEAP_ID_LEN; u++)
+ HDfprintf(stream, "%*s%-*s {%llu, ", indent, "", fwidth, "Record:", (unsigned long long)nrecord->corder);
+ for (u = 0; u < H5G_DENSE_FHEAP_ID_LEN; u++)
HDfprintf(stderr, "%02x%s", nrecord->id[u], (u < (H5G_DENSE_FHEAP_ID_LEN - 1) ? " " : "}\n"));
FUNC_LEAVE_NOAPI(SUCCEED)
} /* H5G__dense_btree2_corder_debug() */
-