summaryrefslogtreecommitdiffstats
path: root/src/H5T.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2004-07-28 03:51:43 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2004-07-28 03:51:43 (GMT)
commitd60d3679301d5587b077ae47eab091fdbb96a28d (patch)
tree4e9717e96ab1d43d157259dcb6200c5d260cb9ab /src/H5T.c
parentae0ae159563f4d284b4062f0c838f7c91d38f338 (diff)
downloadhdf5-d60d3679301d5587b077ae47eab091fdbb96a28d.zip
hdf5-d60d3679301d5587b077ae47eab091fdbb96a28d.tar.gz
hdf5-d60d3679301d5587b077ae47eab091fdbb96a28d.tar.bz2
[svn-r8964] Purpose:
Revise new feature Description: Add buffer type and version # bytes to the encoded datatype and dataspace buffers (for H5Tencode & H5Sencode) Platforms tested: FreeBSD 4.10 (sleipnir) Too minor to require h5committest
Diffstat (limited to 'src/H5T.c')
-rw-r--r--src/H5T.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/H5T.c b/src/H5T.c
index acd4649..8863ceb 100644
--- a/src/H5T.c
+++ b/src/H5T.c
@@ -259,6 +259,9 @@ static herr_t H5T_unregister(H5T_pers_t pers, const char *name, H5T_t *src,
static herr_t H5T_register(H5T_pers_t pers, const char *name, H5T_t *src,
H5T_t *dst, H5T_conv_t func, hid_t dxpl_id);
+/* Local macro definitions */
+#define H5T_ENCODE_VERSION 0
+
/*
* Type initialization macros
*
@@ -2671,11 +2674,17 @@ H5T_encode(H5T_t *obj, unsigned char *buf, size_t *nalloc)
HGOTO_ERROR(H5E_DATATYPE, H5E_BADSIZE, FAIL, "can't find datatype size");
/* Don't encode if buffer size isn't big enough or buffer is empty */
- if(!buf || *nalloc<buf_size) {
- *nalloc = buf_size;
+ if(!buf || *nalloc<(buf_size+1+1)) {
+ *nalloc = buf_size+1+1;
HGOTO_DONE(ret_value);
}
+ /* Encode the type of the information */
+ *buf++ = H5O_DTYPE_ID;
+
+ /* Encode the version of the dataspace information */
+ *buf++ = H5T_ENCODE_VERSION;
+
if(H5O_encode(&f, buf, obj, H5O_DTYPE_ID)<0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTENCODE, FAIL, "can't encode object");
@@ -2709,6 +2718,14 @@ H5T_decode(unsigned char *buf)
FUNC_ENTER_NOAPI(H5T_decode, NULL);
+ /* Decode the type of the information */
+ if(*buf++ != H5O_DTYPE_ID)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_BADMESG, NULL, "not an encoded datatype");
+
+ /* Decode the version of the datatype information */
+ if(*buf++ != H5T_ENCODE_VERSION)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_VERSION, NULL, "unknown version of encoded datatype");
+
if((ret_value = H5O_decode(NULL, buf, H5O_DTYPE_ID))==NULL)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTDECODE, NULL, "can't decode object");