summaryrefslogtreecommitdiffstats
path: root/src/H5S.c
diff options
context:
space:
mode:
authorDana Robinson <derobins@hdfgroup.org>2015-09-30 02:36:46 (GMT)
committerDana Robinson <derobins@hdfgroup.org>2015-09-30 02:36:46 (GMT)
commita89b064e2bd8fb81e39a930209114cfae4fcd141 (patch)
tree1b3c3b218a4e054ee998429982b7dff840304c16 /src/H5S.c
parent5c0a8cc86ebe85e1b46e20f253f09c86bdc83169 (diff)
parentfbd659fe6feba18f9fd4f931535a6603ccbf763d (diff)
downloadhdf5-a89b064e2bd8fb81e39a930209114cfae4fcd141.zip
hdf5-a89b064e2bd8fb81e39a930209114cfae4fcd141.tar.gz
hdf5-a89b064e2bd8fb81e39a930209114cfae4fcd141.tar.bz2
[svn-r27916] Re-merge of r27884-27891 from the trunk + bugfix for a few
H5S recursive functions where an aliased pointer was incorrectly set too early. Tested on: Ubuntu 15.04 (Linux 3.19 x86_64) w/ gcc 4.9.2 serial and parallel (w/ MPICH 3.1.4)
Diffstat (limited to 'src/H5S.c')
-rw-r--r--src/H5S.c40
1 files changed, 22 insertions, 18 deletions
diff --git a/src/H5S.c b/src/H5S.c
index 1d07f14..af7d395 100644
--- a/src/H5S.c
+++ b/src/H5S.c
@@ -1576,11 +1576,12 @@ done:
herr_t
H5S_encode(H5S_t *obj, unsigned char **p, size_t *nalloc)
{
+ H5F_t *f = NULL; /* Fake file structure*/
+ unsigned char *pp = (*p); /* Local pointer for decoding */
size_t extent_size; /* Size of serialized dataspace extent */
hssize_t sselect_size; /* Signed size of serialized dataspace selection */
size_t select_size; /* Size of serialized dataspace selection */
- H5F_t *f = NULL; /* Fake file structure*/
- herr_t ret_value = SUCCEED;
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
@@ -1599,27 +1600,28 @@ H5S_encode(H5S_t *obj, unsigned char **p, size_t *nalloc)
/* Verify the size of buffer. If it's not big enough, simply return the
* right size without filling the buffer. */
- if(!*p || *nalloc < (extent_size + select_size + 1 + 1 + 1 + 4))
+ if(!pp || *nalloc < (extent_size + select_size + 1 + 1 + 1 + 4))
*nalloc = extent_size + select_size + 1 + 1 + 1 + 4;
else {
/* Encode the type of the information */
- *(*p)++ = H5O_SDSPACE_ID;
+ *pp++ = H5O_SDSPACE_ID;
/* Encode the version of the dataspace information */
- *(*p)++ = H5S_ENCODE_VERSION;
+ *pp++ = H5S_ENCODE_VERSION;
/* Encode the "size of size" information */
- *(*p)++ = (unsigned char)H5F_SIZEOF_SIZE(f);
+ *pp++ = (unsigned char)H5F_SIZEOF_SIZE(f);
/* Encode size of extent information. Pointer is actually moved in this macro. */
- UINT32ENCODE(*p, extent_size);
+ UINT32ENCODE(pp, extent_size);
/* Encode the extent part of dataspace */
- if(H5O_msg_encode(f, H5O_SDSPACE_ID, TRUE, *p, obj) < 0)
+ if(H5O_msg_encode(f, H5O_SDSPACE_ID, TRUE, pp, obj) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTENCODE, FAIL, "can't encode extent space")
- *p += extent_size;
+ pp += extent_size;
/* Encode the selection part of dataspace. */
+ *p = pp;
if(H5S_SELECT_SERIALIZE(obj, p) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTENCODE, FAIL, "can't encode select space")
} /* end else */
@@ -1692,38 +1694,39 @@ done:
H5S_t*
H5S_decode(const unsigned char **p)
{
- H5S_t *ds;
- H5S_extent_t *extent;
- size_t extent_size; /* size of the extent message*/
H5F_t *f = NULL; /* Fake file structure*/
+ H5S_t *ds; /* Decoded dataspace */
+ H5S_extent_t *extent; /* Entent of decoded dataspace */
+ const unsigned char *pp = (*p); /* Local pointer for decoding */
+ size_t extent_size; /* size of the extent message*/
uint8_t sizeof_size; /* 'Size of sizes' for file */
H5S_t *ret_value = NULL; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
/* Decode the type of the information */
- if(*(*p)++ != H5O_SDSPACE_ID)
+ if(*pp++ != H5O_SDSPACE_ID)
HGOTO_ERROR(H5E_DATASPACE, H5E_BADMESG, NULL, "not an encoded dataspace")
/* Decode the version of the dataspace information */
- if(*(*p)++ != H5S_ENCODE_VERSION)
+ if(*pp++ != H5S_ENCODE_VERSION)
HGOTO_ERROR(H5E_DATASPACE, H5E_VERSION, NULL, "unknown version of encoded dataspace")
/* Decode the "size of size" information */
- sizeof_size = *(*p)++;
+ sizeof_size = *pp++;
/* Allocate "fake" file structure */
if(NULL == (f = H5F_fake_alloc(sizeof_size)))
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, NULL, "can't allocate fake file struct")
/* Decode size of extent information */
- UINT32DECODE(*p, extent_size);
+ UINT32DECODE(pp, extent_size);
/* Decode the extent part of dataspace */
/* (pass mostly bogus file pointer and bogus DXPL) */
- if((extent = (H5S_extent_t *)H5O_msg_decode(f, H5P_DEFAULT, NULL, H5O_SDSPACE_ID, *p))==NULL)
+ if((extent = (H5S_extent_t *)H5O_msg_decode(f, H5P_DEFAULT, NULL, H5O_SDSPACE_ID, pp))==NULL)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDECODE, NULL, "can't decode object")
- *p += extent_size;
+ pp += extent_size;
/* Copy the extent into dataspace structure */
if((ds = H5FL_CALLOC(H5S_t))==NULL)
@@ -1739,6 +1742,7 @@ H5S_decode(const unsigned char **p)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSET, NULL, "unable to set all selection")
/* Decode the select part of dataspace. I believe this part always exists. */
+ *p = pp;
if(H5S_SELECT_DESERIALIZE(&ds, p) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDECODE, NULL, "can't decode space selection")