summaryrefslogtreecommitdiffstats
path: root/src/H5Aint.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2007-07-18 02:08:37 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2007-07-18 02:08:37 (GMT)
commitc55d0f4e1e09e813fec5fcaa0541150c1ee2a36f (patch)
tree9d288066d5140d72c7f27cef72b01274731ab5bd /src/H5Aint.c
parent2ed54543c8a45e3315d53ba5c1c44e33a98b5c73 (diff)
downloadhdf5-c55d0f4e1e09e813fec5fcaa0541150c1ee2a36f.zip
hdf5-c55d0f4e1e09e813fec5fcaa0541150c1ee2a36f.tar.gz
hdf5-c55d0f4e1e09e813fec5fcaa0541150c1ee2a36f.tar.bz2
[svn-r13988] Description:
Fix bug where the version of an attribute would change after it was created, causing the amount of space used to encode it to change. Tested on: Mac OS X/32 10.4.10 (amazon) FreeBSD/32 6.2 (duty)
Diffstat (limited to 'src/H5Aint.c')
-rw-r--r--src/H5Aint.c57
1 files changed, 57 insertions, 0 deletions
diff --git a/src/H5Aint.c b/src/H5Aint.c
index 9dd40ec..f57bd6b 100644
--- a/src/H5Aint.c
+++ b/src/H5Aint.c
@@ -669,3 +669,60 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5A_get_ainfo() */
+
+/*-------------------------------------------------------------------------
+ * Function: H5A_get_version
+ *
+ * Purpose: Retrieves the correct version to encode attribute with.
+ * Chooses the oldest version possible, unless the "use the
+ * latest format" flag is set.
+ *
+ * Return: Success: Version to encode attribute with.
+ * Failure: Can't fail
+ *
+ * Programmer: Quincey Koziol
+ * koziol@hdfgroup.org
+ * Jul 17 2007
+ *
+ *-------------------------------------------------------------------------
+ */
+unsigned
+H5A_get_version(const H5F_t *f, const H5A_t *attr)
+{
+ hbool_t type_shared, space_shared; /* Flags to indicate that shared messages are used for this attribute */
+ hbool_t use_latest_format; /* Flag indicating the newest file format should be used */
+ unsigned ret_value; /* Return value */
+
+ FUNC_ENTER_NOAPI_NOFUNC(H5A_get_version)
+
+ /* check arguments */
+ HDassert(f);
+ HDassert(attr);
+
+ /* Get the file's 'use the latest version of the format' flag */
+ use_latest_format = H5F_USE_LATEST_FORMAT(f);
+
+ /* Check whether datatype and dataspace are shared */
+ if(H5O_msg_is_shared(H5O_DTYPE_ID, attr->dt) > 0)
+ type_shared = TRUE;
+ else
+ type_shared = FALSE;
+
+ if(H5O_msg_is_shared(H5O_SDSPACE_ID, attr->ds) > 0)
+ space_shared = TRUE;
+ else
+ space_shared = FALSE;
+
+ /* Check which version to encode attribute with */
+ if(use_latest_format)
+ ret_value = H5O_ATTR_VERSION_LATEST; /* Write out latest version of format */
+ else if(attr->encoding != H5T_CSET_ASCII)
+ ret_value = H5O_ATTR_VERSION_3; /* Write version which includes the character encoding */
+ else if(type_shared || space_shared)
+ ret_value = H5O_ATTR_VERSION_2; /* Write out version with flag for indicating shared datatype or dataspace */
+ else
+ ret_value = H5O_ATTR_VERSION_1; /* Write out basic version */
+
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5A_get_version() */
+