summaryrefslogtreecommitdiffstats
path: root/src/H5B2int.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2006-10-02 10:24:03 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2006-10-02 10:24:03 (GMT)
commita6f6462541cc57364586f770131e2ea074d63492 (patch)
tree0debf502fb7d66f9f470edb935a62223945960d4 /src/H5B2int.c
parent9bc29ea538b9ce2013a8cde5be230c18cf052009 (diff)
downloadhdf5-a6f6462541cc57364586f770131e2ea074d63492.zip
hdf5-a6f6462541cc57364586f770131e2ea074d63492.tar.gz
hdf5-a6f6462541cc57364586f770131e2ea074d63492.tar.bz2
[svn-r12700] Alert:
File format is not stable, don't keep files produced! Description: First stage of checkins modifying the format of groups to support creation order. Implement "dense" storage for links in groups. Try to clarify some of the symbols for the H5L API. Add the H5Pset_latest_format() flag for FAPLs, to choose to use the newest file format options (including "dense" link storage in groups) Add the H5Pset_track_creation_order() flag for GCPLs, to enable creation order tracking in groups (although no index on creation order yet). Remove --enable-group-revision configure flag, as file format issues are now handled in a backwardly/forwardly compatible way. Clean up lots of compiler warnings and other minor formatting issues. Tested on: FreeBSD/32 4.11 (sleipnir) w/threadsafe Linux/32 2.4 (heping) w/FORTRAN & C++ Linux/64 2.4 (mir) w/enable-v1.6 compa Mac OSX/32 10.4.8 (amazon) AIX 5.3 (copper) w/parallel & FORTRAN
Diffstat (limited to 'src/H5B2int.c')
-rw-r--r--src/H5B2int.c50
1 files changed, 36 insertions, 14 deletions
diff --git a/src/H5B2int.c b/src/H5B2int.c
index e974583..e97487d 100644
--- a/src/H5B2int.c
+++ b/src/H5B2int.c
@@ -2115,12 +2115,13 @@ H5B2_iterate_node(H5F_t *f, hid_t dxpl_id, H5RC_t *bt2_shared, unsigned depth,
const H5B2_node_ptr_t *curr_node, H5B2_operator_t op, void *op_data)
{
H5B2_shared_t *shared; /* Pointer to B-tree's shared information */
- const H5AC_class_t *curr_node_class=NULL; /* Pointer to current node's class info */
- void *node=NULL; /* Pointers to current node */
- uint8_t *native; /* Pointers to node's native records */
- H5B2_node_ptr_t *node_ptrs=NULL; /* Pointers to node's node pointers */
+ const H5AC_class_t *curr_node_class = NULL; /* Pointer to current node's class info */
+ void *node = NULL; /* Pointers to current node */
+ uint8_t *node_native; /* Pointers to node's native records */
+ uint8_t *native = NULL; /* Pointers to copy of node's native records */
+ H5B2_node_ptr_t *node_ptrs = NULL; /* Pointers to node's node pointers */
unsigned u; /* Local index */
- herr_t ret_value = H5B2_ITER_CONT;
+ herr_t ret_value = H5B2_ITER_CONT; /* Iterator return value */
FUNC_ENTER_NOAPI_NOINIT(H5B2_iterate_node)
@@ -2145,8 +2146,14 @@ H5B2_iterate_node(H5F_t *f, hid_t dxpl_id, H5RC_t *bt2_shared, unsigned depth,
/* Set up information about current node */
curr_node_class = H5AC_BT2_INT;
node = internal;
- native = internal->int_native;
- node_ptrs = internal->node_ptrs;
+ node_native = internal->int_native;
+
+ /* Allocate space for the node pointers in memory */
+ if((node_ptrs = H5FL_FAC_MALLOC(shared->node_info[depth].node_ptr_fac)) == NULL)
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for B-tree internal node pointers")
+
+ /* Copy the node pointers */
+ HDmemcpy(node_ptrs, internal->node_ptrs, (sizeof(H5B2_node_ptr_t) * (curr_node->node_nrec + 1)));
} /* end if */
else {
H5B2_leaf_t *leaf; /* Pointer to leaf node */
@@ -2158,9 +2165,21 @@ H5B2_iterate_node(H5F_t *f, hid_t dxpl_id, H5RC_t *bt2_shared, unsigned depth,
/* Set up information about current node */
curr_node_class = H5AC_BT2_LEAF;
node = leaf;
- native = leaf->leaf_native;
+ node_native = leaf->leaf_native;
} /* end else */
+ /* Allocate space for the native keys in memory */
+ if((native = H5FL_FAC_MALLOC(shared->node_info[depth].nat_rec_fac)) == NULL)
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for B-tree internal native keys")
+
+ /* Copy the native keys */
+ HDmemcpy(native, node_native, (shared->type->nrec_size * curr_node->node_nrec));
+
+ /* Unlock the node */
+ if(H5AC_unprotect(f, dxpl_id, curr_node_class, curr_node->addr, node, H5AC__NO_FLAGS_SET) < 0)
+ HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node")
+ node = NULL;
+
/* Iterate through records, in order */
for(u = 0; u < curr_node->node_nrec && !ret_value; u++) {
/* Descend into child node, if current node is an internal node */
@@ -2170,8 +2189,10 @@ H5B2_iterate_node(H5F_t *f, hid_t dxpl_id, H5RC_t *bt2_shared, unsigned depth,
} /* end if */
/* Make callback for current record */
- if((ret_value = (op)(H5B2_NAT_NREC(native, shared, u), op_data)) < 0)
- HGOTO_ERROR(H5E_BTREE, H5E_CANTLIST, FAIL, "iterator function failed")
+ if(!ret_value) {
+ if((ret_value = (op)(H5B2_NAT_NREC(native, shared, u), op_data)) < 0)
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTLIST, FAIL, "iterator function failed")
+ } /* end if */
} /* end for */
/* Descend into last child node, if current node is an internal node */
@@ -2181,10 +2202,11 @@ H5B2_iterate_node(H5F_t *f, hid_t dxpl_id, H5RC_t *bt2_shared, unsigned depth,
} /* end if */
done:
- /* Unlock current node */
- if(node)
- if(H5AC_unprotect(f, dxpl_id, curr_node_class, curr_node->addr, node, H5AC__NO_FLAGS_SET) < 0)
- HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node")
+ /* Release the node pointers & native records, if they were copied */
+ if(node_ptrs)
+ H5FL_FAC_FREE(shared->node_info[depth].node_ptr_fac, node_ptrs);
+ if(native)
+ H5FL_FAC_FREE(shared->node_info[depth].nat_rec_fac, native);
FUNC_LEAVE_NOAPI(ret_value)
} /* H5B2_iterate_node() */