summaryrefslogtreecommitdiffstats
path: root/src/H5B2.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2015-12-19 14:42:15 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2015-12-19 14:42:15 (GMT)
commit9ceca0f89a0d27a6dfaeb3dd0cab2680281c5b60 (patch)
tree70640ab8a5ea83537c05afa0a1d4450802239c1f /src/H5B2.c
parent2c55e17cfb6d396ffc33065bcba2ef8ceb7081b8 (diff)
downloadhdf5-9ceca0f89a0d27a6dfaeb3dd0cab2680281c5b60.zip
hdf5-9ceca0f89a0d27a6dfaeb3dd0cab2680281c5b60.tar.gz
hdf5-9ceca0f89a0d27a6dfaeb3dd0cab2680281c5b60.tar.bz2
[svn-r28710] Description:
Bring r28708 from revise_chunks branch: Fix earray, farray and btree2 use of incorrect file pointer when two files are opened and used to access the data structure. Misc. minor code cleanups as well. Tested on: MacOSX/64 10.11.2 (amazon) w/serial & parallel h5committest forthcoming
Diffstat (limited to 'src/H5B2.c')
-rw-r--r--src/H5B2.c30
1 files changed, 9 insertions, 21 deletions
diff --git a/src/H5B2.c b/src/H5B2.c
index 7eb88c4..a171917 100644
--- a/src/H5B2.c
+++ b/src/H5B2.c
@@ -134,7 +134,6 @@ H5B2_create(H5F_t *f, hid_t dxpl_id, const H5B2_create_t *cparam, void *ctx_udat
{
H5B2_t *bt2 = NULL; /* Pointer to the B-tree */
H5B2_hdr_t *hdr = NULL; /* Pointer to the B-tree header */
- H5B2_hdr_cache_ud_t cache_udata; /* User-data for callback */
haddr_t hdr_addr; /* B-tree header address */
H5B2_t *ret_value = NULL; /* Return value */
@@ -158,11 +157,8 @@ H5B2_create(H5F_t *f, hid_t dxpl_id, const H5B2_create_t *cparam, void *ctx_udat
HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, NULL, "memory allocation failed for v2 B-tree info")
/* Look up the B-tree header */
- cache_udata.f = f;
- cache_udata.addr = hdr_addr;
- cache_udata.ctx_udata = ctx_udata;
- if(NULL == (hdr = (H5B2_hdr_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_HDR, hdr_addr, &cache_udata, H5AC__NO_FLAGS_SET)))
- HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, NULL, "unable to load B-tree header")
+ if(NULL == (hdr = H5B2__hdr_protect(f, dxpl_id, hdr_addr, ctx_udata, H5AC__NO_FLAGS_SET)))
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, NULL, "unable to protect v2 B-tree header")
/* Point v2 B-tree wrapper at header and bump it's ref count */
bt2->hdr = hdr;
@@ -180,7 +176,7 @@ H5B2_create(H5F_t *f, hid_t dxpl_id, const H5B2_create_t *cparam, void *ctx_udat
ret_value = bt2;
done:
- if(hdr && H5AC_unprotect(f, dxpl_id, H5AC_BT2_HDR, hdr_addr, hdr, H5AC__NO_FLAGS_SET) < 0)
+ if(hdr && H5B2__hdr_unprotect(hdr, dxpl_id, H5AC__NO_FLAGS_SET) < 0)
HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, NULL, "unable to release v2 B-tree header")
if(!ret_value && bt2)
if(H5B2_close(bt2, dxpl_id) < 0)
@@ -209,7 +205,6 @@ H5B2_open(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *ctx_udata)
{
H5B2_t *bt2 = NULL; /* Pointer to the B-tree */
H5B2_hdr_t *hdr = NULL; /* Pointer to the B-tree header */
- H5B2_hdr_cache_ud_t cache_udata; /* User-data for callback */
H5B2_t *ret_value = NULL; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
@@ -219,11 +214,8 @@ H5B2_open(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *ctx_udata)
HDassert(H5F_addr_defined(addr));
/* Look up the B-tree header */
- cache_udata.f = f;
- cache_udata.addr = addr;
- cache_udata.ctx_udata = ctx_udata;
- if(NULL == (hdr = (H5B2_hdr_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_HDR, addr, &cache_udata, H5AC__READ_ONLY_FLAG)))
- HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, NULL, "unable to load B-tree header")
+ if(NULL == (hdr = H5B2__hdr_protect(f, dxpl_id, addr, ctx_udata, H5AC__READ_ONLY_FLAG)))
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, NULL, "unable to protect v2 B-tree header")
/* Check for pending heap deletion */
if(hdr->pending_delete)
@@ -249,7 +241,7 @@ H5B2_open(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *ctx_udata)
ret_value = bt2;
done:
- if(hdr && H5AC_unprotect(f, dxpl_id, H5AC_BT2_HDR, addr, hdr, H5AC__NO_FLAGS_SET) < 0)
+ if(hdr && H5B2__hdr_unprotect(hdr, dxpl_id, H5AC__NO_FLAGS_SET) < 0)
HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, NULL, "unable to release v2 B-tree header")
if(!ret_value && bt2)
if(H5B2_close(bt2, dxpl_id) < 0)
@@ -1282,7 +1274,7 @@ H5B2_close(H5B2_t *bt2, hid_t dxpl_id)
/* Lock the v2 B-tree header into memory */
/* (OK to pass in NULL for callback context, since we know the header must be in the cache) */
- if(NULL == (hdr = (H5B2_hdr_t *)H5AC_protect(bt2->f, dxpl_id, H5AC_BT2_HDR, bt2_addr, NULL, H5AC__NO_FLAGS_SET)))
+ if(NULL == (hdr = H5B2__hdr_protect(bt2->f, dxpl_id, bt2_addr, NULL, H5AC__NO_FLAGS_SET)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect v2 B-tree header")
/* Set the shared v2 B-tree header's file context for this operation */
@@ -1344,7 +1336,6 @@ H5B2_delete(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *ctx_udata,
H5B2_remove_t op, void *op_data)
{
H5B2_hdr_t *hdr = NULL; /* Pointer to the B-tree header */
- H5B2_hdr_cache_ud_t cache_udata; /* User-data for callback */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(FAIL)
@@ -1357,10 +1348,7 @@ H5B2_delete(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *ctx_udata,
#ifdef QAK
HDfprintf(stderr, "%s: addr = %a\n", FUNC, addr);
#endif /* QAK */
- cache_udata.f = f;
- cache_udata.addr = addr;
- cache_udata.ctx_udata = ctx_udata;
- if(NULL == (hdr = (H5B2_hdr_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_HDR, addr, &cache_udata, H5AC__NO_FLAGS_SET)))
+ if(NULL == (hdr = H5B2__hdr_protect(f, dxpl_id, addr, ctx_udata, H5AC__NO_FLAGS_SET)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect v2 B-tree header")
/* Remember the callback & context for later */
@@ -1382,7 +1370,7 @@ HDfprintf(stderr, "%s: addr = %a\n", FUNC, addr);
done:
/* Unprotect the header, if an error occurred */
- if(hdr && H5AC_unprotect(f, dxpl_id, H5AC_BT2_HDR, addr, hdr, H5AC__NO_FLAGS_SET) < 0)
+ if(hdr && H5B2__hdr_unprotect(hdr, dxpl_id, H5AC__NO_FLAGS_SET) < 0)
HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release v2 B-tree header")
FUNC_LEAVE_NOAPI(ret_value)