diff options
Diffstat (limited to 'src/H5Gnode.c')
-rw-r--r-- | src/H5Gnode.c | 362 |
1 files changed, 173 insertions, 189 deletions
diff --git a/src/H5Gnode.c b/src/H5Gnode.c index 60c39b4..5d12d94 100644 --- a/src/H5Gnode.c +++ b/src/H5Gnode.c @@ -49,6 +49,19 @@ typedef struct H5G_node_key_t { size_t offset; /*offset into heap for name */ } H5G_node_key_t; +/* + * A symbol table node is a collection of symbol table entries. It can + * be thought of as the lowest level of the B-link tree that points to + * a collection of symbol table entries that belong to a specific symbol + * table or group. + */ +typedef struct H5G_node_t { + H5AC_info_t cache_info; /* Information for H5AC cache functions, _must_ be */ + /* first field in structure */ + unsigned nsyms; /*number of symbols */ + H5G_entry_t *entry; /*array of symbol table entries */ +} H5G_node_t; + /* Private macros */ #define H5G_NODE_VERS 1 /*symbol table node version number */ #define H5G_NODE_SIZEOF_HDR(F) (H5G_NODE_SIZEOF_MAGIC + 4) @@ -677,8 +690,6 @@ H5G_compute_size(const H5F_t *f, const H5G_node_t UNUSED *sym, size_t *size_ptr) * matzke@llnl.gov * Jun 23 1997 * - * Modifications: - * *------------------------------------------------------------------------- */ static herr_t @@ -883,9 +894,6 @@ done: * matzke@llnl.gov * Jun 23 1997 * - * Modifications: - * Robb Matzke, 1999-07-28 - * The ADDR argument is passed by value. *------------------------------------------------------------------------- */ static herr_t @@ -899,26 +907,26 @@ H5G_node_found(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void UNUSED *_lt_key int cmp = 1; const char *s; const char *base; /* Base of heap */ - herr_t ret_value=SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT(H5G_node_found); + FUNC_ENTER_NOAPI_NOINIT(H5G_node_found) /* * Check arguments. */ - assert(f); - assert(H5F_addr_defined(addr)); - assert(udata); + HDassert(f); + HDassert(H5F_addr_defined(addr)); + HDassert(udata); /* * Load the symbol table node for exclusive access. */ - if (NULL == (sn = H5AC_protect(f, dxpl_id, H5AC_SNODE, addr, NULL, NULL, H5AC_READ))) - HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, FAIL, "unable to protect symbol table node"); + if(NULL == (sn = H5AC_protect(f, dxpl_id, H5AC_SNODE, addr, NULL, NULL, H5AC_READ))) + HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, FAIL, "unable to protect symbol table node") /* Get base address of heap */ - if (NULL == (heap = H5HL_protect(f, dxpl_id, udata->common.heap_addr))) - HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "unable to protect symbol name"); + if(NULL == (heap = H5HL_protect(f, dxpl_id, udata->common.heap_addr))) + HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "unable to protect symbol name") base = H5HL_offset_into(f, heap, 0); @@ -926,23 +934,23 @@ H5G_node_found(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void UNUSED *_lt_key * Binary search. */ rt = sn->nsyms; - while (lt < rt && cmp) { + while(lt < rt && cmp) { idx = (lt + rt) / 2; - s=base+sn->entry[idx].name_off; + s = base + sn->entry[idx].name_off; cmp = HDstrcmp(udata->common.name, s); if (cmp < 0) rt = idx; else lt = idx + 1; - } + } /* end while */ - if (H5HL_unprotect(f, dxpl_id, heap, udata->common.heap_addr) < 0) - HGOTO_ERROR(H5E_SYM, H5E_PROTECT, FAIL, "unable to unprotect symbol name"); - heap=NULL; base=NULL; + if(H5HL_unprotect(f, dxpl_id, heap, udata->common.heap_addr) < 0) + HGOTO_ERROR(H5E_SYM, H5E_PROTECT, FAIL, "unable to unprotect symbol name") + heap = NULL; base = NULL; - if (cmp) - HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "not found"); + if(cmp) + HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "not found") /* * The caller is querying the symbol entry, copy it into the UDATA @@ -950,8 +958,8 @@ H5G_node_found(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void UNUSED *_lt_key * * (do a NULL copy, since the entry's name will be constructed later) */ - if (H5G_ent_copy(udata->ent, &sn->entry[idx], H5G_COPY_NULL)<0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to copy entry"); + if(H5G_ent_copy(udata->ent, &sn->entry[idx], H5_COPY_NULL) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to copy entry") /* Leave object in same file as lookup occurs in */ /* If a file is opened through different H5Fopen() calls, the symbol @@ -961,11 +969,11 @@ H5G_node_found(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void UNUSED *_lt_key udata->ent->file = f; done: - if (sn && H5AC_unprotect(f, dxpl_id, H5AC_SNODE, addr, sn, FALSE) < 0) - HDONE_ERROR(H5E_SYM, H5E_PROTECT, FAIL, "unable to release symbol table node"); + if(sn && H5AC_unprotect(f, dxpl_id, H5AC_SNODE, addr, sn, FALSE) < 0) + HDONE_ERROR(H5E_SYM, H5E_PROTECT, FAIL, "unable to release symbol table node") - FUNC_LEAVE_NOAPI(ret_value); -} + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5G_node_found() */ /*------------------------------------------------------------------------- @@ -1000,16 +1008,14 @@ done: * matzke@llnl.gov * Jun 24 1997 * - * Modifications: - * Robb Matzke, 1999-07-28 - * The ADDR argument is passed by value. *------------------------------------------------------------------------- */ static H5B_ins_t -H5G_node_insert(H5F_t *f, hid_t dxpl_id, haddr_t addr, void UNUSED *_lt_key, - hbool_t UNUSED *lt_key_changed, void *_md_key, - void *_udata, void *_rt_key, hbool_t *rt_key_changed, - haddr_t *new_node_p) +H5G_node_insert(H5F_t *f, hid_t dxpl_id, haddr_t addr, + void UNUSED *_lt_key, hbool_t UNUSED *lt_key_changed, + void *_md_key, void *_udata, + void *_rt_key, hbool_t *rt_key_changed, + haddr_t *new_node_p) { H5G_node_key_t *md_key = (H5G_node_key_t *) _md_key; H5G_node_key_t *rt_key = (H5G_node_key_t *) _rt_key; @@ -1025,27 +1031,27 @@ H5G_node_insert(H5F_t *f, hid_t dxpl_id, haddr_t addr, void UNUSED *_lt_key, H5G_node_t *insert_into = NULL; /*node that gets new entry*/ H5B_ins_t ret_value = H5B_INS_ERROR; - FUNC_ENTER_NOAPI_NOINIT(H5G_node_insert); + FUNC_ENTER_NOAPI_NOINIT(H5G_node_insert) /* * Check arguments. */ - assert(f); - assert(H5F_addr_defined(addr)); - assert(md_key); - assert(rt_key); - assert(udata); - assert(new_node_p); + HDassert(f); + HDassert(H5F_addr_defined(addr)); + HDassert(md_key); + HDassert(rt_key); + HDassert(udata); + HDassert(new_node_p); /* * Load the symbol node. */ - if (NULL == (sn = H5AC_protect(f, dxpl_id, H5AC_SNODE, addr, NULL, NULL, H5AC_WRITE))) - HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, H5B_INS_ERROR, "unable to protect symbol table node"); + if(NULL == (sn = H5AC_protect(f, dxpl_id, H5AC_SNODE, addr, NULL, NULL, H5AC_WRITE))) + HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, H5B_INS_ERROR, "unable to protect symbol table node") /* Get base address of heap */ - if (NULL == (heap = H5HL_protect(f, dxpl_id, udata->common.heap_addr))) - HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, H5B_INS_ERROR, "unable to protect symbol name"); + if(NULL == (heap = H5HL_protect(f, dxpl_id, udata->common.heap_addr))) + HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, H5B_INS_ERROR, "unable to protect symbol name") base = H5HL_offset_into(f, heap, 0); @@ -1053,30 +1059,30 @@ H5G_node_insert(H5F_t *f, hid_t dxpl_id, haddr_t addr, void UNUSED *_lt_key, * Where does the new symbol get inserted? We use a binary search. */ rt = sn->nsyms; - while (lt < rt) { + while(lt < rt) { idx = (lt + rt) / 2; - s=base+sn->entry[idx].name_off; + s = base + sn->entry[idx].name_off; - if (0 == (cmp = HDstrcmp(udata->common.name, s))) /*already present */ { + if(0 == (cmp = HDstrcmp(udata->common.name, s))) /*already present */ { HCOMMON_ERROR(H5E_SYM, H5E_CANTINSERT, "symbol is already present in symbol table"); - if (H5HL_unprotect(f, dxpl_id, heap, udata->common.heap_addr) < 0) - HGOTO_ERROR(H5E_SYM, H5E_PROTECT, H5B_INS_ERROR, "unable to unprotect symbol name"); - heap=NULL; base=NULL; + if(H5HL_unprotect(f, dxpl_id, heap, udata->common.heap_addr) < 0) + HGOTO_ERROR(H5E_SYM, H5E_PROTECT, H5B_INS_ERROR, "unable to unprotect symbol name") + heap = NULL; base = NULL; - HGOTO_DONE(H5B_INS_ERROR); - } + HGOTO_DONE(H5B_INS_ERROR) + } /* end if */ if (cmp < 0) rt = idx; else lt = idx + 1; - } + } /* end while */ idx += cmp > 0 ? 1 : 0; - if (H5HL_unprotect(f, dxpl_id, heap, udata->common.heap_addr) < 0) - HGOTO_ERROR(H5E_SYM, H5E_PROTECT, H5B_INS_ERROR, "unable to unprotect symbol name"); - heap=NULL; base=NULL; + if(H5HL_unprotect(f, dxpl_id, heap, udata->common.heap_addr) < 0) + HGOTO_ERROR(H5E_SYM, H5E_PROTECT, H5B_INS_ERROR, "unable to unprotect symbol name") + heap = NULL; base = NULL; /* * Add the new name to the heap. @@ -1085,8 +1091,10 @@ H5G_node_insert(H5F_t *f, hid_t dxpl_id, haddr_t addr, void UNUSED *_lt_key, udata->common.name); udata->ent->name_off = offset; if (0==offset || (size_t)(-1)==offset) - HGOTO_ERROR(H5E_SYM, H5E_CANTINSERT, H5B_INS_ERROR, "unable to insert symbol name into heap"); - if (sn->nsyms >= 2*H5F_SYM_LEAF_K(f)) { + HGOTO_ERROR(H5E_SYM, H5E_CANTINSERT, H5B_INS_ERROR, "unable to insert symbol name into heap") + + /* Determine where to place entry in node */ + if(sn->nsyms >= 2 * H5F_SYM_LEAF_K(f)) { /* * The node is full. Split it into a left and right * node and return the address of the new right node (the @@ -1095,12 +1103,11 @@ H5G_node_insert(H5F_t *f, hid_t dxpl_id, haddr_t addr, void UNUSED *_lt_key, ret_value = H5B_INS_RIGHT; /* The right node */ - if (H5G_node_create(f, dxpl_id, H5B_INS_FIRST, NULL, NULL, NULL, - new_node_p/*out*/)<0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, H5B_INS_ERROR, "unable to split symbol table node"); + if(H5G_node_create(f, dxpl_id, H5B_INS_FIRST, NULL, NULL, NULL, new_node_p/*out*/) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, H5B_INS_ERROR, "unable to split symbol table node") - if (NULL == (snrt = H5AC_protect(f, dxpl_id, H5AC_SNODE, *new_node_p, NULL, NULL, H5AC_WRITE))) - HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, H5B_INS_ERROR, "unable to split symbol table node"); + if(NULL == (snrt = H5AC_protect(f, dxpl_id, H5AC_SNODE, *new_node_p, NULL, NULL, H5AC_WRITE))) + HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, H5B_INS_ERROR, "unable to split symbol table node") HDmemcpy(snrt->entry, sn->entry + H5F_SYM_LEAF_K(f), H5F_SYM_LEAF_K(f) * sizeof(H5G_entry_t)); @@ -1117,37 +1124,36 @@ H5G_node_insert(H5F_t *f, hid_t dxpl_id, haddr_t addr, void UNUSED *_lt_key, md_key->offset = sn->entry[sn->nsyms - 1].name_off; /* Where to insert the new entry? */ - if (idx <= (int)H5F_SYM_LEAF_K(f)) { + if(idx <= (int)H5F_SYM_LEAF_K(f)) { insert_into = sn; - if (idx == (int)H5F_SYM_LEAF_K(f)) + if(idx == (int)H5F_SYM_LEAF_K(f)) md_key->offset = offset; } else { idx -= H5F_SYM_LEAF_K(f); insert_into = snrt; - if (idx == (int)H5F_SYM_LEAF_K (f)) { + if(idx == (int)H5F_SYM_LEAF_K (f)) { rt_key->offset = offset; *rt_key_changed = TRUE; - } - } + } /* end if */ + } /* end else */ } else { /* Where to insert the new entry? */ ret_value = H5B_INS_NOOP; sn->cache_info.is_dirty = TRUE; insert_into = sn; - if (idx == (int)sn->nsyms) { + if(idx == (int)sn->nsyms) { rt_key->offset = offset; *rt_key_changed = TRUE; - } - } + } /* end if */ + } /* end else */ /* Move entries down to make room for new entry */ - HDmemmove(insert_into->entry + idx + 1, - insert_into->entry + idx, + HDmemmove(insert_into->entry + idx + 1, insert_into->entry + idx, (insert_into->nsyms - idx) * sizeof(H5G_entry_t)); /* Copy new entry into table */ - /* (use H5G_COPY_NULL because we don't track the object names in the table) */ - H5G_ent_copy(&(insert_into->entry[idx]), udata->ent, H5G_COPY_NULL); + if(H5G_ent_copy(&(insert_into->entry[idx]), udata->ent, H5_COPY_NULL) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTCOPY, H5B_INS_ERROR, "unable to copy entry") /* Flag entry as dirty */ insert_into->entry[idx].dirty = TRUE; @@ -1156,13 +1162,13 @@ H5G_node_insert(H5F_t *f, hid_t dxpl_id, haddr_t addr, void UNUSED *_lt_key, insert_into->nsyms += 1; done: - if (snrt && H5AC_unprotect(f, dxpl_id, H5AC_SNODE, *new_node_p, snrt, FALSE) < 0) - HDONE_ERROR(H5E_SYM, H5E_PROTECT, H5B_INS_ERROR, "unable to release symbol table node"); - if (sn && H5AC_unprotect(f, dxpl_id, H5AC_SNODE, addr, sn, FALSE) < 0) - HDONE_ERROR(H5E_SYM, H5E_PROTECT, H5B_INS_ERROR, "unable to release symbol table node"); + if(snrt && H5AC_unprotect(f, dxpl_id, H5AC_SNODE, *new_node_p, snrt, FALSE) < 0) + HDONE_ERROR(H5E_SYM, H5E_PROTECT, H5B_INS_ERROR, "unable to release symbol table node") + if(sn && H5AC_unprotect(f, dxpl_id, H5AC_SNODE, addr, sn, FALSE) < 0) + HDONE_ERROR(H5E_SYM, H5E_PROTECT, H5B_INS_ERROR, "unable to release symbol table node") - FUNC_LEAVE_NOAPI(ret_value); -} + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5G_node_insert() */ /*------------------------------------------------------------------------- @@ -1191,16 +1197,6 @@ done: * Programmer: Robb Matzke * Thursday, September 24, 1998 * - * Modifications: - * Robb Matzke, 1999-07-28 - * The ADDR argument is passed by value. - * - * Pedro Vicente, <pvn@ncsa.uiuc.edu> 18 Sep 2002 - * Added `id to name' support. - * - * Quincey Koziol, 2003-03-22 - * Added support for deleting all the entries at once. - * *------------------------------------------------------------------------- */ static H5B_ins_t @@ -1214,74 +1210,73 @@ H5G_node_remove(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_lt_key/*in,out*/, H5G_bt_ud2_t *udata = (H5G_bt_ud2_t *)_udata; H5G_node_t *sn = NULL; const H5HL_t *heap = NULL; - unsigned lt=0, rt, idx=0; - int cmp=1; + unsigned lt = 0, rt, idx = 0; + int cmp = 1; const char *s = NULL; const char *base; /* Base of heap */ H5B_ins_t ret_value = H5B_INS_ERROR; - FUNC_ENTER_NOAPI_NOINIT(H5G_node_remove); + FUNC_ENTER_NOAPI_NOINIT(H5G_node_remove) /* Check arguments */ - assert(f); - assert(H5F_addr_defined(addr)); - assert(lt_key); - assert(rt_key); - assert(udata); + HDassert(f); + HDassert(H5F_addr_defined(addr)); + HDassert(lt_key); + HDassert(rt_key); + HDassert(udata); /* Load the symbol table */ - if (NULL==(sn=H5AC_protect(f, dxpl_id, H5AC_SNODE, addr, NULL, NULL, H5AC_WRITE))) - HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, H5B_INS_ERROR, "unable to protect symbol table node"); + if(NULL == (sn = H5AC_protect(f, dxpl_id, H5AC_SNODE, addr, NULL, NULL, H5AC_WRITE))) + HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, H5B_INS_ERROR, "unable to protect symbol table node") /* "Normal" removal of a single entry from the symbol table node */ - if(udata->common.name!=NULL) { - size_t len=0; + if(udata->common.name != NULL) { + size_t len = 0; hbool_t found; /* Indicate that the string was found */ /* Get base address of heap */ - if (NULL == (heap = H5HL_protect(f, dxpl_id, udata->common.heap_addr))) - HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, H5B_INS_ERROR, "unable to protect symbol name"); + if(NULL == (heap = H5HL_protect(f, dxpl_id, udata->common.heap_addr))) + HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, H5B_INS_ERROR, "unable to protect symbol name") base = H5HL_offset_into(f, heap, 0); /* Find the name with a binary search */ rt = sn->nsyms; - while (lt<rt && cmp) { - idx = (lt+rt)/2; - s=base+sn->entry[idx].name_off; + while(lt < rt && cmp) { + idx = (lt + rt) / 2; + s = base + sn->entry[idx].name_off; cmp = HDstrcmp(udata->common.name, s); - if (cmp<0) { + if(cmp < 0) rt = idx; - } else { - lt = idx+1; - } - } + else + lt = idx + 1; + } /* end while */ - if (H5HL_unprotect(f, dxpl_id, heap, udata->common.heap_addr) < 0) - HDONE_ERROR(H5E_SYM, H5E_PROTECT, H5B_INS_ERROR, "unable to unprotect symbol name"); - heap=NULL; base=NULL; + if(H5HL_unprotect(f, dxpl_id, heap, udata->common.heap_addr) < 0) + HGOTO_ERROR(H5E_SYM, H5E_PROTECT, H5B_INS_ERROR, "unable to unprotect symbol name") + heap = NULL; base = NULL; - if (cmp) - HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, H5B_INS_ERROR, "not found"); + if(cmp) + HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, H5B_INS_ERROR, "not found") - if (H5G_CACHED_SLINK==sn->entry[idx].type) { + if(H5G_CACHED_SLINK == sn->entry[idx].type) { /* Remove the symbolic link value */ - if (NULL == (heap = H5HL_protect(f, dxpl_id, udata->common.heap_addr))) - HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, H5B_INS_ERROR, "unable to protect symbol name"); + if(NULL == (heap = H5HL_protect(f, dxpl_id, udata->common.heap_addr))) + HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, H5B_INS_ERROR, "unable to protect symbol name") s = H5HL_offset_into(f, heap, sn->entry[idx].cache.slink.lval_offset); - if (s) { - len=HDstrlen(s)+1; - found=1; + if(s) { + len = HDstrlen(s) + 1; + found = 1; } /* end if */ else - found=0; + found = 0; - if (H5HL_unprotect(f, dxpl_id, heap, udata->common.heap_addr) < 0) - HGOTO_ERROR(H5E_SYM, H5E_PROTECT, H5B_INS_ERROR, "unable to unprotect symbol name"); - heap=NULL; s=NULL; + if(H5HL_unprotect(f, dxpl_id, heap, udata->common.heap_addr) < 0) + HGOTO_ERROR(H5E_SYM, H5E_PROTECT, H5B_INS_ERROR, "unable to unprotect symbol name") + heap = NULL; s = NULL; - if (found) + if(found) H5HL_remove(f, dxpl_id, udata->common.heap_addr, sn->entry[idx].cache.slink.lval_offset, len); H5E_clear(); /* no big deal */ @@ -1289,55 +1284,55 @@ H5G_node_remove(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_lt_key/*in,out*/, /* Decrement the reference count, if requested */ if(udata->adj_link) { HDassert(H5F_addr_defined(sn->entry[idx].header)); - if (H5O_link(sn->entry+idx, -1, dxpl_id)<0) + if(H5O_link(sn->entry+idx, -1, dxpl_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, H5B_INS_ERROR, "unable to decrement object link count") } /* end if */ - } + } /* end else */ /* Remove the name from the local heap */ - if (NULL == (heap = H5HL_protect(f, dxpl_id, udata->common.heap_addr))) - HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, H5B_INS_ERROR, "unable to protect symbol name"); + if(NULL == (heap = H5HL_protect(f, dxpl_id, udata->common.heap_addr))) + HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, H5B_INS_ERROR, "unable to protect symbol name") s = H5HL_offset_into(f, heap, sn->entry[idx].name_off); - if (s) { - len=HDstrlen(s)+1; - found=1; + if(s) { + len = HDstrlen(s) + 1; + found = 1; } /* end if */ else - found=0; + found = 0; - if (H5HL_unprotect(f, dxpl_id, heap, udata->common.heap_addr) < 0) - HGOTO_ERROR(H5E_SYM, H5E_PROTECT, H5B_INS_ERROR, "unable to unprotect symbol name"); - heap=NULL; s=NULL; + if(H5HL_unprotect(f, dxpl_id, heap, udata->common.heap_addr) < 0) + HGOTO_ERROR(H5E_SYM, H5E_PROTECT, H5B_INS_ERROR, "unable to unprotect symbol name") + heap = NULL; s = NULL; - if (found) + if(found) H5HL_remove(f, dxpl_id, udata->common.heap_addr, sn->entry[idx].name_off, len); H5E_clear(); /* no big deal */ /* Remove the entry from the symbol table node */ - if(1==sn->nsyms) { + if(1 == sn->nsyms) { /* * We are about to remove the only symbol in this node. Copy the left * key to the right key and mark the right key as dirty. Free this * node and indicate that the pointer to this node in the B-tree * should be removed also. */ - assert(0==idx); + HDassert(0 == idx); *rt_key = *lt_key; *rt_key_changed = TRUE; sn->nsyms = 0; sn->cache_info.is_dirty = TRUE; - if (H5MF_xfree(f, H5FD_MEM_BTREE, dxpl_id, addr, (hsize_t)H5G_node_size(f))<0 + if(H5MF_xfree(f, H5FD_MEM_BTREE, dxpl_id, addr, (hsize_t)H5G_node_size(f)) < 0 || H5AC_unprotect(f, dxpl_id, H5AC_SNODE, addr, sn, TRUE)<0) { sn = NULL; - HGOTO_ERROR(H5E_SYM, H5E_PROTECT, H5B_INS_ERROR, "unable to free symbol table node"); - } + HGOTO_ERROR(H5E_SYM, H5E_PROTECT, H5B_INS_ERROR, "unable to free symbol table node") + } /* end if */ sn = NULL; ret_value = H5B_INS_REMOVE; - } else if (0==idx) { + } else if(0 == idx) { /* * We are about to remove the left-most entry from the symbol table * node but there are other entries to the right. No key values @@ -1345,11 +1340,11 @@ H5G_node_remove(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_lt_key/*in,out*/, */ sn->nsyms -= 1; sn->cache_info.is_dirty = TRUE; - HDmemmove(sn->entry+idx, sn->entry+idx+1, - (sn->nsyms-idx)*sizeof(H5G_entry_t)); + HDmemmove(sn->entry + idx, sn->entry + idx + 1, + (sn->nsyms-idx) * sizeof(H5G_entry_t)); ret_value = H5B_INS_NOOP; - } else if (idx+1==sn->nsyms) { + } else if (idx + 1 == sn->nsyms) { /* * We are about to remove the right-most entry from the symbol table * node but there are other entries to the left. The right key @@ -1357,7 +1352,7 @@ H5G_node_remove(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_lt_key/*in,out*/, */ sn->nsyms -= 1; sn->cache_info.is_dirty = TRUE; - rt_key->offset = sn->entry[sn->nsyms-1].name_off; + rt_key->offset = sn->entry[sn->nsyms - 1].name_off; *rt_key_changed = TRUE; ret_value = H5B_INS_NOOP; @@ -1368,20 +1363,20 @@ H5G_node_remove(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_lt_key/*in,out*/, */ sn->nsyms -= 1; sn->cache_info.is_dirty = TRUE; - HDmemmove(sn->entry+idx, sn->entry+idx+1, - (sn->nsyms-idx)*sizeof(H5G_entry_t)); + HDmemmove(sn->entry + idx, sn->entry + idx + 1, + (sn->nsyms - idx) * sizeof(H5G_entry_t)); ret_value = H5B_INS_NOOP; - } + } /* end else */ } /* end if */ /* Remove all entries from node, during B-tree deletion */ else { /* Reduce the link count for all entries in this node */ - for(idx=0; idx<sn->nsyms; idx++) { - if (H5G_CACHED_SLINK!=sn->entry[idx].type) { + for(idx = 0; idx < sn->nsyms; idx++) { + if(H5G_CACHED_SLINK != sn->entry[idx].type) { /* Decrement the reference count, if requested */ if(udata->adj_link) { HDassert(H5F_addr_defined(sn->entry[idx].header)); - if (H5O_link(sn->entry+idx, -1, dxpl_id)<0) + if (H5O_link(sn->entry+idx, -1, dxpl_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTDELETE, H5B_INS_ERROR, "unable to decrement object link count") } /* end if */ } /* end if */ @@ -1397,21 +1392,21 @@ H5G_node_remove(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_lt_key/*in,out*/, *rt_key_changed = TRUE; sn->nsyms = 0; sn->cache_info.is_dirty = TRUE; - if (H5MF_xfree(f, H5FD_MEM_BTREE, dxpl_id, addr, (hsize_t)H5G_node_size(f))<0 + if(H5MF_xfree(f, H5FD_MEM_BTREE, dxpl_id, addr, (hsize_t)H5G_node_size(f)) < 0 || H5AC_unprotect(f, dxpl_id, H5AC_SNODE, addr, sn, TRUE)<0) { sn = NULL; - HGOTO_ERROR(H5E_SYM, H5E_PROTECT, H5B_INS_ERROR, "unable to free symbol table node"); - } + HGOTO_ERROR(H5E_SYM, H5E_PROTECT, H5B_INS_ERROR, "unable to free symbol table node") + } /* end if */ sn = NULL; ret_value = H5B_INS_REMOVE; } /* end else */ done: - if (sn && H5AC_unprotect(f, dxpl_id, H5AC_SNODE, addr, sn, FALSE)<0) - HDONE_ERROR(H5E_SYM, H5E_PROTECT, H5B_INS_ERROR, "unable to release symbol table node"); + if(sn && H5AC_unprotect(f, dxpl_id, H5AC_SNODE, addr, sn, FALSE) < 0) + HDONE_ERROR(H5E_SYM, H5E_PROTECT, H5B_INS_ERROR, "unable to release symbol table node") - FUNC_LEAVE_NOAPI(ret_value); -} + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5G_node_remove() */ /*------------------------------------------------------------------------- @@ -1425,12 +1420,6 @@ done: * matzke@llnl.gov * Jun 24 1997 * - * Modifications: - * Robb Matzke, 1999-07-28 - * The ADDR argument is passed by value. - * - * Quincey Koziol, 2002-04-22 - * Changed to callback from H5B_iterate *------------------------------------------------------------------------- */ int @@ -1538,8 +1527,6 @@ done: * Programmer: Raymond Lu * Nov 20, 2002 * - * Modifications: - * *------------------------------------------------------------------------- */ int @@ -1585,8 +1572,6 @@ done: * Programmer: Raymond Lu * Nov 20, 2002 * - * Modifications: - * *------------------------------------------------------------------------- */ int @@ -1655,7 +1640,6 @@ done: * Programmer: Raymond Lu * Nov 20, 2002 * - * *------------------------------------------------------------------------- */ int @@ -1663,35 +1647,38 @@ H5G_node_type(H5F_t *f, hid_t dxpl_id, const void UNUSED *_lt_key, haddr_t addr, const void UNUSED *_rt_key, void *_udata) { H5G_bt_it_ud3_t *udata = (H5G_bt_it_ud3_t*)_udata; - hsize_t loc_idx; H5G_node_t *sn = NULL; int ret_value = H5B_ITER_CONT; - FUNC_ENTER_NOAPI(H5G_node_type, H5B_ITER_ERROR); + FUNC_ENTER_NOAPI(H5G_node_type, H5B_ITER_ERROR) /* Check arguments. */ - assert(f); - assert(H5F_addr_defined(addr)); - assert(udata); + HDassert(f); + HDassert(H5F_addr_defined(addr)); + HDassert(udata); /* Find the node, locate the object symbol table entry and retrieve the type */ - if (NULL == (sn = H5AC_protect(f, dxpl_id, H5AC_SNODE, addr, NULL, NULL, H5AC_READ))) + if(NULL == (sn = H5AC_protect(f, dxpl_id, H5AC_SNODE, addr, NULL, NULL, H5AC_READ))) HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, H5B_ITER_ERROR, "unable to load symbol table node"); if(udata->idx >= udata->num_objs && udata->idx < (udata->num_objs + sn->nsyms)) { + hsize_t loc_idx; + + /* Compute index of entry */ loc_idx = udata->idx - udata->num_objs; + udata->type = H5G_get_type(&(sn->entry[loc_idx]), dxpl_id); ret_value = H5B_ITER_STOP; } else { udata->num_objs += sn->nsyms; - } + } /* end else */ done: - if (sn && H5AC_unprotect(f, dxpl_id, H5AC_SNODE, addr, sn, FALSE) != SUCCEED) + if(sn && H5AC_unprotect(f, dxpl_id, H5AC_SNODE, addr, sn, FALSE) != SUCCEED) HDONE_ERROR(H5E_SYM, H5E_PROTECT, H5B_ITER_ERROR, "unable to release object header"); FUNC_LEAVE_NOAPI(ret_value); -} +} /* end H5G_node_type() */ /*------------------------------------------------------------------------- @@ -1829,9 +1816,6 @@ H5G_node_shared_free (void *_shared) * matzke@llnl.gov * Aug 4 1997 * - * Modifications: - * Robb Matzke, 1999-07-28 - * The ADDR and HEAP arguments are passed by value. *------------------------------------------------------------------------- */ herr_t |