summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/H5G.c2
-rw-r--r--src/H5Gcompact.c2
-rw-r--r--src/H5Gdense.c26
-rw-r--r--src/H5Gobj.c93
-rw-r--r--src/H5Gpkg.h10
-rw-r--r--src/H5Gstab.c4
-rw-r--r--src/H5Gtest.c12
-rw-r--r--src/H5Gtraverse.c2
-rw-r--r--src/H5O.c40
-rw-r--r--src/H5Ocache.c5
-rw-r--r--src/H5Ocopy.c1
-rw-r--r--src/H5Olinfo.c22
-rw-r--r--src/H5Omessage.c2
-rw-r--r--src/H5Opkg.h1
-rw-r--r--src/H5Oprivate.h5
-rw-r--r--src/H5Orefcount.c4
16 files changed, 164 insertions, 67 deletions
diff --git a/src/H5G.c b/src/H5G.c
index 64eb8c2..b193e61 100644
--- a/src/H5G.c
+++ b/src/H5G.c
@@ -561,7 +561,7 @@ H5Gget_create_plist(hid_t group_id)
H5O_linfo_t linfo; /* Link info message */
/* Read the link info */
- if(NULL == H5O_msg_read(&(grp->oloc), H5O_LINFO_ID, &linfo, H5AC_ind_dxpl_id))
+ if(NULL == H5G_obj_get_linfo(&(grp->oloc), &linfo, H5AC_ind_dxpl_id))
HGOTO_ERROR(H5E_SYM, H5E_BADMESG, FAIL, "can't get link info")
/* Set the link info for the property list */
diff --git a/src/H5Gcompact.c b/src/H5Gcompact.c
index 9476716..90ac2d0 100644
--- a/src/H5Gcompact.c
+++ b/src/H5Gcompact.c
@@ -183,7 +183,7 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5G_compact_insert(H5O_loc_t *grp_oloc, H5O_link_t *obj_lnk,
+H5G_compact_insert(const H5O_loc_t *grp_oloc, H5O_link_t *obj_lnk,
hid_t dxpl_id)
{
herr_t ret_value = SUCCEED; /* Return value */
diff --git a/src/H5Gdense.c b/src/H5Gdense.c
index ded0549..0b7ae9e 100644
--- a/src/H5Gdense.c
+++ b/src/H5Gdense.c
@@ -303,10 +303,10 @@ H5G_dense_create(H5F_t *f, hid_t dxpl_id, H5O_linfo_t *linfo)
HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create fractal heap")
/* Retrieve the heap's address in the file */
- if(H5HF_get_heap_addr(fheap, &(linfo->link_fheap_addr)) < 0)
+ if(H5HF_get_heap_addr(fheap, &(linfo->fheap_addr)) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTGETSIZE, FAIL, "can't get fractal heap address")
#ifdef QAK
-HDfprintf(stderr, "%s: linfo->link_fheap_addr = %a\n", FUNC, linfo->link_fheap_addr);
+HDfprintf(stderr, "%s: linfo->fheap_addr = %a\n", FUNC, linfo->fheap_addr);
#endif /* QAK */
/* Retrieve the heap's ID length in the file */
@@ -386,7 +386,7 @@ H5G_dense_insert(H5F_t *f, hid_t dxpl_id, const H5O_linfo_t *linfo,
HDassert(linfo);
HDassert(lnk);
#ifdef QAK
-HDfprintf(stderr, "%s: linfo->link_fheap_addr = %a\n", FUNC, linfo->link_fheap_addr);
+HDfprintf(stderr, "%s: linfo->fheap_addr = %a\n", FUNC, linfo->fheap_addr);
HDfprintf(stderr, "%s: linfo->name_bt2_addr = %a\n", FUNC, linfo->name_bt2_addr);
#endif /* QAK */
@@ -410,7 +410,7 @@ HDfprintf(stderr, "%s: HDstrlen(lnk->name) = %Zu, link_size = %Zu\n", FUNC, HDst
HGOTO_ERROR(H5E_SYM, H5E_CANTENCODE, FAIL, "can't encode link")
/* Open the fractal heap */
- if(NULL == (fheap = H5HF_open(f, dxpl_id, linfo->link_fheap_addr)))
+ if(NULL == (fheap = H5HF_open(f, dxpl_id, linfo->fheap_addr)))
HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open fractal heap")
/* Insert the serialized link into the fractal heap */
@@ -520,7 +520,7 @@ H5G_dense_lookup(H5F_t *f, hid_t dxpl_id, const H5O_linfo_t *linfo,
HDassert(lnk);
/* Open the fractal heap */
- if(NULL == (fheap = H5HF_open(f, dxpl_id, linfo->link_fheap_addr)))
+ if(NULL == (fheap = H5HF_open(f, dxpl_id, linfo->fheap_addr)))
HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open fractal heap")
/* Construct the user data for v2 B-tree callback */
@@ -687,7 +687,7 @@ H5G_dense_lookup_by_idx(H5F_t *f, hid_t dxpl_id, const H5O_linfo_t *linfo,
H5G_bt2_ud_lbi_t udata; /* User data for v2 B-tree link lookup */
/* Open the fractal heap */
- if(NULL == (fheap = H5HF_open(f, dxpl_id, linfo->link_fheap_addr)))
+ if(NULL == (fheap = H5HF_open(f, dxpl_id, linfo->fheap_addr)))
HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open fractal heap")
/* Construct the user data for v2 B-tree callback */
@@ -1011,7 +1011,7 @@ H5G_dense_iterate(H5F_t *f, hid_t dxpl_id, const H5O_linfo_t *linfo,
H5G_bt2_ud_it_t udata; /* User data for iterator callback */
/* Open the fractal heap */
- if(NULL == (fheap = H5HF_open(f, dxpl_id, linfo->link_fheap_addr)))
+ if(NULL == (fheap = H5HF_open(f, dxpl_id, linfo->fheap_addr)))
HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open fractal heap")
/* Construct the user data for v2 B-tree iterator callback */
@@ -1205,7 +1205,7 @@ H5G_dense_get_name_by_idx(H5F_t *f, hid_t dxpl_id, H5O_linfo_t *linfo,
H5G_bt2_ud_gnbi_t udata; /* User data for v2 B-tree callback */
/* Open the fractal heap */
- if(NULL == (fheap = H5HF_open(f, dxpl_id, linfo->link_fheap_addr)))
+ if(NULL == (fheap = H5HF_open(f, dxpl_id, linfo->fheap_addr)))
HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open fractal heap")
/* Set up the user data for the v2 B-tree 'record remove' callback */
@@ -1464,7 +1464,7 @@ H5G_dense_remove(H5F_t *f, hid_t dxpl_id, const H5O_linfo_t *linfo,
HDassert(name && *name);
/* Open the fractal heap */
- if(NULL == (fheap = H5HF_open(f, dxpl_id, linfo->link_fheap_addr)))
+ if(NULL == (fheap = H5HF_open(f, dxpl_id, linfo->fheap_addr)))
HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open fractal heap")
/* Set up the user data for the v2 B-tree 'record remove' callback */
@@ -1696,7 +1696,7 @@ H5G_dense_remove_by_idx(H5F_t *f, hid_t dxpl_id, const H5O_linfo_t *linfo,
H5G_bt2_ud_rmbi_t udata; /* User data for v2 B-tree record removal */
/* Open the fractal heap */
- if(NULL == (fheap = H5HF_open(f, dxpl_id, linfo->link_fheap_addr)))
+ if(NULL == (fheap = H5HF_open(f, dxpl_id, linfo->fheap_addr)))
HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open fractal heap")
/* Set up the user data for the v2 B-tree 'remove by index' callback */
@@ -1772,7 +1772,7 @@ H5G_dense_delete(H5F_t *f, hid_t dxpl_id, H5O_linfo_t *linfo, hbool_t adj_link)
H5G_bt2_ud_rm_t udata; /* User data for v2 B-tree record removal */
/* Open the fractal heap */
- if(NULL == (fheap = H5HF_open(f, dxpl_id, linfo->link_fheap_addr)))
+ if(NULL == (fheap = H5HF_open(f, dxpl_id, linfo->fheap_addr)))
HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open fractal heap")
/* Set up the user data for the v2 B-tree 'record remove' callback */
@@ -1815,9 +1815,9 @@ H5G_dense_delete(H5F_t *f, hid_t dxpl_id, H5O_linfo_t *linfo, hbool_t adj_link)
HDassert(!H5F_addr_defined(linfo->corder_bt2_addr));
/* Delete the fractal heap */
- if(H5HF_delete(f, dxpl_id, linfo->link_fheap_addr) < 0)
+ if(H5HF_delete(f, dxpl_id, linfo->fheap_addr) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTDELETE, FAIL, "unable to delete fractal heap")
- linfo->link_fheap_addr = HADDR_UNDEF;
+ linfo->fheap_addr = HADDR_UNDEF;
done:
FUNC_LEAVE_NOAPI(ret_value)
diff --git a/src/H5Gobj.c b/src/H5Gobj.c
index f262c4b..e91b162 100644
--- a/src/H5Gobj.c
+++ b/src/H5Gobj.c
@@ -77,7 +77,7 @@ typedef struct {
* a new-format group
*/
typedef struct {
- H5O_loc_t *grp_oloc; /* Pointer to group for insertion */
+ const H5O_loc_t *grp_oloc; /* Pointer to group for insertion */
hid_t dxpl_id; /* DXPL during insertion */
} H5G_obj_stab_it_ud1_t;
@@ -308,6 +308,57 @@ H5G_obj_ent_encode(const H5F_t *f, uint8_t **pp, const H5O_loc_t *oloc)
/*-------------------------------------------------------------------------
+ * Function: H5G_obj_get_linfo
+ *
+ * Purpose: Retrieves the "link info" message for an object. Also
+ * sets the number of links correctly, if it isn't set up yet.
+ *
+ * Return: Success: Ptr to message in native format.
+ * Failure: NULL
+ *
+ * Programmer: Quincey Koziol
+ * koziol@hdfgroup.org
+ * Mar 11 2007
+ *
+ *-------------------------------------------------------------------------
+ */
+H5O_linfo_t *
+H5G_obj_get_linfo(const H5O_loc_t *grp_oloc, H5O_linfo_t *linfo, hid_t dxpl_id)
+{
+ H5O_linfo_t *ret_value; /* Return value */
+
+ FUNC_ENTER_NOAPI(H5G_obj_get_linfo, NULL)
+
+ /* check arguments */
+ HDassert(grp_oloc);
+
+ /* Retrieve the "link info" structure */
+ if(ret_value = H5O_msg_read(grp_oloc, H5O_LINFO_ID, linfo, dxpl_id)) {
+ /* Check if we don't know how many links there are */
+ if(ret_value->nlinks == HSIZET_MAX) {
+ /* Check if we are using "dense" link storage */
+ if(H5F_addr_defined(ret_value->fheap_addr)) {
+ /* Retrieve # of records in "name" B-tree */
+ /* (should be same # of records in all indices) */
+ if(H5B2_get_nrec(grp_oloc->file, dxpl_id, H5G_BT2_NAME, ret_value->name_bt2_addr, &ret_value->nlinks) < 0)
+ HGOTO_ERROR(H5E_SYM, H5E_CANTGET, NULL, "can't retrieve # of records in index")
+ } /* end if */
+ else {
+ /* Retrieve # of links from object header */
+ if(H5O_get_nlinks(grp_oloc, dxpl_id, &ret_value->nlinks) < 0)
+ HGOTO_ERROR(H5E_SYM, H5E_CANTGET, NULL, "can't retrieve # of links for object")
+ } /* end if */
+ } /* end if */
+ } /* end if */
+ else
+ HGOTO_ERROR(H5E_SYM, H5E_CANTGET, NULL, "link info message not present")
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5G_obj_get_linfo() */
+
+
+/*-------------------------------------------------------------------------
* Function: H5G_obj_compact_to_dense_cb
*
* Purpose: Callback routine for converting "compact" to "dense"
@@ -397,7 +448,7 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5G_obj_insert(H5O_loc_t *grp_oloc, const char *name, H5O_link_t *obj_lnk,
+H5G_obj_insert(const H5O_loc_t *grp_oloc, const char *name, H5O_link_t *obj_lnk,
hbool_t adj_link, hid_t dxpl_id)
{
H5O_linfo_t linfo; /* Link info message */
@@ -414,7 +465,7 @@ H5G_obj_insert(H5O_loc_t *grp_oloc, const char *name, H5O_link_t *obj_lnk,
/* Check if we have information about the number of objects in this group */
/* (by attempting to get the link info message for this group) */
- if(H5O_msg_read(grp_oloc, H5O_LINFO_ID, &linfo, dxpl_id)) {
+ if(H5G_obj_get_linfo(grp_oloc, &linfo, dxpl_id)) {
H5O_ginfo_t ginfo; /* Group info message */
size_t link_msg_size; /* Size of new link message in the file */
@@ -443,7 +494,7 @@ H5G_obj_insert(H5O_loc_t *grp_oloc, const char *name, H5O_link_t *obj_lnk,
/* (If the encoded form of the link is too large to fit into an object
* header message, convert to using dense link storage instead of link messages)
*/
- if(H5F_addr_defined(linfo.link_fheap_addr))
+ if(H5F_addr_defined(linfo.fheap_addr))
use_new_dense = TRUE;
else if(linfo.nlinks < ginfo.max_compact && link_msg_size < H5O_MESG_MAX_SIZE)
use_new_dense = FALSE;
@@ -608,7 +659,7 @@ H5G_obj_iterate(hid_t loc_id, const char *group_name,
HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "bad group ID")
/* Attempt to get the link info for this group */
- if(H5O_msg_read(&(grp->oloc), H5O_LINFO_ID, &linfo, dxpl_id)) {
+ if(H5G_obj_get_linfo(&(grp->oloc), &linfo, dxpl_id)) {
/* Check for going out of bounds */
if(skip > 0 && (size_t)skip >= linfo.nlinks)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "index out of bound")
@@ -620,7 +671,7 @@ H5G_obj_iterate(hid_t loc_id, const char *group_name,
HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "creation order not tracked for links in group")
} /* end if */
- if(H5F_addr_defined(linfo.link_fheap_addr)) {
+ if(H5F_addr_defined(linfo.fheap_addr)) {
/* Iterate over the links in the group, building a table of the link messages */
if((ret_value = H5G_dense_iterate(grp->oloc.file, dxpl_id, &linfo, idx_type, order, skip, last_lnk, gid, lnk_op, op_data)) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTNEXT, FAIL, "error iterating over links")
@@ -678,13 +729,13 @@ H5G_obj_info(H5O_loc_t *oloc, H5G_info_t *grp_info, hid_t dxpl_id)
HDassert(grp_info);
/* Attempt to get the link info for this group */
- if(H5O_msg_read(oloc, H5O_LINFO_ID, &linfo, dxpl_id)) {
+ if(H5G_obj_get_linfo(oloc, &linfo, dxpl_id)) {
/* Retrieve the information about the links */
grp_info->nlinks = linfo.nlinks;
grp_info->max_corder = linfo.max_corder;
/* Check if the group is using compact or dense storage for its links */
- if(H5F_addr_defined(linfo.link_fheap_addr))
+ if(H5F_addr_defined(linfo.fheap_addr))
grp_info->storage_type = H5G_STORAGE_TYPE_DENSE;
else
grp_info->storage_type = H5G_STORAGE_TYPE_COMPACT;
@@ -734,7 +785,7 @@ H5G_obj_get_name_by_idx(H5O_loc_t *oloc, H5_index_t idx_type,
HDassert(oloc && oloc->file);
/* Attempt to get the link info for this group */
- if(H5O_msg_read(oloc, H5O_LINFO_ID, &linfo, dxpl_id)) {
+ if(H5G_obj_get_linfo(oloc, &linfo, dxpl_id)) {
/* Check for creation order tracking, if creation order index lookup requested */
if(idx_type == H5_INDEX_CRT_ORDER) {
/* Check if creation order is tracked */
@@ -743,7 +794,7 @@ H5G_obj_get_name_by_idx(H5O_loc_t *oloc, H5_index_t idx_type,
} /* end if */
/* Check for dense link storage */
- if(H5F_addr_defined(linfo.link_fheap_addr)) {
+ if(H5F_addr_defined(linfo.fheap_addr)) {
/* Get the object's name from the dense link storage */
if((ret_value = H5G_dense_get_name_by_idx(oloc->file, dxpl_id, &linfo, idx_type, order, n, name, size)) < 0)
HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "can't locate name")
@@ -799,8 +850,8 @@ H5G_obj_get_type_by_idx(H5O_loc_t *oloc, hsize_t idx, hid_t dxpl_id)
HDassert(oloc);
/* Attempt to get the link info for this group */
- if(H5O_msg_read(oloc, H5O_LINFO_ID, &linfo, dxpl_id)) {
- if(H5F_addr_defined(linfo.link_fheap_addr)) {
+ if(H5G_obj_get_linfo(oloc, &linfo, dxpl_id)) {
+ if(H5F_addr_defined(linfo.fheap_addr)) {
/* Get the object's name from the dense link storage */
if((ret_value = H5G_dense_get_type_by_idx(oloc->file, dxpl_id, &linfo, idx)) < 0)
HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, H5G_UNKNOWN, "can't locate type")
@@ -857,7 +908,7 @@ H5G_obj_remove_update_linfo(H5O_loc_t *oloc, H5O_linfo_t *linfo, hid_t dxpl_id)
linfo->max_corder = 0;
/* Check for transitioning out of dense storage, if we are using it */
- if(H5F_addr_defined(linfo->link_fheap_addr)) {
+ if(H5F_addr_defined(linfo->fheap_addr)) {
/* Check if there's no more links */
if(linfo->nlinks == 0) {
/* Delete the dense storage */
@@ -961,12 +1012,12 @@ H5G_obj_remove(H5O_loc_t *oloc, H5RS_str_t *grp_full_path_r, const char *name, h
HDassert(name && *name);
/* Attempt to get the link info for this group */
- if(H5O_msg_read(oloc, H5O_LINFO_ID, &linfo, dxpl_id)) {
+ if(H5G_obj_get_linfo(oloc, &linfo, dxpl_id)) {
/* Using the new format for groups */
use_old_format = FALSE;
/* Check for dense or compact storage */
- if(H5F_addr_defined(linfo.link_fheap_addr)) {
+ if(H5F_addr_defined(linfo.fheap_addr)) {
/* Remove object from the dense link storage */
if(H5G_dense_remove(oloc->file, dxpl_id, &linfo, grp_full_path_r, name) < 0)
HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "can't remove object")
@@ -1026,7 +1077,7 @@ H5G_obj_remove_by_idx(H5O_loc_t *grp_oloc, H5RS_str_t *grp_full_path_r,
HDassert(grp_oloc && grp_oloc->file);
/* Attempt to get the link info for this group */
- if(H5O_msg_read(grp_oloc, H5O_LINFO_ID, &linfo, dxpl_id)) {
+ if(H5G_obj_get_linfo(grp_oloc, &linfo, dxpl_id)) {
/* Check for creation order tracking, if creation order index lookup requested */
if(idx_type == H5_INDEX_CRT_ORDER) {
/* Check if creation order is tracked */
@@ -1038,7 +1089,7 @@ H5G_obj_remove_by_idx(H5O_loc_t *grp_oloc, H5RS_str_t *grp_full_path_r,
use_old_format = FALSE;
/* Check for dense or compact storage */
- if(H5F_addr_defined(linfo.link_fheap_addr)) {
+ if(H5F_addr_defined(linfo.fheap_addr)) {
/* Remove object from the dense link storage */
if(H5G_dense_remove_by_idx(grp_oloc->file, dxpl_id, &linfo, grp_full_path_r, idx_type, order, n) < 0)
HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "can't remove object")
@@ -1103,9 +1154,9 @@ H5G_obj_lookup(H5O_loc_t *grp_oloc, const char *name, H5O_link_t *lnk,
HDassert(name && *name);
/* Attempt to get the link info message for this group */
- if(H5O_msg_read(grp_oloc, H5O_LINFO_ID, &linfo, dxpl_id)) {
+ if(H5G_obj_get_linfo(grp_oloc, &linfo, dxpl_id)) {
/* Check for dense link storage */
- if(H5F_addr_defined(linfo.link_fheap_addr)) {
+ if(H5F_addr_defined(linfo.fheap_addr)) {
/* Get the object's info from the dense link storage */
if(H5G_dense_lookup(grp_oloc->file, dxpl_id, &linfo, name, lnk) < 0)
HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "can't locate object")
@@ -1157,7 +1208,7 @@ H5G_obj_lookup_by_idx(H5O_loc_t *grp_oloc, H5_index_t idx_type,
HDassert(grp_oloc && grp_oloc->file);
/* Attempt to get the link info message for this group */
- if(H5O_msg_read(grp_oloc, H5O_LINFO_ID, &linfo, dxpl_id)) {
+ if(H5G_obj_get_linfo(grp_oloc, &linfo, dxpl_id)) {
/* Check for creation order tracking, if creation order index lookup requested */
if(idx_type == H5_INDEX_CRT_ORDER) {
/* Check if creation order is tracked */
@@ -1166,7 +1217,7 @@ H5G_obj_lookup_by_idx(H5O_loc_t *grp_oloc, H5_index_t idx_type,
} /* end if */
/* Check for dense link storage */
- if(H5F_addr_defined(linfo.link_fheap_addr)) {
+ if(H5F_addr_defined(linfo.fheap_addr)) {
/* Get the link from the dense storage */
if(H5G_dense_lookup_by_idx(grp_oloc->file, dxpl_id, &linfo, idx_type, order, n, lnk) < 0)
HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "can't locate object")
diff --git a/src/H5Gpkg.h b/src/H5Gpkg.h
index 181d5e4..879b364 100644
--- a/src/H5Gpkg.h
+++ b/src/H5Gpkg.h
@@ -376,12 +376,12 @@ H5_DLL herr_t H5G_traverse(const H5G_loc_t *loc, const char *name,
H5_DLL herr_t H5G_stab_create(H5O_loc_t *grp_oloc, hid_t dxpl_id,
const H5O_ginfo_t *ginfo, H5O_stab_t *stab);
H5_DLL herr_t H5G_stab_create_components(H5F_t *f, H5O_stab_t *stab, size_t size_hint, hid_t dxpl_id);
-H5_DLL herr_t H5G_stab_insert(H5O_loc_t *grp_oloc, const char *name,
+H5_DLL herr_t H5G_stab_insert(const H5O_loc_t *grp_oloc, const char *name,
H5O_link_t *obj_lnk, hid_t dxpl_id);
H5_DLL herr_t H5G_stab_insert_real(H5F_t *f, H5O_stab_t *stab, const char *name,
H5O_link_t *obj_lnk, hid_t dxpl_id);
H5_DLL herr_t H5G_stab_delete(H5F_t *f, hid_t dxpl_id, const H5O_stab_t *stab);
-H5_DLL herr_t H5G_stab_iterate(H5O_loc_t *oloc, hid_t dxpl_id,
+H5_DLL herr_t H5G_stab_iterate(const H5O_loc_t *oloc, hid_t dxpl_id,
H5_iter_order_t order, hsize_t skip, hsize_t *last_lnk, hid_t gid,
H5G_link_iterate_t *lnk_op, void *op_data);
H5_DLL herr_t H5G_stab_count(struct H5O_loc_t *oloc, hsize_t *num_objs, hid_t dxpl_id);
@@ -453,7 +453,7 @@ H5_DLL herr_t H5G_link_name_replace(H5F_t *file, hid_t dxpl_id,
haddr_t lnk_addr);
/* Functions that understand "compact" link storage */
-H5_DLL herr_t H5G_compact_insert(H5O_loc_t *grp_oloc, H5O_link_t *obj_lnk,
+H5_DLL herr_t H5G_compact_insert(const H5O_loc_t *grp_oloc, H5O_link_t *obj_lnk,
hid_t dxpl_id);
H5_DLL ssize_t H5G_compact_get_name_by_idx(H5O_loc_t *oloc, hid_t dxpl_id,
const H5O_linfo_t *linfo, H5_index_t idx_type, H5_iter_order_t order,
@@ -504,7 +504,9 @@ H5_DLL herr_t H5G_dense_delete(H5F_t *f, hid_t dxpl_id, H5O_linfo_t *linfo,
/* Functions that understand group objects */
H5_DLL herr_t H5G_obj_create(H5F_t *f, hid_t dxpl_id, const H5O_ginfo_t *ginfo,
const H5O_linfo_t *linfo, hid_t gcpl_id, H5O_loc_t *oloc/*out*/);
-H5_DLL herr_t H5G_obj_insert(H5O_loc_t *grp_oloc, const char *name,
+H5_DLL H5O_linfo_t * H5G_obj_get_linfo(const H5O_loc_t *grp_oloc,
+ H5O_linfo_t *linfo, hid_t dxpl_id);
+H5_DLL herr_t H5G_obj_insert(const H5O_loc_t *grp_oloc, const char *name,
H5O_link_t *obj_lnk, hbool_t adj_link, hid_t dxpl_id);
H5_DLL herr_t H5G_obj_iterate(hid_t loc_id, const char *group_name,
H5_index_t idx_type, H5_iter_order_t order, hsize_t skip, hsize_t *last_obj,
diff --git a/src/H5Gstab.c b/src/H5Gstab.c
index e174072..431571b 100644
--- a/src/H5Gstab.c
+++ b/src/H5Gstab.c
@@ -255,7 +255,7 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5G_stab_insert(H5O_loc_t *grp_oloc, const char *name, H5O_link_t *obj_lnk,
+H5G_stab_insert(const H5O_loc_t *grp_oloc, const char *name, H5O_link_t *obj_lnk,
hid_t dxpl_id)
{
H5O_stab_t stab; /* Symbol table message */
@@ -433,7 +433,7 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5G_stab_iterate(H5O_loc_t *oloc, hid_t dxpl_id, H5_iter_order_t order,
+H5G_stab_iterate(const H5O_loc_t *oloc, hid_t dxpl_id, H5_iter_order_t order,
hsize_t skip, hsize_t *last_lnk, hid_t gid,
H5G_link_iterate_t *lnk_op, void *op_data)
{
diff --git a/src/H5Gtest.c b/src/H5Gtest.c
index b0b4d52..2921bf0 100644
--- a/src/H5Gtest.c
+++ b/src/H5Gtest.c
@@ -133,11 +133,11 @@ H5G_is_empty_test(hid_t gid)
HGOTO_ERROR(H5E_SYM, H5E_BADVALUE, FAIL, "both symbol table and link info messages found")
/* Get the link info */
- if(NULL == H5O_msg_read(&(grp->oloc), H5O_LINFO_ID, &linfo, H5AC_dxpl_id))
+ if(NULL == H5G_obj_get_linfo(&(grp->oloc), &linfo, H5AC_dxpl_id))
HGOTO_ERROR(H5E_SYM, H5E_BADMESG, FAIL, "can't get link info")
/* Check for 'dense' link storage file addresses being defined */
- if(H5F_addr_defined(linfo.link_fheap_addr))
+ if(H5F_addr_defined(linfo.fheap_addr))
HGOTO_DONE(FALSE)
if(H5F_addr_defined(linfo.name_bt2_addr))
HGOTO_DONE(FALSE)
@@ -343,11 +343,11 @@ H5G_is_new_dense_test(hid_t gid)
H5O_linfo_t linfo; /* Link info message */
/* Get the link info */
- if(NULL == H5O_msg_read(&(grp->oloc), H5O_LINFO_ID, &linfo, H5AC_dxpl_id))
+ if(NULL == H5G_obj_get_linfo(&(grp->oloc), &linfo, H5AC_dxpl_id))
HGOTO_ERROR(H5E_SYM, H5E_BADMESG, FAIL, "can't get link info")
/* Check for 'dense' link storage file addresses being defined */
- if(!H5F_addr_defined(linfo.link_fheap_addr))
+ if(!H5F_addr_defined(linfo.fheap_addr))
HGOTO_DONE(FALSE)
if(!H5F_addr_defined(linfo.name_bt2_addr))
HGOTO_DONE(FALSE)
@@ -393,11 +393,11 @@ H5G_new_dense_info_test(hid_t gid, hsize_t *name_count, hsize_t *corder_count)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a group")
/* Get the link info */
- if(NULL == H5O_msg_read(&(grp->oloc), H5O_LINFO_ID, &linfo, H5AC_dxpl_id))
+ if(NULL == H5G_obj_get_linfo(&(grp->oloc), &linfo, H5AC_dxpl_id))
HGOTO_ERROR(H5E_SYM, H5E_BADMESG, FAIL, "can't get link info")
/* Check for 'dense' link storage file addresses being defined */
- if(!H5F_addr_defined(linfo.link_fheap_addr))
+ if(!H5F_addr_defined(linfo.fheap_addr))
HGOTO_DONE(FAIL)
if(!H5F_addr_defined(linfo.name_bt2_addr))
HGOTO_DONE(FAIL)
diff --git a/src/H5Gtraverse.c b/src/H5Gtraverse.c
index 255059c..9434f17 100644
--- a/src/H5Gtraverse.c
+++ b/src/H5Gtraverse.c
@@ -714,7 +714,7 @@ H5G_traverse_real(const H5G_loc_t *_loc, const char *name, unsigned target,
/* Get the link info for parent group */
/* (OK if not found) */
- if(NULL == H5O_msg_read(grp_loc.oloc, H5O_LINFO_ID, &par_linfo, dxpl_id)) {
+ if(NULL == H5G_obj_get_linfo(grp_loc.oloc, &par_linfo, dxpl_id)) {
/* Clear error stack from not finding the link info message */
H5E_clear_stack(NULL);
diff --git a/src/H5O.c b/src/H5O.c
index 5f3e507..f02a7f5 100644
--- a/src/H5O.c
+++ b/src/H5O.c
@@ -2046,3 +2046,43 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5O_get_create_plist() */
+
+/*-------------------------------------------------------------------------
+ * Function: H5O_get_nlinks
+ *
+ * Purpose: Retrieve the number of link messages read in from the file
+ *
+ * Return: Success: Non-negative
+ * Failure: Negative
+ *
+ * Programmer: Quincey Koziol
+ * March 11 2007
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5O_get_nlinks(const H5O_loc_t *oloc, hid_t dxpl_id, hsize_t *nlinks)
+{
+ H5O_t *oh = NULL; /* Object header */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI(H5O_get_nlinks, FAIL)
+
+ /* Check args */
+ HDassert(oloc);
+ HDassert(nlinks);
+
+ /* Get the object header */
+ if(NULL == (oh = H5AC_protect(oloc->file, dxpl_id, H5AC_OHDR, oloc->addr, NULL, NULL, H5AC_READ)))
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL, "unable to load object header")
+
+ /* Retrieve the # of link messages seen when the object header was loaded */
+ *nlinks = oh->link_msgs_seen;
+
+done:
+ if(oh && H5AC_unprotect(oloc->file, dxpl_id, H5AC_OHDR, oloc->addr, oh, H5AC__NO_FLAGS_SET) < 0)
+ HDONE_ERROR(H5E_OHDR, H5E_PROTECT, FAIL, "unable to release object header")
+
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5O_get_nlinks() */
+
diff --git a/src/H5Ocache.c b/src/H5Ocache.c
index 2a76526..774055a 100644
--- a/src/H5Ocache.c
+++ b/src/H5Ocache.c
@@ -606,6 +606,11 @@ H5O_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void UNUSED * _udata1,
oh->has_refcount_msg = TRUE;
oh->nlink = *refcount;
} /* end if */
+ /* Check if next message to examine is a link message */
+ else if(H5O_LINK_ID == oh->mesg[curmesg].type->id) {
+ /* Increment the count of link messages */
+ oh->link_msgs_seen++;
+ } /* end if */
} /* end for */
} /* end while */
diff --git a/src/H5Ocopy.c b/src/H5Ocopy.c
index ec51f00..748d780 100644
--- a/src/H5Ocopy.c
+++ b/src/H5Ocopy.c
@@ -342,6 +342,7 @@ H5O_copy_header_real(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out */,
oh_dst->version = oh_src->version;
oh_dst->flags = oh_src->flags;
oh_dst->skipped_mesg_size = oh_src->skipped_mesg_size;
+ oh_dst->link_msgs_seen = oh_src->link_msgs_seen;
oh_dst->sizeof_size = H5F_SIZEOF_SIZE(oloc_dst->file);
oh_dst->sizeof_addr = H5F_SIZEOF_ADDR(oloc_dst->file);
diff --git a/src/H5Olinfo.c b/src/H5Olinfo.c
index 0a2e145..eade420 100644
--- a/src/H5Olinfo.c
+++ b/src/H5Olinfo.c
@@ -137,8 +137,8 @@ H5O_linfo_decode(H5F_t *f, hid_t UNUSED dxpl_id, unsigned UNUSED mesg_flags,
linfo->track_corder = (index_flags & H5O_LINFO_TRACK_CORDER) ? TRUE : FALSE;
linfo->index_corder = (index_flags & H5O_LINFO_INDEX_CORDER) ? TRUE : FALSE;
- /* Number of links in the group */
- H5F_DECODE_LENGTH(f, p, linfo->nlinks)
+ /* Set the number of links in the group to an invalid value, so we query it later */
+ linfo->nlinks = HSIZET_MAX;
/* Max. link creation order value for the group, if tracked */
if(linfo->track_corder)
@@ -147,7 +147,7 @@ H5O_linfo_decode(H5F_t *f, hid_t UNUSED dxpl_id, unsigned UNUSED mesg_flags,
linfo->max_corder = 0;
/* Address of fractal heap to store "dense" links */
- H5F_addr_decode(f, &p, &(linfo->link_fheap_addr));
+ H5F_addr_decode(f, &p, &(linfo->fheap_addr));
/* Address of v2 B-tree to index names of links (names are always indexed) */
H5F_addr_decode(f, &p, &(linfo->name_bt2_addr));
@@ -204,15 +204,12 @@ H5O_linfo_encode(H5F_t *f, hbool_t UNUSED disable_shared, uint8_t *p, const void
index_flags |= linfo->index_corder ? H5O_LINFO_INDEX_CORDER : 0;
*p++ = index_flags;
- /* Number of links in the group */
- H5F_ENCODE_LENGTH(f, p, linfo->nlinks)
-
/* Max. link creation order value for the group, if tracked */
if(linfo->track_corder)
INT64ENCODE(p, linfo->max_corder)
/* Address of fractal heap to store "dense" links */
- H5F_addr_encode(f, &p, linfo->link_fheap_addr);
+ H5F_addr_encode(f, &p, linfo->fheap_addr);
/* Address of v2 B-tree to index names of links */
H5F_addr_encode(f, &p, linfo->name_bt2_addr);
@@ -294,7 +291,6 @@ H5O_linfo_size(const H5F_t *f, hbool_t UNUSED disable_shared, const void *_mesg)
/* Set return value */
ret_value = 1 /* Version */
+ 1 /* Index flags */
- + H5F_SIZEOF_SIZE(f) /* Number of links */
+ (linfo->track_corder ? 8 : 0) /* Curr. max. creation order value */
+ H5F_SIZEOF_ADDR(f) /* Address of fractal heap to store "dense" links */
+ H5F_SIZEOF_ADDR(f) /* Address of v2 B-tree for indexing names of links */
@@ -354,7 +350,7 @@ H5O_linfo_delete(H5F_t *f, hid_t dxpl_id, const void *_mesg)
HDassert(linfo);
/* If the group is using "dense" link storage, delete it */
- if(H5F_addr_defined(linfo->link_fheap_addr))
+ if(H5F_addr_defined(linfo->fheap_addr))
if(H5G_dense_delete(f, dxpl_id, (H5O_linfo_t *)linfo, TRUE) < 0) /* Casting away const OK - QAK */
HGOTO_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "unable to free dense link storage")
@@ -402,7 +398,7 @@ H5O_linfo_copy_file(H5F_t UNUSED *file_src, void *native_src, H5F_t *file_dst,
if(cpy_info->max_depth >= 0 && cpy_info->curr_depth >= cpy_info->max_depth) {
linfo_dst->nlinks = 0;
linfo_dst->max_corder = 0;
- linfo_dst->link_fheap_addr = HADDR_UNDEF;
+ linfo_dst->fheap_addr = HADDR_UNDEF;
linfo_dst->name_bt2_addr = HADDR_UNDEF;
linfo_dst->corder_bt2_addr = HADDR_UNDEF;
} /* end if */
@@ -411,7 +407,7 @@ H5O_linfo_copy_file(H5F_t UNUSED *file_src, void *native_src, H5F_t *file_dst,
/* (XXX: should probably get the "creation" parameters for the source group's
* dense link storage components and use those - QAK)
*/
- if(H5F_addr_defined(linfo_src->link_fheap_addr)) {
+ if(H5F_addr_defined(linfo_src->fheap_addr)) {
if(H5G_dense_create(file_dst, dxpl_id, linfo_dst) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, NULL, "unable to create 'dense' form of new format group")
} /* end if */
@@ -513,7 +509,7 @@ H5O_linfo_post_copy_file(const H5O_loc_t *src_oloc, const void *mesg_src,
HGOTO_DONE(SUCCEED)
/* Check for copying dense link storage */
- if(H5F_addr_defined(linfo_src->link_fheap_addr)) {
+ if(H5F_addr_defined(linfo_src->fheap_addr)) {
H5O_linfo_postcopy_ud_t udata; /* User data for iteration callback */
H5G_link_iterate_t lnk_op; /* Link operator */
@@ -575,7 +571,7 @@ H5O_linfo_debug(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, const void *_mesg, FILE *
HDfprintf(stream, "%*s%-*s %Hd\n", indent, "", fwidth,
"Max. creation order value:", linfo->max_corder);
HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth,
- "'Dense' link storage fractal heap address:", linfo->link_fheap_addr);
+ "'Dense' link storage fractal heap address:", linfo->fheap_addr);
HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth,
"'Dense' link storage name index v2 B-tree address:", linfo->name_bt2_addr);
HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth,
diff --git a/src/H5Omessage.c b/src/H5Omessage.c
index 651cd64..a8b332b 100644
--- a/src/H5Omessage.c
+++ b/src/H5Omessage.c
@@ -908,7 +908,7 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5O_msg_remove(H5O_loc_t *loc, unsigned type_id, int sequence, hbool_t adj_link,
+H5O_msg_remove(const H5O_loc_t *loc, unsigned type_id, int sequence, hbool_t adj_link,
hid_t dxpl_id)
{
H5O_t *oh = NULL; /* Pointer to actual object header */
diff --git a/src/H5Opkg.h b/src/H5Opkg.h
index 68a286d..3df402f 100644
--- a/src/H5Opkg.h
+++ b/src/H5Opkg.h
@@ -266,6 +266,7 @@ struct H5O_t {
size_t alloc_nmesgs; /*number of message slots */
H5O_mesg_t *mesg; /*array of messages */
size_t skipped_mesg_size; /*size of skipped messages (for sanity checking) */
+ size_t link_msgs_seen; /* # of link messages seen when loading header */
/* Chunk management (not stored) */
size_t nchunks; /*number of chunks */
diff --git a/src/H5Oprivate.h b/src/H5Oprivate.h
index 60d7a1d..2bfe8ef 100644
--- a/src/H5Oprivate.h
+++ b/src/H5Oprivate.h
@@ -187,7 +187,7 @@ typedef struct H5O_linfo_t {
/* Storage management info */
hsize_t nlinks; /* Number of links in the group */
- haddr_t link_fheap_addr; /* Address of fractal heap for storing "dense" links */
+ haddr_t fheap_addr; /* Address of fractal heap for storing "dense" links */
haddr_t name_bt2_addr; /* Address of v2 B-tree for indexing names of links */
} H5O_linfo_t;
@@ -466,6 +466,7 @@ H5_DLL herr_t H5O_get_info(H5O_loc_t *oloc, H5O_info_t *oinfo, hid_t dxpl_id);
H5_DLL herr_t H5O_obj_type(const H5O_loc_t *loc, H5O_type_t *obj_type, hid_t dxpl_id);
H5_DLL herr_t H5O_get_create_plist(const H5O_loc_t *loc, hid_t dxpl_id, struct H5P_genplist_t *oc_plist);
H5_DLL hid_t H5O_open_name(H5G_loc_t *loc, const char *name, hid_t lapl_id);
+H5_DLL herr_t H5O_get_nlinks(const H5O_loc_t *loc, hid_t dxpl_id, hsize_t *nlinks);
/* Object header message routines */
H5_DLL herr_t H5O_msg_create(const H5O_loc_t *loc, unsigned type_id, unsigned mesg_flags,
@@ -481,7 +482,7 @@ H5_DLL void *H5O_msg_free(unsigned type_id, void *mesg);
H5_DLL void *H5O_msg_copy(unsigned type_id, const void *mesg, void *dst);
H5_DLL int H5O_msg_count(const H5O_loc_t *loc, unsigned type_id, hid_t dxpl_id);
H5_DLL htri_t H5O_msg_exists(H5O_loc_t *loc, unsigned type_id, hid_t dxpl_id);
-H5_DLL herr_t H5O_msg_remove(H5O_loc_t *loc, unsigned type_id, int sequence,
+H5_DLL herr_t H5O_msg_remove(const H5O_loc_t *loc, unsigned type_id, int sequence,
hbool_t adj_link, hid_t dxpl_id);
H5_DLL herr_t H5O_msg_remove_op(const H5O_loc_t *loc, unsigned type_id, int sequence,
H5O_operator_t op, void *op_data, hbool_t adj_link, hid_t dxpl_id);
diff --git a/src/H5Orefcount.c b/src/H5Orefcount.c
index 8f49b8c..85ff4c0 100644
--- a/src/H5Orefcount.c
+++ b/src/H5Orefcount.c
@@ -215,9 +215,9 @@ done:
*-------------------------------------------------------------------------
*/
static size_t
-H5O_refcount_size(const H5F_t *f, hbool_t UNUSED disable_shared, const void *_mesg)
+H5O_refcount_size(const H5F_t UNUSED *f, hbool_t UNUSED disable_shared,
+ const void UNUSED *_mesg)
{
- const H5O_refcount_t *refcount = (const H5O_refcount_t *)_mesg;
size_t ret_value; /* Return value */
FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_refcount_size)