summaryrefslogtreecommitdiffstats
path: root/src/H5B.c
diff options
context:
space:
mode:
authorRobb Matzke <matzke@llnl.gov>1997-08-15 16:51:34 (GMT)
committerRobb Matzke <matzke@llnl.gov>1997-08-15 16:51:34 (GMT)
commitbc2b9d9dea6271a46cdfb12913d73d0cd7675607 (patch)
tree41ac2d41fd86a39ae969610fefde057474f50f8e /src/H5B.c
parent9c6f65ec241eb2941e2af399385d7c7b62edac04 (diff)
downloadhdf5-bc2b9d9dea6271a46cdfb12913d73d0cd7675607.zip
hdf5-bc2b9d9dea6271a46cdfb12913d73d0cd7675607.tar.gz
hdf5-bc2b9d9dea6271a46cdfb12913d73d0cd7675607.tar.bz2
[svn-r35] ./src/H5ACproto.h
./src/H5Aproto.h ./src/H5Bproto.h ./src/H5Cproto.h ./src/H5Dproto.h ./src/H5Eproto.h ./src/H5Fproto.h ./src/H5Gproto.h ./src/H5Hproto.h ./src/H5MFproto.h ./src/H5MMproto.h ./src/H5Mproto.h ./src/H5Oproto.h ./src/H5Pproto.h ./src/H5Tproto.h ./src/H5proto.h These files were removed from the library and renamed by changing `proto' to `public'. ./src/H5ACpublic.h NEW ./src/H5Apublic.h NEW ./src/H5Bpublic.h NEW ./src/H5Cpublic.h NEW ./src/H5Dpublic.h NEW ./src/H5Epublic.h NEW ./src/H5Fpublic.h NEW ./src/H5Gpublic.h NEW ./src/H5Hpublic.h NEW ./src/H5MFpublic.h NEW ./src/H5MMpublic.h NEW ./src/H5Mpublic.h NEW ./src/H5Opublic.h NEW ./src/H5Ppublic.h NEW ./src/H5Tpublic.h NEW ./src/H5public.h NEW These files came from the old H5*proto.h files. ./src/Makefile ./src/Makefile.in NEW Removed. Now generated automatically from Makefile.in by running configure. ./src/h5oplat.h ./src/hdf5fort.h ./src/hdf5gen.h ./src/hdf5glob.h ./src/hdf5lims.h ./src/hdf5meta.h ./src/hdf5pabl.h ./src/hdf5plat.h ./src/hdf5port.h ./src/hdf5type.h Removed. The contents of these files has moved to other header files or source files depending on it's nature. ./src/H5.c ./src/H5A.c ./src/H5B.c ./src/H5C.c ./src/H5D.c ./src/H5E.c ./src/H5F.c ./src/H5G.c ./src/H5H.c ./src/H5M.c ./src/H5MF.c ./src/H5MM.c ./src/H5O.c ./src/H5Ocont.c ./src/H5Oname.c ./src/H5Onull.c ./src/H5Ostab.c ./src/H5P.c ./src/H5T.c Fixed include files. Moved some things from old headers into these files. ./src/H5ACprivate.h ./src/H5Aprivate.h ./src/H5Bprivate.h ./src/H5Cprivate.h ./src/H5Dprivate.h ./src/H5Eprivate.h ./src/H5Fprivate.h ./src/H5Gprivate.h ./src/H5Hprivate.h ./src/H5MFprivate.h ./src/H5MMprivate.h ./src/H5Mprivate.h ./src/H5Oprivate.h ./src/H5Pprivate.h ./src/H5Tprivate.h ./src/H5private.h ./src/debug.c Fixed include files. ./src/hdf5.h This is now the top-level *PUBLIC* include file. It should never appear in the library *.c files.
Diffstat (limited to 'src/H5B.c')
-rw-r--r--src/H5B.c132
1 files changed, 53 insertions, 79 deletions
diff --git a/src/H5B.c b/src/H5B.c
index e932dc7..b09e3bc 100644
--- a/src/H5B.c
+++ b/src/H5B.c
@@ -86,36 +86,17 @@
*
*-------------------------------------------------------------------------
*/
-
-/*
- * Define this if the root address of a B-link tree should never change.
- *
- * If this isn't defined and the root node of a tree splits, then the
- * new root (which points to the old root plus the new node from the
- * split) will be at a new file address.
- *
- * But if this is defined, then the old root will be copied to a new
- * location and the new root will occupy the file memory vacated by the
- * old root.
- */
-#define H5B_ANCHOR_ROOT
-
-/* system headers */
-#include <assert.h>
-#include "hdf5.h"
-
/* private headers */
-#include "H5private.h" /*library */
-#include "H5ACprivate.h" /*cache */
-#include "H5Bprivate.h" /*B-link trees */
-#include "H5MFprivate.h" /*File memory management */
-#include "H5MMprivate.h" /*Core memory management */
+#include <H5private.h> /*library */
+#include <H5ACprivate.h> /*cache */
+#include <H5Bprivate.h> /*B-link trees */
+#include <H5Eprivate.h> /*error handling */
+#include <H5MFprivate.h> /*File memory management */
+#include <H5MMprivate.h> /*Core memory management */
#define PABLO_MASK H5B_mask
#define BOUND(MIN,X,MAX) ((X)<(MIN)?(MIN):((X)>(MAX)?(MAX):(X)))
-#define false 0
-#define true 1
/* PRIVATE PROTOTYPES */
static haddr_t H5B_insert_helper (hdf5_file_t *f, haddr_t addr,
@@ -784,10 +765,13 @@ haddr_t
H5B_insert (hdf5_file_t *f, const H5B_class_t *type, haddr_t addr, void *udata)
{
uint8 lt_key[256], md_key[256], rt_key[256];
- intn lt_key_changed=false, rt_key_changed=false;
+ intn lt_key_changed=FALSE, rt_key_changed=FALSE;
haddr_t child, new_root;
intn level;
H5B_t *bt;
+ size_t size;
+ uint8 *buf;
+ haddr_t tmp_addr;
FUNC_ENTER (H5B_insert, NULL, FAIL);
@@ -829,62 +813,52 @@ H5B_insert (hdf5_file_t *f, const H5B_class_t *type, haddr_t addr, void *udata)
memcpy (rt_key, bt->key[bt->nchildren].nkey, type->sizeof_nkey);
}
-#ifdef H5B_ANCHOR_ROOT
- {
- /*
- * Copy the old root node to some other file location and make the new
- * root at the old root's previous address. This prevents the B-tree
- * from "moving".
- */
- size_t size = H5B_nodesize (f, type, NULL, bt->sizeof_rkey);
- uint8 *buf = H5MM_xmalloc (size);
- haddr_t tmp_addr = H5MF_alloc (f, size);
-
- if (tmp_addr<0) {
- HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL);
- }
- if (H5AC_flush (f, H5AC_BT, addr, FALSE)<0) {
- HRETURN_ERROR (H5E_BTREE, H5E_CANTFLUSH, FAIL);
- }
- if (H5F_block_read (f, addr, size, buf)<0) {
- HRETURN_ERROR (H5E_BTREE, H5E_READERROR, FAIL);
- }
- if (H5F_block_write (f, tmp_addr, size, buf)<0) {
- HRETURN_ERROR (H5E_BTREE, H5E_WRITEERROR, FAIL);
- }
- if (H5AC_rename (f, H5AC_BT, addr, tmp_addr)<0) {
- HRETURN_ERROR (H5E_BTREE, H5E_CANTSPLIT, FAIL);
- }
+ /*
+ * Copy the old root node to some other file location and make the new
+ * root at the old root's previous address. This prevents the B-tree
+ * from "moving".
+ */
+ size = H5B_nodesize (f, type, NULL, bt->sizeof_rkey);
+ buf = H5MM_xmalloc (size);
+ tmp_addr = H5MF_alloc (f, size);
- buf = H5MM_xfree (buf);
- new_root = addr;
- addr = tmp_addr;
+ if (tmp_addr<0) {
+ HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL);
+ }
+ if (H5AC_flush (f, H5AC_BT, addr, FALSE)<0) {
+ HRETURN_ERROR (H5E_BTREE, H5E_CANTFLUSH, FAIL);
+ }
+ if (H5F_block_read (f, addr, size, buf)<0) {
+ HRETURN_ERROR (H5E_BTREE, H5E_READERROR, FAIL);
+ }
+ if (H5F_block_write (f, tmp_addr, size, buf)<0) {
+ HRETURN_ERROR (H5E_BTREE, H5E_WRITEERROR, FAIL);
+ }
+ if (H5AC_rename (f, H5AC_BT, addr, tmp_addr)<0) {
+ HRETURN_ERROR (H5E_BTREE, H5E_CANTSPLIT, FAIL);
+ }
- /* update the new child's left pointer */
- if (NULL==(bt=H5AC_find (f, H5AC_BT, child, type))) {
- HRETURN_ERROR (H5E_BTREE, H5E_CANTLOAD, FAIL);
- }
- bt->dirty += 1;
- bt->left = addr;
+ buf = H5MM_xfree (buf);
+ new_root = addr;
+ addr = tmp_addr;
- /* clear the old root at the old address */
- if (NULL==(bt=H5AC_find (f, H5AC_BT, new_root, type))) {
- HRETURN_ERROR (H5E_BTREE, H5E_CANTLOAD, FAIL);
- }
- bt->dirty += 1;
- bt->ndirty = 0;
- bt->left = 0;
- bt->right = 0;
- bt->nchildren = 0;
+ /* update the new child's left pointer */
+ if (NULL==(bt=H5AC_find (f, H5AC_BT, child, type))) {
+ HRETURN_ERROR (H5E_BTREE, H5E_CANTLOAD, FAIL);
}
-#else
- /*
- * The new root is created at a new file location.
- */
- if ((new_root = H5B_new (f, type, bt->sizeof_rkey))<0) {
- HRETURN_ERROR (H5E_BTREE, H5E_CANTINIT, FAIL);
+ bt->dirty += 1;
+ bt->left = addr;
+
+ /* clear the old root at the old address */
+ if (NULL==(bt=H5AC_find (f, H5AC_BT, new_root, type))) {
+ HRETURN_ERROR (H5E_BTREE, H5E_CANTLOAD, FAIL);
}
-#endif
+ bt->dirty += 1;
+ bt->ndirty = 0;
+ bt->left = 0;
+ bt->right = 0;
+ bt->nchildren = 0;
+
/* the new root */
if (NULL==(bt = H5AC_find (f, H5AC_BT, new_root, type))) {
@@ -1200,7 +1174,7 @@ H5B_insert_helper (hdf5_file_t *f, haddr_t addr, const H5B_class_t *type,
memcpy (bt->key[idx].nkey, lt_key, type->sizeof_nkey);
bt->dirty += 1;
bt->key[idx].dirty = 1;
- if (idx>0) *lt_key_changed = false;
+ if (idx>0) *lt_key_changed = FALSE;
}
if (*rt_key_changed) {
bt->key[idx+1].nkey = bt->native +
@@ -1208,7 +1182,7 @@ H5B_insert_helper (hdf5_file_t *f, haddr_t addr, const H5B_class_t *type,
memcpy (bt->key[idx+1].nkey, rt_key, type->sizeof_nkey);
bt->dirty += 1;
bt->key[idx+1].dirty = 1;
- if (idx+1<bt->nchildren) *rt_key_changed = false;
+ if (idx+1<bt->nchildren) *rt_key_changed = FALSE;
}
/*