diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2003-09-11 16:45:54 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2003-09-11 16:45:54 (GMT) |
commit | 987e281c8afa3ebd4113d9efba251be4074fd55f (patch) | |
tree | ee6b63635f8071e33e6159b5b114ae6303d17b71 /src/H5HG.c | |
parent | 1a8d15116a28c07aa7c4e903615712a0da0bb1fe (diff) | |
download | hdf5-987e281c8afa3ebd4113d9efba251be4074fd55f.zip hdf5-987e281c8afa3ebd4113d9efba251be4074fd55f.tar.gz hdf5-987e281c8afa3ebd4113d9efba251be4074fd55f.tar.bz2 |
[svn-r7467] Purpose:
Code cleanup
Description:
Patch up a few places where the metadata cache could ask for a read lock
instead of a write lock and other minor code cleanups.
Platforms tested:
FreeBSD 4.9 (sleipnir)
too minor to need h5committest
Misc. update:
Diffstat (limited to 'src/H5HG.c')
-rw-r--r-- | src/H5HG.c | 44 |
1 files changed, 18 insertions, 26 deletions
@@ -788,12 +788,10 @@ H5HG_peek (H5F_t *f, hid_t dxpl_id, H5HG_t *hobj) } } - if (H5AC_unprotect(f, dxpl_id, H5AC_GHEAP, hobj->addr, heap, FALSE) != SUCCEED) - HGOTO_ERROR(H5E_HEAP, H5E_PROTECT, FAIL, "unable to release object header"); - - heap=NULL; - done: + if (heap && H5AC_unprotect(f, dxpl_id, H5AC_GHEAP, hobj->addr, heap, FALSE)<0) + HDONE_ERROR(H5E_HEAP, H5E_PROTECT, NULL, "unable to release object header"); + FUNC_LEAVE_NOAPI(ret_value); } #endif /* NOT_YET */ @@ -861,18 +859,11 @@ H5HG_read (H5F_t *f, hid_t dxpl_id, H5HG_t *hobj, void *object/*out*/) } } - if (H5AC_unprotect(f, dxpl_id, H5AC_GHEAP, hobj->addr, heap, FALSE) != SUCCEED) { - heap = NULL; - HGOTO_ERROR(H5E_HEAP, H5E_PROTECT, NULL, "unable to release object header"); - } - - heap = NULL; - /* Set return value */ ret_value=object; done: - if (heap && H5AC_unprotect(f, dxpl_id, H5AC_GHEAP, hobj->addr, heap, FALSE) != SUCCEED) + if (heap && H5AC_unprotect(f, dxpl_id, H5AC_GHEAP, hobj->addr, heap, FALSE)<0) HDONE_ERROR(H5E_HEAP, H5E_PROTECT, NULL, "unable to release object header"); FUNC_LEAVE_NOAPI(ret_value); @@ -913,25 +904,26 @@ H5HG_link (H5F_t *f, hid_t dxpl_id, H5HG_t *hobj, int adjust) if (0==(f->intent & H5F_ACC_RDWR)) HGOTO_ERROR (H5E_HEAP, H5E_WRITEERROR, FAIL, "no write intent on file"); - /* Load the heap */ - if (NULL == (heap = H5AC_protect(f, dxpl_id, H5AC_GHEAP, hobj->addr, NULL, NULL, H5AC_WRITE))) - HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, FAIL, "unable to load heap"); - - assert (hobj->idx>0 && hobj->idx<heap->nalloc); - assert (heap->obj[hobj->idx].begin); - if (heap->obj[hobj->idx].nrefs+adjust<0) - HGOTO_ERROR (H5E_HEAP, H5E_BADRANGE, FAIL, "new link count would be out of range"); - if (heap->obj[hobj->idx].nrefs+adjust>H5HG_MAXLINK) - HGOTO_ERROR (H5E_HEAP, H5E_BADVALUE, FAIL, "new link count would be out of range"); - heap->obj[hobj->idx].nrefs += adjust; - if (adjust) + if(adjust!=0) { + /* Load the heap */ + if (NULL == (heap = H5AC_protect(f, dxpl_id, H5AC_GHEAP, hobj->addr, NULL, NULL, H5AC_WRITE))) + HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, FAIL, "unable to load heap"); + + assert (hobj->idx>0 && hobj->idx<heap->nalloc); + assert (heap->obj[hobj->idx].begin); + if (heap->obj[hobj->idx].nrefs+adjust<0) + HGOTO_ERROR (H5E_HEAP, H5E_BADRANGE, FAIL, "new link count would be out of range"); + if (heap->obj[hobj->idx].nrefs+adjust>H5HG_MAXLINK) + HGOTO_ERROR (H5E_HEAP, H5E_BADVALUE, FAIL, "new link count would be out of range"); + heap->obj[hobj->idx].nrefs += adjust; heap->cache_info.dirty = TRUE; + } /* end if */ /* Set return value */ ret_value=heap->obj[hobj->idx].nrefs; done: - if (heap && H5AC_unprotect(f, dxpl_id, H5AC_GHEAP, hobj->addr, heap, FALSE) != SUCCEED && ret_value != FAIL) + if (heap && H5AC_unprotect(f, dxpl_id, H5AC_GHEAP, hobj->addr, heap, FALSE)<0) HDONE_ERROR(H5E_HEAP, H5E_PROTECT, FAIL, "unable to release object header"); FUNC_LEAVE_NOAPI(ret_value); |