diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2009-10-27 19:18:45 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2009-10-27 19:18:45 (GMT) |
commit | ab3f3e0219d80b5407fe5da785a7faae443c7ffc (patch) | |
tree | c51c1dc909d9b5e82f077620ca4fc423a5d1edd4 /src/H5B2.c | |
parent | 4af649f03d3eb2826616c6f730bc4281c027a536 (diff) | |
download | hdf5-ab3f3e0219d80b5407fe5da785a7faae443c7ffc.zip hdf5-ab3f3e0219d80b5407fe5da785a7faae443c7ffc.tar.gz hdf5-ab3f3e0219d80b5407fe5da785a7faae443c7ffc.tar.bz2 |
[svn-r17749] Description:
Refactor v2 B-tree code to bring it further in line with how the fractal
heap code works, to make forthcoming modificaions easier. Also minor tweaks to
the fractal heap code to clean it up a bit more also.
Tested on:
FreeBSD/32 6.3 (duty) in debug mode
FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode
Linux/32 2.6 (jam) w/PGI compilers, w/default API=1.8.x,
w/C++ & FORTRAN, w/threadsafe, in debug mode
Linux/64-amd64 2.6 (smirom) w/Intel compilers, w/default API=1.6.x,
w/C++ & FORTRAN, in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, in production mode
Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in debug mode
Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in production mode
Diffstat (limited to 'src/H5B2.c')
-rw-r--r-- | src/H5B2.c | 41 |
1 files changed, 7 insertions, 34 deletions
@@ -41,7 +41,6 @@ #include "H5private.h" /* Generic Functions */ #include "H5B2pkg.h" /* v2 B-trees */ #include "H5Eprivate.h" /* Error handling */ -#include "H5MFprivate.h" /* File memory management */ /****************/ @@ -71,9 +70,6 @@ static herr_t H5B2_close(H5B2_hdr_t *hdr, hid_t dxpl_id); /* Package Variables */ /*********************/ -/* Declare a free list to manage the H5B2_hdr_t struct */ -H5FL_DEFINE(H5B2_hdr_t); - /*****************************/ /* Library Private Variables */ @@ -103,7 +99,7 @@ herr_t H5B2_create(H5F_t *f, hid_t dxpl_id, const H5B2_create_t *cparam, haddr_t *addr_p) { - H5B2_hdr_t *hdr = NULL; /* The new B-tree header information */ + haddr_t hdr_addr; /* The new v2 B-tree header address */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5B2_create, FAIL) @@ -115,36 +111,14 @@ H5B2_create(H5F_t *f, hid_t dxpl_id, const H5B2_create_t *cparam, HDassert(cparam); HDassert(addr_p); - /* - * Allocate file and memory data structures. - */ - if(NULL == (hdr = H5FL_CALLOC(H5B2_hdr_t))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for B-tree header") - - /* Assign non-zero information */ - hdr->root.addr = HADDR_UNDEF; - - /* Initialize shared B-tree info */ - if(H5B2_hdr_init(f, hdr, cparam, 0) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't create shared B-tree info") - - /* Allocate space for the header on disk */ - if(HADDR_UNDEF == (hdr->addr = H5MF_alloc(f, H5FD_MEM_BTREE, dxpl_id, (hsize_t)H5B2_HEADER_SIZE(f)))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "file allocation failed for B-tree header") - - /* Cache the new B-tree node */ - if(H5AC_set(f, dxpl_id, H5AC_BT2_HDR, hdr->addr, hdr, H5AC__NO_FLAGS_SET) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL, "can't add B-tree header to cache") + /* Create shared v2 B-tree header */ + if(HADDR_UNDEF == (hdr_addr = H5B2_hdr_create(f, dxpl_id, cparam))) + HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL, "can't create v2 B-tree header") /* Set the B-tree's address to return */ - *addr_p = hdr->addr; + *addr_p = hdr_addr; done: - if(ret_value < 0) { - if(hdr) - (void)H5B2_cache_hdr_dest(f, hdr); - } /* end if */ - FUNC_LEAVE_NOAPI(ret_value) } /* end H5B2_create() */ @@ -188,10 +162,9 @@ H5B2_open(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type, haddr_t addr, ret_value = hdr; done: - if(!ret_value) { - if(hdr && H5B2_close(hdr, dxpl_id) < 0) + if(!ret_value && hdr) + if(H5B2_close(hdr, dxpl_id) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTCLOSEOBJ, NULL, "unable to close B-tree") - } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* H5B2_open() */ |