diff options
author | Robb Matzke <matzke@llnl.gov> | 1997-08-04 16:19:57 (GMT) |
---|---|---|
committer | Robb Matzke <matzke@llnl.gov> | 1997-08-04 16:19:57 (GMT) |
commit | 6a3cb617d3aa57f439065118fbc68afcb1465a54 (patch) | |
tree | b9062c04a678e7615a437afe04fc7ca86f06efc7 /src/H5B.c | |
parent | 5cc4d0dcde9fb0f5a941c90a1de9ab964d09a163 (diff) | |
download | hdf5-6a3cb617d3aa57f439065118fbc68afcb1465a54.zip hdf5-6a3cb617d3aa57f439065118fbc68afcb1465a54.tar.gz hdf5-6a3cb617d3aa57f439065118fbc68afcb1465a54.tar.bz2 |
[svn-r12] ./src/H5AC.c
Fails sooner if the type of object requested doesn't match
the type of object cached.
./src/H5B.c
./src/H5Bprivate.h
./src/H5Fprivate.h
./src/H5G.c
./src/H5Gnode.c
./src/H5Gprivate.h
./src/H5H.c
./src/H5Hprivate.h
Changed lots of `H5*_HDR_SIZE' macros to `H5*_SIZEOF_HDR' to make
things more consistent.
Added H5*_SIZEOF_MAGIC macros.
Added debugging functions to some of the packages.
./src/H5F.c
Fixed a bug with reading past the end of a buffer.
./src/H5Tproto.h
Added prototypes for H5Tadd_field() and H5Tget_fields().
./src/debug.c
Low-level file debugging program.
./src/Makefile
Builds `debug' as one of the main targets. The target is
called `debug_hdf5' so it doesn't conflict with the `debug'
target that was already there. But the executable is called
`debug'.
Diffstat (limited to 'src/H5B.c')
-rw-r--r-- | src/H5B.c | 78 |
1 files changed, 65 insertions, 13 deletions
@@ -181,7 +181,7 @@ H5B_new (hdf5_file_t *f, const H5B_class_t *type, size_t sizeof_rkey) * `page' buffer. Each native key pointer should be null until the key is * translated to native format. */ - for (i=0,offset=H5B_HDR_SIZE(f); + for (i=0,offset=H5B_SIZEOF_HDR(f); i<2*type->k; i++,offset+=bt->sizeof_rkey+H5F_SIZEOF_OFFSET(f)) { @@ -249,7 +249,7 @@ H5B_load (hdf5_file_t *f, haddr_t addr, const void *_data) p = bt->page; /* magic number */ - if (memcmp (p, H5B_MAGIC, 4)) goto error; + if (memcmp (p, H5B_MAGIC, H5B_SIZEOF_MAGIC)) goto error; p += 4; /* node type and level */ @@ -326,7 +326,7 @@ H5B_flush (hdf5_file_t *f, hbool_t destroy, haddr_t addr, H5B_t *bt) if (bt->dirty) { /* magic number */ - memcpy (p, H5B_MAGIC, 4); + memcpy (p, H5B_MAGIC, H5B_SIZEOF_MAGIC); p += 4; /* node type and level */ @@ -513,14 +513,14 @@ H5B_split (hdf5_file_t *f, const H5B_class_t *type, haddr_t addr, intn anchor) /* * Copy data into the new node from the old node. */ - memcpy (bt->page + H5B_HDR_SIZE(f), - old->page + H5B_HDR_SIZE(f) + delta*recsize, + memcpy (bt->page + H5B_SIZEOF_HDR(f), + old->page + H5B_SIZEOF_HDR(f) + delta*recsize, type->k * recsize); memcpy (bt->native, old->native + delta * type->sizeof_nkey, (type->k+1) * type->sizeof_nkey); - for (i=0,offset=H5B_HDR_SIZE(f); i<=2*type->k; i++,offset+=recsize) { + for (i=0,offset=H5B_SIZEOF_HDR(f); i<=2*type->k; i++,offset+=recsize) { /* key */ if (i<=type->k) { @@ -555,8 +555,8 @@ H5B_split (hdf5_file_t *f, const H5B_class_t *type, haddr_t addr, intn anchor) old->nchildren = type->k; if (H5B_ANCHOR_RT==anchor) { - memcpy (old->page + H5B_HDR_SIZE(f), - old->page + H5B_HDR_SIZE(f) + delta*recsize, + memcpy (old->page + H5B_SIZEOF_HDR(f), + old->page + H5B_SIZEOF_HDR(f) + delta*recsize, type->k * recsize); memmove (old->native, old->native + delta * type->sizeof_nkey, @@ -803,8 +803,8 @@ H5B_insert_child (hdf5_file_t *f, const H5B_class_t *type, haddr_t addr, /* * The MD_KEY is the left key of the new node. */ - memmove (bt->page + H5B_HDR_SIZE(f) + (idx+1)*recsize, - bt->page + H5B_HDR_SIZE(f) + idx*recsize, + memmove (bt->page + H5B_SIZEOF_HDR(f) + (idx+1)*recsize, + bt->page + H5B_SIZEOF_HDR(f) + idx*recsize, (bt->nchildren-idx)*recsize + bt->sizeof_rkey); memmove (bt->native + (idx+1) * type->sizeof_nkey, @@ -822,9 +822,9 @@ H5B_insert_child (hdf5_file_t *f, const H5B_class_t *type, haddr_t addr, /* * The MD_KEY is the right key of the new node. */ - memmove (bt->page + (H5B_HDR_SIZE(f) + + memmove (bt->page + (H5B_SIZEOF_HDR(f) + (idx+1)*recsize + bt->sizeof_rkey), - bt->page + (H5B_HDR_SIZE(f) + + bt->page + (H5B_SIZEOF_HDR(f) + idx*recsize + bt->sizeof_rkey), (bt->nchildren-idx) * recsize); @@ -1170,8 +1170,60 @@ H5B_nodesize (hdf5_file_t *f, const H5B_class_t *type, *total_nkey_size = (2 * type->k + 1) * type->sizeof_nkey; } - return (H5B_HDR_SIZE(f) + /*node header */ + return (H5B_SIZEOF_HDR(f) + /*node header */ 2 * type->k * H5F_SIZEOF_OFFSET(f) + /*child pointers*/ (2*type->k+1) * sizeof_rkey); /*keys */ } + +/*------------------------------------------------------------------------- + * Function: H5B_debug + * + * Purpose: Prints debugging info about a B-tree. + * + * Return: Success: 0 + * + * Failure: -1 + * + * Programmer: Robb Matzke + * robb@maya.nuance.com + * Aug 4 1997 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +herr_t +H5B_debug (hdf5_file_t *f, haddr_t addr, FILE *stream, intn indent, + intn fwidth, const H5B_class_t *type) +{ + H5B_t *bt = H5AC_find (f, H5AC_BT, addr, type); + + if (!bt) return -1; + + fprintf (stream, "%*s%-*s %d\n", indent, "", fwidth, + "Tree type ID:", + (int)(bt->type->id)); + fprintf (stream, "%*s%-*s %lu\n", indent, "", fwidth, + "Size of raw (disk) key:", + (unsigned long)(bt->sizeof_rkey)); + fprintf (stream, "%*s%-*s %d\n", indent, "", fwidth, + "Dirty flag:", + (int)(bt->dirty)); + fprintf (stream, "%*s%-*s %d\n", indent, "", fwidth, + "Number of initial dirty children:", + (int)(bt->ndirty)); + fprintf (stream, "%*s%-*s %d\n", indent, "", fwidth, + "Level:", + (int)(bt->level)); + fprintf (stream, "%*s%-*s %lu\n", indent, "", fwidth, + "Address of left sibling:", + (unsigned long)(bt->left)); + fprintf (stream, "%*s%-*s %lu\n", indent, "", fwidth, + "Address of right sibling:", + (unsigned long)(bt->right)); + fprintf (stream, "%*s%-*s %d\n", indent, "", fwidth, + "Number of children:", + (int)(bt->nchildren)); + return 0; +} |