mirror of
https://github.com/HDFGroup/hdf5.git
synced 2025-01-30 15:32:37 +08:00
[svn-r7926] Purpose:
Bug fix Description: Clean up a few allocations of zero-sized blocks that were detected with the new free-list assertions. Platforms tested: FreeBSD 4.9 (sleipnir) w & w/o parallel too minor to require h5committest
This commit is contained in:
parent
404567ce64
commit
f473fc5cb8
18
src/H5S.c
18
src/H5S.c
@ -1200,8 +1200,12 @@ H5S_read(H5G_entry_t *ent, hid_t dxpl_id)
|
|||||||
HGOTO_ERROR (H5E_DATASPACE, H5E_CANTSET, NULL, "unable to set all selection");
|
HGOTO_ERROR (H5E_DATASPACE, H5E_CANTSET, NULL, "unable to set all selection");
|
||||||
|
|
||||||
/* Allocate space for the offset and set it to zeros */
|
/* Allocate space for the offset and set it to zeros */
|
||||||
if (NULL==(ds->select.offset = H5FL_ARR_CALLOC(hssize_t,ds->extent.u.simple.rank)))
|
if(ds->extent.u.simple.rank>0) {
|
||||||
HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
|
if (NULL==(ds->select.offset = H5FL_ARR_CALLOC(hssize_t,ds->extent.u.simple.rank)))
|
||||||
|
HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
|
||||||
|
} /* end if */
|
||||||
|
else
|
||||||
|
ds->select.offset = NULL;
|
||||||
|
|
||||||
/* Set the value for successful return */
|
/* Set the value for successful return */
|
||||||
ret_value=ds;
|
ret_value=ds;
|
||||||
@ -1380,8 +1384,12 @@ H5S_set_extent_simple (H5S_t *space, unsigned rank, const hsize_t *dims,
|
|||||||
space->select.offset=H5FL_ARR_FREE(hssize_t,space->select.offset);
|
space->select.offset=H5FL_ARR_FREE(hssize_t,space->select.offset);
|
||||||
|
|
||||||
/* Allocate space for the offset and set it to zeros */
|
/* Allocate space for the offset and set it to zeros */
|
||||||
if (NULL==(space->select.offset = H5FL_ARR_CALLOC(hssize_t,rank)))
|
if(rank>0) {
|
||||||
HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed");
|
if (NULL==(space->select.offset = H5FL_ARR_CALLOC(hssize_t,rank)))
|
||||||
|
HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed");
|
||||||
|
} /* end if */
|
||||||
|
else
|
||||||
|
space->select.offset = NULL;
|
||||||
|
|
||||||
/* shift out of the previous state to a "simple" dataspace */
|
/* shift out of the previous state to a "simple" dataspace */
|
||||||
switch (space->extent.type) {
|
switch (space->extent.type) {
|
||||||
@ -1917,6 +1925,8 @@ H5Soffset_simple(hid_t space_id, const hssize_t *offset)
|
|||||||
/* Check args */
|
/* Check args */
|
||||||
if (NULL == (space = H5I_object_verify(space_id, H5I_DATASPACE)))
|
if (NULL == (space = H5I_object_verify(space_id, H5I_DATASPACE)))
|
||||||
HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "not a data space");
|
HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "not a data space");
|
||||||
|
if (space->extent.u.simple.rank==0 || space->extent.type==H5S_SCALAR)
|
||||||
|
HGOTO_ERROR(H5E_ATOM, H5E_UNSUPPORTED, FAIL, "can't set offset on scalar dataspace");
|
||||||
if (offset == NULL)
|
if (offset == NULL)
|
||||||
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no offset specified");
|
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no offset specified");
|
||||||
|
|
||||||
|
@ -126,6 +126,7 @@ H5S_select_offset(H5S_t *space, const hssize_t *offset)
|
|||||||
|
|
||||||
/* Check args */
|
/* Check args */
|
||||||
assert(space);
|
assert(space);
|
||||||
|
assert(space->extent.u.simple.rank);
|
||||||
assert(offset);
|
assert(offset);
|
||||||
|
|
||||||
/* Allocate space for new offset */
|
/* Allocate space for new offset */
|
||||||
@ -178,10 +179,14 @@ H5S_select_copy (H5S_t *dst, const H5S_t *src)
|
|||||||
/* Need to copy order information still */
|
/* Need to copy order information still */
|
||||||
|
|
||||||
/* Copy offset information */
|
/* Copy offset information */
|
||||||
if (NULL==(dst->select.offset = H5FL_ARR_CALLOC(hssize_t,src->extent.u.simple.rank)))
|
if(src->extent.u.simple.rank>0) {
|
||||||
HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed");
|
if (NULL==(dst->select.offset = H5FL_ARR_CALLOC(hssize_t,src->extent.u.simple.rank)))
|
||||||
if(src->select.offset!=NULL)
|
HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed");
|
||||||
HDmemcpy(dst->select.offset,src->select.offset,(src->extent.u.simple.rank*sizeof(hssize_t)));
|
if(src->select.offset!=NULL)
|
||||||
|
HDmemcpy(dst->select.offset,src->select.offset,(src->extent.u.simple.rank*sizeof(hssize_t)));
|
||||||
|
} /* end if */
|
||||||
|
else
|
||||||
|
dst->select.offset=NULL;
|
||||||
|
|
||||||
/* Perform correct type of copy based on the type of selection */
|
/* Perform correct type of copy based on the type of selection */
|
||||||
switch (src->extent.type) {
|
switch (src->extent.type) {
|
||||||
@ -596,12 +601,16 @@ H5S_select_iter_init(H5S_sel_iter_t *sel_iter, const H5S_t *space, size_t elmt_s
|
|||||||
/* Save the dataspace's rank */
|
/* Save the dataspace's rank */
|
||||||
sel_iter->rank=space->extent.u.simple.rank;
|
sel_iter->rank=space->extent.u.simple.rank;
|
||||||
|
|
||||||
/* Allocate room for the dataspace dimensions */
|
if(sel_iter->rank>0) {
|
||||||
sel_iter->dims = H5FL_ARR_MALLOC(hsize_t,sel_iter->rank);
|
/* Allocate room for the dataspace dimensions */
|
||||||
assert(sel_iter->dims);
|
sel_iter->dims = H5FL_ARR_MALLOC(hsize_t,sel_iter->rank);
|
||||||
|
assert(sel_iter->dims);
|
||||||
|
|
||||||
/* Keep a copy of the dataspace dimensions */
|
/* Keep a copy of the dataspace dimensions */
|
||||||
HDmemcpy(sel_iter->dims,space->extent.u.simple.size,sel_iter->rank*sizeof(hsize_t));
|
HDmemcpy(sel_iter->dims,space->extent.u.simple.size,sel_iter->rank*sizeof(hsize_t));
|
||||||
|
} /* end if */
|
||||||
|
else
|
||||||
|
sel_iter->dims = NULL;
|
||||||
|
|
||||||
/* Call initialization routine for selection type */
|
/* Call initialization routine for selection type */
|
||||||
ret_value= (*space->select.iter_init)(sel_iter, space, elmt_size);
|
ret_value= (*space->select.iter_init)(sel_iter, space, elmt_size);
|
||||||
|
Loading…
Reference in New Issue
Block a user