diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2002-08-08 16:52:55 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2002-08-08 16:52:55 (GMT) |
commit | d8397a6f426227d09d20e647ce8b12b8c6295b2d (patch) | |
tree | 2943fbfd2bfb66cf167eb642835fdb4deb3afd3c /src/H5Sselect.c | |
parent | 573307786a1f5f7ce597e5191ea08c3bbd95b66c (diff) | |
download | hdf5-d8397a6f426227d09d20e647ce8b12b8c6295b2d.zip hdf5-d8397a6f426227d09d20e647ce8b12b8c6295b2d.tar.gz hdf5-d8397a6f426227d09d20e647ce8b12b8c6295b2d.tar.bz2 |
[svn-r5842] Purpose:
Code cleanup
Description:
Change most (all?) HRETURN_ERROR macros to HGOTO_ERROR macros, along with
HRETURN macros to HGOTO_DONE macros. This unifies the error return path
from functions and reduces the size of the library by up to 10% on some
platforms.
Additionally, I improved a lot of the error cleanup code in many routines.
Platforms tested:
FreeBSD 4.6 (sleipnir) serial & parallel and IRIX64 6.5 (modi4) serial &
parallel.
Diffstat (limited to 'src/H5Sselect.c')
-rw-r--r-- | src/H5Sselect.c | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/src/H5Sselect.c b/src/H5Sselect.c index 18b5ca7..1905d7a 100644 --- a/src/H5Sselect.c +++ b/src/H5Sselect.c @@ -76,7 +76,7 @@ H5S_select_copy (H5S_t *dst, const H5S_t *src) /* Copy offset information */ if (NULL==(dst->select.offset = H5FL_ARR_ALLOC(hssize_t,src->extent.u.simple.rank,1))) - HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); + HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); if(src->select.offset!=NULL) HDmemcpy(dst->select.offset,src->select.offset,(src->extent.u.simple.rank*sizeof(hssize_t))); @@ -117,6 +117,7 @@ H5S_select_copy (H5S_t *dst, const H5S_t *src) break; } /* end switch */ +done: FUNC_LEAVE (ret_value); } /* H5S_select_copy() */ @@ -142,17 +143,18 @@ hssize_t H5Sget_select_npoints(hid_t spaceid) { H5S_t *space = NULL; /* Dataspace to modify selection of */ - hssize_t ret_value=FAIL; /* return value */ + hssize_t ret_value; /* return value */ FUNC_ENTER_API(H5Sget_select_npoints, 0); H5TRACE1("Hs","i",spaceid); /* Check args */ if (NULL == (space=H5I_object_verify(spaceid, H5I_DATASPACE))) - HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "not a data space"); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "not a data space"); ret_value = (*space->select.get_npoints)(space); +done: FUNC_LEAVE (ret_value); } /* H5Sget_select_npoints() */ @@ -181,17 +183,18 @@ htri_t H5Sselect_valid(hid_t spaceid) { H5S_t *space = NULL; /* Dataspace to modify selection of */ - htri_t ret_value=FAIL; /* return value */ + htri_t ret_value; /* return value */ FUNC_ENTER_API(H5Sselect_valid, 0); H5TRACE1("b","i",spaceid); /* Check args */ if (NULL == (space=H5I_object_verify(spaceid, H5I_DATASPACE))) - HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "not a data space"); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "not a data space"); ret_value = (*space->select.is_valid)(space); +done: FUNC_LEAVE (ret_value); } /* H5Sselect_valid() */ @@ -287,19 +290,20 @@ herr_t H5Sget_select_bounds(hid_t spaceid, hsize_t *start, hsize_t *end) { H5S_t *space = NULL; /* Dataspace to modify selection of */ - herr_t ret_value=FAIL; /* return value */ + herr_t ret_value; /* return value */ FUNC_ENTER_API(H5Sget_select_bounds, FAIL); H5TRACE3("e","i*h*h",spaceid,start,end); /* Check args */ if(start==NULL || end==NULL) - HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid pointer"); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid pointer"); if (NULL == (space=H5I_object_verify(spaceid, H5I_DATASPACE))) - HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space"); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space"); ret_value = (*space->select.bounds)(space,start,end); +done: FUNC_LEAVE (ret_value); } /* H5Sget_select_bounds() */ @@ -491,15 +495,20 @@ H5S_sel_type H5Sget_select_type(hid_t space_id) { H5S_t *space = NULL; /* dataspace to modify */ + H5S_sel_type ret_value; /* Return value */ FUNC_ENTER_API(H5Sget_select_type, H5S_SEL_ERROR); H5TRACE1("St","i",space_id); /* Check args */ if (NULL == (space = H5I_object_verify(space_id, H5I_DATASPACE))) - HRETURN_ERROR(H5E_ATOM, H5E_BADATOM, H5S_SEL_ERROR, "not a data space"); + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, H5S_SEL_ERROR, "not a data space"); - FUNC_LEAVE(space->select.type); + /* Set return value */ + ret_value=space->select.type; + +done: + FUNC_LEAVE(ret_value); } /* end H5Sget_select_type() */ |