summaryrefslogtreecommitdiffstats
path: root/src/H5Aint.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2007-03-12 03:00:31 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2007-03-12 03:00:31 (GMT)
commitc227f4ffa55010ea480773d9df9b68baba2b08e0 (patch)
treeb2942cfaf387acd91863967c5d014ee89ee06b39 /src/H5Aint.c
parenta64589450e5b41dc55b1c6f2e42e837fb0c72bba (diff)
downloadhdf5-c227f4ffa55010ea480773d9df9b68baba2b08e0.zip
hdf5-c227f4ffa55010ea480773d9df9b68baba2b08e0.tar.gz
hdf5-c227f4ffa55010ea480773d9df9b68baba2b08e0.tar.bz2
[svn-r13499] Description:
Avoid storing the # of attributes in the "attribute info" message and regenerate it when the object is opened. Tested on: FreeBSD/32 6.2 (duty)
Diffstat (limited to 'src/H5Aint.c')
-rw-r--r--src/H5Aint.c50
1 files changed, 50 insertions, 0 deletions
diff --git a/src/H5Aint.c b/src/H5Aint.c
index 18b49f8..1af97d9 100644
--- a/src/H5Aint.c
+++ b/src/H5Aint.c
@@ -616,3 +616,53 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5A_attr_release_table() */
+
+/*-------------------------------------------------------------------------
+ * Function: H5A_get_ainfo
+ *
+ * Purpose: Retrieves the "attribute info" message for an object. Also
+ * sets the number of attributes 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_ainfo_t *
+H5A_get_ainfo(H5F_t *f, hid_t dxpl_id, H5O_t *oh, H5O_ainfo_t *ainfo)
+{
+ H5O_ainfo_t *ret_value; /* Return value */
+
+ FUNC_ENTER_NOAPI(H5A_get_ainfo, NULL)
+
+ /* check arguments */
+ HDassert(f);
+ HDassert(oh);
+
+ /* Retrieve the "attribute info" structure */
+ if(ret_value = H5O_msg_read_real(f, dxpl_id, oh, H5O_AINFO_ID, ainfo)) {
+ /* Check if we don't know how many attributes there are */
+ if(ret_value->nattrs == HSIZET_MAX) {
+ /* Check if we are using "dense" attribute 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(f, dxpl_id, H5A_BT2_NAME, ret_value->name_bt2_addr, &ret_value->nattrs) < 0)
+ HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, NULL, "can't retrieve # of records in index")
+ } /* end if */
+ else
+ /* Retrieve # of attributes from object header */
+ ret_value->nattrs = oh->attr_msgs_seen;
+ } /* end if */
+ } /* end if */
+ else
+ HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, NULL, "attribute info message not present")
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5A_get_ainfo() */
+