diff options
Diffstat (limited to 'src/H5Bcache.c')
-rw-r--r-- | src/H5Bcache.c | 73 |
1 files changed, 37 insertions, 36 deletions
diff --git a/src/H5Bcache.c b/src/H5Bcache.c index 99930e6..a3b49e9 100644 --- a/src/H5Bcache.c +++ b/src/H5Bcache.c @@ -109,7 +109,7 @@ H5B_serialize(const H5F_t *f, const H5B_t *bt) HDassert(f); HDassert(bt); HDassert(bt->rc_shared); - shared=(H5B_shared_t *)H5RC_GET_OBJ(bt->rc_shared); + shared = (H5B_shared_t *)H5RC_GET_OBJ(bt->rc_shared); HDassert(shared); p = shared->page; @@ -131,10 +131,10 @@ H5B_serialize(const H5F_t *f, const H5B_t *bt) H5F_addr_encode(f, &p, bt->right); /* child keys and pointers */ - native=bt->native; - for (u = 0; u < bt->nchildren; ++u) { + native = bt->native; + for(u = 0; u < bt->nchildren; ++u) { /* encode the key */ - if (shared->type->encode(f, bt, p, native) < 0) + if(shared->type->encode(f, bt, p, native) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTENCODE, FAIL, "unable to encode B-tree key") p += shared->sizeof_rkey; native += shared->type->sizeof_nkey; @@ -142,9 +142,9 @@ H5B_serialize(const H5F_t *f, const H5B_t *bt) /* encode the child address */ H5F_addr_encode(f, &p, bt->child[u]); } /* end for */ - if(bt->nchildren>0) { + if(bt->nchildren > 0) { /* Encode the final key */ - if (shared->type->encode(f, bt, p, native) < 0) + if(shared->type->encode(f, bt, p, native) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTENCODE, FAIL, "unable to encode B-tree key") } /* end if */ @@ -187,29 +187,29 @@ H5B_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_type, void *udata) HDassert(type); HDassert(type->get_shared); - if (NULL==(bt = H5FL_MALLOC(H5B_t))) - HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") + if(NULL == (bt = H5FL_MALLOC(H5B_t))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") HDmemset(&bt->cache_info,0,sizeof(H5AC_info_t)); - if((bt->rc_shared=(type->get_shared)(f, udata))==NULL) - HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "can't retrieve B-tree node buffer") - shared=(H5B_shared_t *)H5RC_GET_OBJ(bt->rc_shared); + if(NULL == (bt->rc_shared=(type->get_shared)(f, udata))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "can't retrieve B-tree node buffer") + shared = (H5B_shared_t *)H5RC_GET_OBJ(bt->rc_shared); HDassert(shared); - if (NULL==(bt->native=H5FL_BLK_MALLOC(native_block,shared->sizeof_keys)) || - NULL==(bt->child=H5FL_SEQ_MALLOC(haddr_t,(size_t)shared->two_k))) - HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") + if(NULL == (bt->native = H5FL_BLK_MALLOC(native_block, shared->sizeof_keys)) || + NULL == (bt->child = H5FL_SEQ_MALLOC(haddr_t, (size_t)shared->two_k))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") - if (H5F_block_read(f, H5FD_MEM_BTREE, addr, shared->sizeof_rnode, dxpl_id, shared->page)<0) + if(H5F_block_read(f, H5FD_MEM_BTREE, addr, shared->sizeof_rnode, dxpl_id, shared->page)<0) HGOTO_ERROR(H5E_BTREE, H5E_READERROR, NULL, "can't read B-tree node") p = shared->page; /* magic number */ - if (HDmemcmp(p, H5B_MAGIC, (size_t)H5_SIZEOF_MAGIC)) + if(HDmemcmp(p, H5B_MAGIC, (size_t)H5_SIZEOF_MAGIC)) HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, NULL, "wrong B-tree signature") p += 4; /* node type and level */ - if (*p++ != (uint8_t)type->id) + if(*p++ != (uint8_t)type->id) HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, NULL, "incorrect B-tree node type") bt->level = *p++; @@ -221,22 +221,22 @@ H5B_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_type, void *udata) H5F_addr_decode(f, (const uint8_t **) &p, &(bt->right)); /* the child/key pairs */ - native=bt->native; - for (u = 0; u < bt->nchildren; u++) { + native = bt->native; + for(u = 0; u < bt->nchildren; u++) { /* Decode native key value */ - if ((type->decode) (f, bt, p, native) < 0) + if((type->decode)(f, bt, p, native) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTDECODE, NULL, "unable to decode key") p += shared->sizeof_rkey; native += type->sizeof_nkey; /* Decode address value */ H5F_addr_decode(f, (const uint8_t **) &p, bt->child + u); - } + } /* end for */ /* Decode final key */ - if(bt->nchildren>0) { + if(bt->nchildren > 0) { /* Decode native key value */ - if ((type->decode) (f, bt, p, native) < 0) + if((type->decode)(f, bt, p, native) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTDECODE, NULL, "unable to decode key") } /* end if */ @@ -244,8 +244,8 @@ H5B_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_type, void *udata) ret_value = bt; done: - if (!ret_value && bt) - (void)H5B_dest(f,bt); + if(!ret_value && bt) + (void)H5B_dest(f, bt); FUNC_LEAVE_NOAPI(ret_value) } /* end H5B_load() */ /*lint !e818 Can't make udata a pointer to const */ @@ -286,8 +286,8 @@ H5B_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5B_t *bt, uns HDassert(shared->type); HDassert(shared->type->encode); - if (bt->cache_info.is_dirty) { - if (H5B_serialize(f, bt) < 0) + if(bt->cache_info.is_dirty) { + if(H5B_serialize(f, bt) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTSERIALIZE, FAIL, "unable to serialize B-tree") /* @@ -295,14 +295,14 @@ H5B_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5B_t *bt, uns * bother writing data for the child entries that don't exist or * for the final unchanged children. */ - if (H5F_block_write(f, H5FD_MEM_BTREE, addr, shared->sizeof_rnode, dxpl_id, shared->page) < 0) + if(H5F_block_write(f, H5FD_MEM_BTREE, addr, shared->sizeof_rnode, dxpl_id, shared->page) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTFLUSH, FAIL, "unable to save B-tree node to disk") bt->cache_info.is_dirty = FALSE; } /* end if */ - if (destroy) - if (H5B_dest(f,bt) < 0) + if(destroy) + if(H5B_dest(f,bt) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTFREE, FAIL, "unable to destroy B-tree node") done: @@ -356,9 +356,9 @@ H5B_dest(H5F_t *f, H5B_t *bt) /* Release resources for B-tree node */ H5FL_SEQ_FREE(haddr_t, bt->child); - (void)H5FL_BLK_FREE(native_block, bt->native); + bt->native = H5FL_BLK_FREE(native_block, bt->native); H5RC_DEC(bt->rc_shared); - (void)H5FL_FREE(H5B_t, bt); + bt = H5FL_FREE(H5B_t, bt); done: FUNC_LEAVE_NOAPI(ret_value) @@ -393,8 +393,8 @@ H5B_clear(H5F_t *f, H5B_t *bt, hbool_t destroy) /* Reset the dirty flag. */ bt->cache_info.is_dirty = FALSE; - if (destroy) - if (H5B_dest(f, bt) < 0) + if(destroy) + if(H5B_dest(f, bt) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTFREE, FAIL, "unable to destroy B-tree node") done: @@ -417,7 +417,7 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5B_compute_size(const H5F_t *f, const H5B_t *bt, size_t *size_ptr) +H5B_compute_size(const H5F_t UNUSED *f, const H5B_t *bt, size_t *size_ptr) { H5B_shared_t *shared; /* Pointer to shared B-tree info */ @@ -427,7 +427,7 @@ H5B_compute_size(const H5F_t *f, const H5B_t *bt, size_t *size_ptr) HDassert(f); HDassert(bt); HDassert(bt->rc_shared); - shared=(H5B_shared_t *)H5RC_GET_OBJ(bt->rc_shared); + shared = (H5B_shared_t *)H5RC_GET_OBJ(bt->rc_shared); HDassert(shared); HDassert(shared->type); HDassert(size_ptr); @@ -437,3 +437,4 @@ H5B_compute_size(const H5F_t *f, const H5B_t *bt, size_t *size_ptr) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5B_compute_size() */ + |