summaryrefslogtreecommitdiffstats
path: root/src/H5Oattr.c
diff options
context:
space:
mode:
authorRobb Matzke <matzke@llnl.gov>1998-07-20 17:58:37 (GMT)
committerRobb Matzke <matzke@llnl.gov>1998-07-20 17:58:37 (GMT)
commit34595bac3b5f0b2dad3050907c07e023a6972097 (patch)
tree34ce0884c518396dd75dfc88faf15084ee18aa05 /src/H5Oattr.c
parent1dbacc8377754e33e8088ad6c7895a5f68bf7dfb (diff)
downloadhdf5-34595bac3b5f0b2dad3050907c07e023a6972097.zip
hdf5-34595bac3b5f0b2dad3050907c07e023a6972097.tar.gz
hdf5-34595bac3b5f0b2dad3050907c07e023a6972097.tar.bz2
[svn-r518] Changes since 19980720
---------------------- ./doc/html/H5.format.html ./src/H5Oattr.c ./src/H5Odtype.c ./src/H5Oefl.c ./src/H5Olayout.c ./src/H5Osdspace.c ./src/H5Oshared.c Added version numbers to some object header messages so we can update them easier in the future. The library currently just gives up if the version numbers don't match, but in the future the library could handle multiple versions of a message. ./test/testhdf5.c Removed an argument from the H5version() call that I missed last time.
Diffstat (limited to 'src/H5Oattr.c')
-rw-r--r--src/H5Oattr.c27
1 files changed, 25 insertions, 2 deletions
diff --git a/src/H5Oattr.c b/src/H5Oattr.c
index 6021802..99551ee 100644
--- a/src/H5Oattr.c
+++ b/src/H5Oattr.c
@@ -51,6 +51,8 @@ const H5O_class_t H5O_ATTR[1] = {{
H5O_attr_debug, /* debug the message */
}};
+#define H5O_ATTR_VERSION 1
+
/* Interface initialization */
static hbool_t interface_initialize_g = FALSE;
#define INTERFACE_INIT NULL
@@ -76,6 +78,9 @@ static hbool_t interface_initialize_g = FALSE;
* Modifications:
* Robb Matzke, 17 Jul 1998
* Added padding for alignment.
+ *
+ * Robb Matzke, 20 Jul 1998
+ * Added a version number at the beginning.
--------------------------------------------------------------------------*/
static void *
H5O_attr_decode(H5F_t *f, const uint8 *p, H5O_shared_t __unused__ *sh)
@@ -83,6 +88,7 @@ H5O_attr_decode(H5F_t *f, const uint8 *p, H5O_shared_t __unused__ *sh)
H5A_t *attr = NULL;
H5S_simple_t *simple; /*simple dimensionality information */
size_t name_len; /*attribute name length */
+ intn version; /*message version number*/
FUNC_ENTER(H5O_attr_decode, NULL);
@@ -95,6 +101,16 @@ H5O_attr_decode(H5F_t *f, const uint8 *p, H5O_shared_t __unused__ *sh)
"memory allocation failed");
}
+ /* Version number */
+ version = *p++;
+ if (version!=H5O_ATTR_VERSION) {
+ HRETURN_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL,
+ "bad version number for attribute message");
+ }
+
+ /* Reserved */
+ p++;
+
/*
* Decode the sizes of the parts of the attribute. The sizes stored in
* the file are exact but the parts are aligned on 8-byte boundaries.
@@ -102,7 +118,6 @@ H5O_attr_decode(H5F_t *f, const uint8 *p, H5O_shared_t __unused__ *sh)
UINT16DECODE(p, name_len); /*including null*/
UINT16DECODE(p, attr->dt_size);
UINT16DECODE(p, attr->ds_size);
- p += 2; /*reserved*/
/* Decode and store the name */
if (NULL==(attr->name=H5MM_malloc(name_len))) {
@@ -175,6 +190,9 @@ H5O_attr_decode(H5F_t *f, const uint8 *p, H5O_shared_t __unused__ *sh)
* Modifications:
* Robb Matzke, 17 Jul 1998
* Added padding for alignment.
+ *
+ * Robb Matzke, 20 Jul 1998
+ * Added a version number at the beginning.
--------------------------------------------------------------------------*/
static herr_t
H5O_attr_encode(H5F_t *f, uint8 *p, const void *mesg)
@@ -189,6 +207,12 @@ H5O_attr_encode(H5F_t *f, uint8 *p, const void *mesg)
assert(p);
assert(attr);
+ /* Version */
+ *p++ = H5O_ATTR_VERSION;
+
+ /* Reserved */
+ *p++ = 0;
+
/*
* Encode the lengths of the various parts of the attribute message. The
* encoded lengths are exact but we pad each part except the data to be a
@@ -198,7 +222,6 @@ H5O_attr_encode(H5F_t *f, uint8 *p, const void *mesg)
UINT16ENCODE(p, name_len);
UINT16ENCODE(p, attr->dt_size);
UINT16ENCODE(p, attr->ds_size);
- UINT16ENCODE(p, 0); /*reserved*/
/*
* Write the name including null terminator padded to the correct number