summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2006-11-16 04:29:18 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2006-11-16 04:29:18 (GMT)
commitfb4f4a22f7053619349b30821b7f06266e54598b (patch)
tree6b1cae17789aedb051fd1858c7a10fb0e16d8cef /src
parentab9425d057dd0a61154dc78e158707fabf45dfe2 (diff)
downloadhdf5-fb4f4a22f7053619349b30821b7f06266e54598b.zip
hdf5-fb4f4a22f7053619349b30821b7f06266e54598b.tar.gz
hdf5-fb4f4a22f7053619349b30821b7f06266e54598b.tar.bz2
[svn-r12922] Description:
Add support for "delete by index" to "old-style" groups, finishing implmentation of H5Ldelete_by_idx() routine. Tested on: FreeBSD/32 4.11 (sleipnir) Linux/32 2.4 (heping) Linux/64 2.4 (mir) Aix/32 5.? (copper)
Diffstat (limited to 'src')
-rw-r--r--src/H5Gobj.c6
-rw-r--r--src/H5Gpkg.h2
-rw-r--r--src/H5Gstab.c54
3 files changed, 57 insertions, 5 deletions
diff --git a/src/H5Gobj.c b/src/H5Gobj.c
index 6db0060..3e0310c 100644
--- a/src/H5Gobj.c
+++ b/src/H5Gobj.c
@@ -1029,8 +1029,6 @@ H5G_obj_remove_by_idx(H5O_loc_t *grp_oloc, H5RS_str_t *grp_full_path_r,
else {
/* Clear error stack from not finding the link info message */
H5E_clear_stack(NULL);
-HDfprintf(stderr, "%s: Removing by index in symbol table not supported yet!\n", FUNC);
-HGOTO_ERROR(H5E_SYM, H5E_UNSUPPORTED, FAIL, "removing by index in symbol table not supported yet")
/* Can only perform name lookups on groups with symbol tables */
if(idx_type != H5L_INDEX_NAME)
@@ -1039,11 +1037,9 @@ HGOTO_ERROR(H5E_SYM, H5E_UNSUPPORTED, FAIL, "removing by index in symbol table n
/* Using the old format for groups */
use_old_format = TRUE;
-#ifdef QAK
/* Remove object from the symbol table */
- if(H5G_stab_remove_by_idx(grp_oloc, dxpl_id, grp_full_path_r, idx_type, order, n) < 0)
+ if(H5G_stab_remove_by_idx(grp_oloc, dxpl_id, grp_full_path_r, order, n) < 0)
HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "can't remove object")
-#endif /* QAK */
} /* end else */
/* Update link info for a new-style group */
diff --git a/src/H5Gpkg.h b/src/H5Gpkg.h
index 84d03a8..9faf46d 100644
--- a/src/H5Gpkg.h
+++ b/src/H5Gpkg.h
@@ -379,6 +379,8 @@ H5_DLL H5G_obj_t H5G_stab_get_type_by_idx(H5O_loc_t *oloc, hsize_t idx,
hid_t dxpl_id);
H5_DLL herr_t H5G_stab_remove(H5O_loc_t *oloc, hid_t dxpl_id,
H5RS_str_t *grp_full_path_r, const char *name);
+H5_DLL herr_t H5G_stab_remove_by_idx(H5O_loc_t *oloc, hid_t dxpl_id,
+ H5RS_str_t *grp_full_path_r, H5_iter_order_t order, hsize_t n);
H5_DLL herr_t H5G_stab_lookup(H5O_loc_t *grp_oloc, const char *name,
H5O_link_t *lnk, hid_t dxpl_id);
H5_DLL herr_t H5G_stab_lookup_by_idx(H5O_loc_t *grp_oloc, H5_iter_order_t order,
diff --git a/src/H5Gstab.c b/src/H5Gstab.c
index ec813d8..f87294b 100644
--- a/src/H5Gstab.c
+++ b/src/H5Gstab.c
@@ -325,6 +325,60 @@ done:
/*-------------------------------------------------------------------------
+ * Function: H5G_stab_remove_by_idx
+ *
+ * Purpose: Remove NAME from a symbol table, according to the name index.
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: Quincey Koziol
+ * Wednesday, November 15, 2006
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5G_stab_remove_by_idx(H5O_loc_t *grp_oloc, hid_t dxpl_id, H5RS_str_t *grp_full_path_r,
+ H5_iter_order_t order, hsize_t n)
+{
+ H5O_stab_t stab; /* Symbol table message */
+ H5G_bt_ud2_t udata; /* Data to pass through B-tree */
+ H5O_link_t obj_lnk; /* Object's link within group */
+ hbool_t lnk_copied = FALSE; /* Whether the link was copied */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI(H5G_stab_remove_by_idx, FAIL)
+
+ HDassert(grp_oloc && grp_oloc->file);
+
+ /* Look up name of link to remove, by index */
+ if(H5G_stab_lookup_by_idx(grp_oloc, order, n, &obj_lnk, dxpl_id) < 0)
+ HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't get link information")
+ lnk_copied = TRUE;
+
+ /* Read in symbol table message */
+ if(NULL == H5O_read(grp_oloc, H5O_STAB_ID, 0, &stab, dxpl_id))
+ HGOTO_ERROR(H5E_SYM, H5E_BADMESG, FAIL, "not a symbol table")
+
+ /* Initialize data to pass through B-tree */
+ udata.common.name = obj_lnk.name;
+ udata.common.heap_addr = stab.heap_addr;
+ udata.adj_link = TRUE;
+ udata.grp_full_path_r = grp_full_path_r;
+
+ /* Remove link from symbol table */
+ if(H5B_remove(grp_oloc->file, dxpl_id, H5B_SNODE, stab.btree_addr, &udata) < 0)
+ HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to remove entry")
+
+done:
+ /* Reset the link information, if we have a copy */
+ if(lnk_copied)
+ H5O_reset(H5O_LINK_ID, &obj_lnk);
+
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5G_stab_remove() */
+
+
+/*-------------------------------------------------------------------------
* Function: H5G_stab_delete
*
* Purpose: Delete entire symbol table information from file