summaryrefslogtreecommitdiffstats
path: root/src/H5Dbtree.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/H5Dbtree.c')
-rw-r--r--src/H5Dbtree.c92
1 files changed, 46 insertions, 46 deletions
diff --git a/src/H5Dbtree.c b/src/H5Dbtree.c
index 8177e13..098e01b 100644
--- a/src/H5Dbtree.c
+++ b/src/H5Dbtree.c
@@ -39,6 +39,7 @@
#include "H5FLprivate.h" /* Free Lists */
#include "H5Iprivate.h" /* IDs */
#include "H5MFprivate.h" /* File space management */
+#include "H5MMprivate.h" /* Memory management */
#include "H5Oprivate.h" /* Object headers */
#include "H5Sprivate.h" /* Dataspaces */
#include "H5VMprivate.h" /* Vector and array functions */
@@ -95,23 +96,22 @@ static herr_t H5D__btree_shared_create(const H5F_t *f, H5O_storage_chunk_t *stor
const H5O_layout_chunk_t *layout);
/* B-tree iterator callbacks */
-static int H5D__btree_idx_iterate_cb(H5F_t *f, hid_t dxpl_id, const void *left_key,
+static int H5D__btree_idx_iterate_cb(H5F_t *f, const void *left_key,
haddr_t addr, const void *right_key, void *_udata);
/* B-tree callbacks */
static H5UC_t *H5D__btree_get_shared(const H5F_t *f, const void *_udata);
-static herr_t H5D__btree_new_node(H5F_t *f, hid_t dxpl_id, H5B_ins_t, void *_lt_key,
+static herr_t H5D__btree_new_node(H5F_t *f, H5B_ins_t, void *_lt_key,
void *_udata, void *_rt_key, haddr_t *addr_p /*out*/);
static int H5D__btree_cmp2(void *_lt_key, void *_udata, void *_rt_key);
static int H5D__btree_cmp3(void *_lt_key, void *_udata, void *_rt_key);
-static htri_t H5D__btree_found(H5F_t *f, hid_t dxpl_id, haddr_t addr,
+static htri_t H5D__btree_found(H5F_t *f, haddr_t addr,
const void *_lt_key, void *_udata);
-static H5B_ins_t H5D__btree_insert(H5F_t *f, hid_t dxpl_id, haddr_t addr,
+static H5B_ins_t H5D__btree_insert(H5F_t *f, haddr_t addr,
void *_lt_key, hbool_t *lt_key_changed, void *_md_key, void *_udata,
void *_rt_key, hbool_t *rt_key_changed, haddr_t *new_node/*out*/);
-static H5B_ins_t H5D__btree_remove( H5F_t *f, hid_t dxpl_id, haddr_t addr,
- void *_lt_key, hbool_t *lt_key_changed, void *_udata, void *_rt_key,
- hbool_t *rt_key_changed);
+static H5B_ins_t H5D__btree_remove( H5F_t *f, haddr_t addr, void *_lt_key,
+ hbool_t *lt_key_changed, void *_udata, void *_rt_key, hbool_t *rt_key_changed);
static herr_t H5D__btree_decode_key(const H5B_shared_t *shared, const uint8_t *raw,
void *_key);
static herr_t H5D__btree_encode_key(const H5B_shared_t *shared, uint8_t *raw,
@@ -136,7 +136,7 @@ static herr_t H5D__btree_idx_delete(const H5D_chk_idx_info_t *idx_info);
static herr_t H5D__btree_idx_copy_setup(const H5D_chk_idx_info_t *idx_info_src,
const H5D_chk_idx_info_t *idx_info_dst);
static herr_t H5D__btree_idx_copy_shutdown(H5O_storage_chunk_t *storage_src,
- H5O_storage_chunk_t *storage_dst, hid_t dxpl_id);
+ H5O_storage_chunk_t *storage_dst);
static herr_t H5D__btree_idx_size(const H5D_chk_idx_info_t *idx_info,
hsize_t *size);
static herr_t H5D__btree_idx_reset(H5O_storage_chunk_t *storage, hbool_t reset_addr);
@@ -253,9 +253,8 @@ H5D__btree_get_shared(const H5F_t H5_ATTR_UNUSED *f, const void *_udata)
*-------------------------------------------------------------------------
*/
static herr_t
-H5D__btree_new_node(H5F_t *f, hid_t H5_ATTR_UNUSED dxpl_id, H5B_ins_t op,
- void *_lt_key, void *_udata, void *_rt_key,
- haddr_t *addr_p/*out*/)
+H5D__btree_new_node(H5F_t H5_ATTR_NDEBUG_UNUSED *f, H5B_ins_t op, void *_lt_key, void *_udata,
+ void *_rt_key, haddr_t *addr_p/*out*/)
{
H5D_btree_key_t *lt_key = (H5D_btree_key_t *) _lt_key;
H5D_btree_key_t *rt_key = (H5D_btree_key_t *) _rt_key;
@@ -438,8 +437,8 @@ H5D__btree_cmp3(void *_lt_key, void *_udata, void *_rt_key)
*-------------------------------------------------------------------------
*/
static htri_t
-H5D__btree_found(H5F_t H5_ATTR_UNUSED *f, hid_t H5_ATTR_UNUSED dxpl_id, haddr_t addr, const void *_lt_key,
- void *_udata)
+H5D__btree_found(H5F_t H5_ATTR_UNUSED *f, haddr_t addr, const void *_lt_key,
+ void *_udata)
{
H5D_chunk_ud_t *udata = (H5D_chunk_ud_t *) _udata;
const H5D_btree_key_t *lt_key = (const H5D_btree_key_t *) _lt_key;
@@ -537,11 +536,9 @@ done:
*-------------------------------------------------------------------------
*/
static H5B_ins_t
-H5D__btree_insert(H5F_t *f, hid_t H5_ATTR_UNUSED dxpl_id, haddr_t addr, void *_lt_key,
- hbool_t *lt_key_changed,
- void *_md_key, void *_udata, void *_rt_key,
- hbool_t H5_ATTR_UNUSED *rt_key_changed,
- haddr_t *new_node_p/*out*/)
+H5D__btree_insert(H5F_t H5_ATTR_NDEBUG_UNUSED *f, haddr_t H5_ATTR_NDEBUG_UNUSED addr, void *_lt_key, hbool_t *lt_key_changed,
+ void *_md_key, void *_udata, void *_rt_key, hbool_t H5_ATTR_UNUSED *rt_key_changed,
+ haddr_t *new_node_p/*out*/)
{
H5D_btree_key_t *lt_key = (H5D_btree_key_t *) _lt_key;
H5D_btree_key_t *md_key = (H5D_btree_key_t *) _md_key;
@@ -630,7 +627,7 @@ done:
*-------------------------------------------------------------------------
*/
static H5B_ins_t
-H5D__btree_remove(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_lt_key /*in,out */ ,
+H5D__btree_remove(H5F_t *f, haddr_t addr, void *_lt_key /*in,out */ ,
hbool_t *lt_key_changed /*out */ ,
void H5_ATTR_UNUSED * _udata /*in,out */ ,
void H5_ATTR_UNUSED * _rt_key /*in,out */ ,
@@ -643,7 +640,7 @@ H5D__btree_remove(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_lt_key /*in,out
/* Remove raw data chunk from file */
H5_CHECK_OVERFLOW(lt_key->nbytes, uint32_t, hsize_t);
- if(H5MF_xfree(f, H5FD_MEM_DRAW, dxpl_id, addr, (hsize_t)lt_key->nbytes) < 0)
+ if(H5MF_xfree(f, H5FD_MEM_DRAW, addr, (hsize_t)lt_key->nbytes) < 0)
HGOTO_ERROR(H5E_STORAGE, H5E_CANTFREE, H5B_INS_ERROR, "unable to free chunk")
/* Mark keys as unchanged */
@@ -670,12 +667,13 @@ done:
static herr_t
H5D__btree_decode_key(const H5B_shared_t *shared, const uint8_t *raw, void *_key)
{
- const H5O_layout_chunk_t *layout; /* Chunk layout description */
- H5D_btree_key_t *key = (H5D_btree_key_t *) _key; /* Pointer to decoded key */
- hsize_t tmp_offset; /* Temporary coordinate offset, from file */
- unsigned u; /* Local index variable */
+ const H5O_layout_chunk_t *layout; /* Chunk layout description */
+ H5D_btree_key_t *key = (H5D_btree_key_t *) _key; /* Pointer to decoded key */
+ hsize_t tmp_offset; /* Temporary coordinate offset, from file */
+ unsigned u; /* Local index variable */
+ herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_STATIC_NOERR
+ FUNC_ENTER_STATIC
/* check args */
HDassert(shared);
@@ -689,15 +687,19 @@ H5D__btree_decode_key(const H5B_shared_t *shared, const uint8_t *raw, void *_key
UINT32DECODE(raw, key->nbytes);
UINT32DECODE(raw, key->filter_mask);
for(u = 0; u < layout->ndims; u++) {
+ if(layout->dim[u] == 0)
+ HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, FAIL, "chunk size must be > 0, dim = %u ", u)
+
/* Retrieve coordinate offset */
- UINT64DECODE(raw, tmp_offset);
+ UINT64DECODE(raw, tmp_offset);
HDassert(0 == (tmp_offset % layout->dim[u]));
/* Convert to a scaled offset */
key->scaled[u] = tmp_offset / layout->dim[u];
} /* end for */
- FUNC_LEAVE_NOAPI(SUCCEED)
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
} /* end H5D__btree_decode_key() */
@@ -846,7 +848,7 @@ H5D__btree_shared_create(const H5F_t *f, H5O_storage_chunk_t *store,
/* Set up the "local" information for this dataset's chunks */
if(NULL == (my_layout = H5FL_MALLOC(H5O_layout_chunk_t)))
HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "can't allocate chunk layout")
- HDmemcpy(my_layout, layout, sizeof(H5O_layout_chunk_t));
+ H5MM_memcpy(my_layout, layout, sizeof(H5O_layout_chunk_t));
shared->udata = my_layout;
/* Make shared B-tree info reference counted */
@@ -940,8 +942,8 @@ H5D__btree_idx_create(const H5D_chk_idx_info_t *idx_info)
udata.storage = idx_info->storage;
/* Create the v1 B-tree for the chunk index */
- if(H5B_create(idx_info->f, idx_info->dxpl_id, H5B_BTREE, &udata, &(idx_info->storage->idx_addr)/*out*/) < 0)
- HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't create B-tree")
+ if(H5B_create(idx_info->f, H5B_BTREE, &udata, &(idx_info->storage->idx_addr)/*out*/) < 0)
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't create B-tree")
done:
FUNC_LEAVE_NOAPI(ret_value)
@@ -1004,7 +1006,7 @@ H5D__btree_idx_insert(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *udata,
* Create the chunk it if it doesn't exist, or reallocate the chunk if
* its size changed.
*/
- if(H5B_insert(idx_info->f, idx_info->dxpl_id, H5B_BTREE, idx_info->storage->idx_addr, udata) < 0)
+ if(H5B_insert(idx_info->f, H5B_BTREE, idx_info->storage->idx_addr, udata) < 0)
HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "unable to allocate chunk")
done:
@@ -1043,7 +1045,7 @@ H5D__btree_idx_get_addr(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *udat
HDassert(udata);
/* Go get the chunk information from the B-tree */
- if(H5B_find(idx_info->f, idx_info->dxpl_id, H5B_BTREE, idx_info->storage->idx_addr, udata) < 0)
+ if(H5B_find(idx_info->f, H5B_BTREE, idx_info->storage->idx_addr, udata) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get chunk info")
done:
@@ -1067,9 +1069,8 @@ done:
*-------------------------------------------------------------------------
*/
static int
-H5D__btree_idx_iterate_cb(H5F_t H5_ATTR_UNUSED *f, hid_t H5_ATTR_UNUSED dxpl_id,
- const void *_lt_key, haddr_t addr, const void H5_ATTR_UNUSED *_rt_key,
- void *_udata)
+H5D__btree_idx_iterate_cb(H5F_t H5_ATTR_UNUSED *f, const void *_lt_key,
+ haddr_t addr, const void H5_ATTR_UNUSED *_rt_key, void *_udata)
{
H5D_btree_it_ud_t *udata = (H5D_btree_it_ud_t *)_udata; /* User data */
const H5D_btree_key_t *lt_key = (const H5D_btree_key_t *)_lt_key; /* B-tree key for chunk */
@@ -1087,7 +1088,7 @@ H5D__btree_idx_iterate_cb(H5F_t H5_ATTR_UNUSED *f, hid_t H5_ATTR_UNUSED dxpl_id,
HDcompile_assert(sizeof(chunk_rec.filter_mask) == sizeof(lt_key->filter_mask));
/* Compose generic chunk record for callback */
- HDmemcpy(&chunk_rec, lt_key, sizeof(*lt_key));
+ H5MM_memcpy(&chunk_rec, lt_key, sizeof(*lt_key));
chunk_rec.chunk_addr = addr;
/* Make "generic chunk" callback */
@@ -1137,7 +1138,7 @@ H5D__btree_idx_iterate(const H5D_chk_idx_info_t *idx_info,
udata.udata = chunk_udata;
/* Iterate over existing chunks */
- if((ret_value = H5B_iterate(idx_info->f, idx_info->dxpl_id, H5B_BTREE, idx_info->storage->idx_addr, H5D__btree_idx_iterate_cb, &udata)) < 0)
+ if((ret_value = H5B_iterate(idx_info->f, H5B_BTREE, idx_info->storage->idx_addr, H5D__btree_idx_iterate_cb, &udata)) < 0)
HERROR(H5E_DATASET, H5E_BADITER, "unable to iterate over chunk B-tree");
FUNC_LEAVE_NOAPI(ret_value)
@@ -1174,7 +1175,7 @@ H5D__btree_idx_remove(const H5D_chk_idx_info_t *idx_info, H5D_chunk_common_ud_t
/* Remove the chunk from the v1 B-tree index and release the space for the
* chunk (in the B-tree callback).
*/
- if(H5B_remove(idx_info->f, idx_info->dxpl_id, H5B_BTREE, idx_info->storage->idx_addr, udata) < 0)
+ if(H5B_remove(idx_info->f, H5B_BTREE, idx_info->storage->idx_addr, udata) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTDELETE, FAIL, "unable to remove chunk entry")
done:
@@ -1228,7 +1229,7 @@ H5D__btree_idx_delete(const H5D_chk_idx_info_t *idx_info)
udata.storage = &tmp_storage;
/* Delete entire B-tree */
- if(H5B_delete(idx_info->f, idx_info->dxpl_id, H5B_BTREE, tmp_storage.idx_addr, &udata) < 0)
+ if(H5B_delete(idx_info->f, H5B_BTREE, tmp_storage.idx_addr, &udata) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTDELETE, FAIL, "unable to delete chunk B-tree")
/* Release the shared B-tree page */
@@ -1261,7 +1262,7 @@ H5D__btree_idx_copy_setup(const H5D_chk_idx_info_t *idx_info_src,
{
herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_STATIC_TAG(idx_info_dst->dxpl_id, H5AC__COPIED_TAG, FAIL)
+ FUNC_ENTER_STATIC_TAG(H5AC__COPIED_TAG)
HDassert(idx_info_src);
HDassert(idx_info_src->f);
@@ -1287,7 +1288,7 @@ H5D__btree_idx_copy_setup(const H5D_chk_idx_info_t *idx_info_src,
HDassert(H5F_addr_defined(idx_info_dst->storage->idx_addr));
done:
- FUNC_LEAVE_NOAPI_TAG(ret_value, FAIL)
+ FUNC_LEAVE_NOAPI_TAG(ret_value)
} /* end H5D__btree_idx_copy_setup() */
@@ -1305,8 +1306,7 @@ done:
*/
static herr_t
H5D__btree_idx_copy_shutdown(H5O_storage_chunk_t *storage_src,
- H5O_storage_chunk_t *storage_dst,
- hid_t H5_ATTR_UNUSED dxpl_id)
+ H5O_storage_chunk_t *storage_dst)
{
herr_t ret_value = SUCCEED; /* Return value */
@@ -1362,7 +1362,7 @@ H5D__btree_idx_size(const H5D_chk_idx_info_t *idx_info, hsize_t *index_size)
udata.storage = idx_info->storage;
/* Get metadata information for B-tree */
- if(H5B_get_info(idx_info->f, idx_info->dxpl_id, H5B_BTREE, idx_info->storage->idx_addr, &bt_info, NULL, &udata) < 0)
+ if(H5B_get_info(idx_info->f, H5B_BTREE, idx_info->storage->idx_addr, &bt_info, NULL, &udata) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL, "unable to iterate over chunk B-tree")
/* Set the size of the B-tree */
@@ -1476,7 +1476,7 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5D_btree_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE * stream, int indent,
+H5D_btree_debug(H5F_t *f, haddr_t addr, FILE * stream, int indent,
int fwidth, unsigned ndims, const uint32_t *dim)
{
H5D_btree_dbg_t udata; /* User data for B-tree callback */
@@ -1510,7 +1510,7 @@ H5D_btree_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE * stream, int indent
udata.ndims = ndims;
/* Dump the records for the B-tree */
- (void)H5B_debug(f, dxpl_id, addr, stream, indent, fwidth, H5B_BTREE, &udata);
+ (void)H5B_debug(f, addr, stream, indent, fwidth, H5B_BTREE, &udata);
done:
if(shared_init) {