diff options
author | Dana Robinson <derobins@hdfgroup.org> | 2015-09-30 02:36:46 (GMT) |
---|---|---|
committer | Dana Robinson <derobins@hdfgroup.org> | 2015-09-30 02:36:46 (GMT) |
commit | a89b064e2bd8fb81e39a930209114cfae4fcd141 (patch) | |
tree | 1b3c3b218a4e054ee998429982b7dff840304c16 /src/H5Spoint.c | |
parent | 5c0a8cc86ebe85e1b46e20f253f09c86bdc83169 (diff) | |
parent | fbd659fe6feba18f9fd4f931535a6603ccbf763d (diff) | |
download | hdf5-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/H5Spoint.c')
-rw-r--r-- | src/H5Spoint.c | 51 |
1 files changed, 31 insertions, 20 deletions
diff --git a/src/H5Spoint.c b/src/H5Spoint.c index 1a14254..0f85110 100644 --- a/src/H5Spoint.c +++ b/src/H5Spoint.c @@ -826,28 +826,32 @@ H5S_point_serial_size (const H5S_t *space) static herr_t H5S_point_serialize (const H5S_t *space, uint8_t **p) { - H5S_pnt_node_t *curr; /* Point information nodes */ - uint8_t *lenp; /* pointer to length location for later storage */ - uint32_t len=0; /* number of bytes used */ - unsigned u; /* local counting variable */ + H5S_pnt_node_t *curr; /* Point information nodes */ + uint8_t *pp = (*p); /* Local pointer for decoding */ + uint8_t *lenp; /* pointer to length location for later storage */ + uint32_t len=0; /* number of bytes used */ + unsigned u; /* local counting variable */ FUNC_ENTER_NOAPI_NOINIT_NOERR + /* Check args */ HDassert(space); + HDassert(p); + HDassert(pp); /* Store the preamble information */ - UINT32ENCODE(*p, (uint32_t)H5S_GET_SELECT_TYPE(space)); /* Store the type of selection */ - UINT32ENCODE(*p, (uint32_t)1); /* Store the version number */ - UINT32ENCODE(*p, (uint32_t)0); /* Store the un-used padding */ - lenp=*p; /* keep the pointer to the length location for later */ - *p+=4; /* skip over space for length */ + UINT32ENCODE(pp, (uint32_t)H5S_GET_SELECT_TYPE(space)); /* Store the type of selection */ + UINT32ENCODE(pp, (uint32_t)1); /* Store the version number */ + UINT32ENCODE(pp, (uint32_t)0); /* Store the un-used padding */ + lenp = pp; /* Keep the pointer to the length location for later */ + pp += 4; /* Skip over space for length */ /* Encode number of dimensions */ - UINT32ENCODE(*p, (uint32_t)space->extent.rank); + UINT32ENCODE(pp, (uint32_t)space->extent.rank); len+=4; /* Encode number of elements */ - UINT32ENCODE(*p, (uint32_t)space->select.num_elem); + UINT32ENCODE(pp, (uint32_t)space->select.num_elem); len+=4; /* Encode each point in selection */ @@ -858,7 +862,7 @@ H5S_point_serialize (const H5S_t *space, uint8_t **p) /* Encode each point */ for(u=0; u<space->extent.rank; u++) - UINT32ENCODE(*p, (uint32_t)curr->pnt[u]); + UINT32ENCODE(pp, (uint32_t)curr->pnt[u]); curr=curr->next; } /* end while */ @@ -866,6 +870,9 @@ H5S_point_serialize (const H5S_t *space, uint8_t **p) /* Encode length */ UINT32ENCODE(lenp, (uint32_t)len); /* Store the length of the extra information */ + /* Update encoding pointer */ + *p = pp; + FUNC_LEAVE_NOAPI(SUCCEED) } /* H5S_point_serialize() */ @@ -898,24 +905,25 @@ static herr_t H5S_point_deserialize(H5S_t *space, uint32_t H5_ATTR_UNUSED version, uint8_t H5_ATTR_UNUSED flags, const uint8_t **p) { - H5S_seloper_t op=H5S_SELECT_SET; /* Selection operation */ - unsigned rank; /* Rank of points */ - size_t num_elem=0; /* Number of elements in selection */ - hsize_t *coord=NULL, *tcoord; /* Pointer to array of elements */ + H5S_seloper_t op = H5S_SELECT_SET; /* Selection operation */ + hsize_t *coord = NULL, *tcoord; /* Pointer to array of elements */ + const uint8_t *pp = (*p); /* Local pointer for decoding */ + size_t num_elem = 0; /* Number of elements in selection */ + unsigned rank; /* Rank of points */ unsigned i, j; /* local counting variables */ - herr_t ret_value = SUCCEED; /* return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT /* Check args */ HDassert(space); HDassert(p); - HDassert(*p); + HDassert(pp); /* Deserialize points to select */ /* (The header and rank have already beed decoded) */ rank = space->extent.rank; /* Retrieve rank from space */ - UINT32DECODE(*p, num_elem); /* decode the number of points */ + UINT32DECODE(pp, num_elem); /* decode the number of points */ /* Allocate space for the coordinates */ if(NULL == (coord = (hsize_t *)H5MM_malloc(num_elem * rank * sizeof(hsize_t)))) @@ -924,12 +932,15 @@ H5S_point_deserialize(H5S_t *space, uint32_t H5_ATTR_UNUSED version, uint8_t H5_ /* Retrieve the coordinates from the buffer */ for(tcoord = coord, i = 0; i < num_elem; i++) for(j = 0; j < (unsigned)rank; j++, tcoord++) - UINT32DECODE(*p, *tcoord); + UINT32DECODE(pp, *tcoord); /* Select points */ if(H5S_select_elements(space, op, num_elem, (const hsize_t *)coord) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't change selection") + /* Update decoding pointer */ + *p = pp; + done: /* Free the coordinate array if necessary */ if(coord != NULL) |