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/H5Ostab.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/H5Ostab.c')
-rw-r--r-- | src/H5Ostab.c | 50 |
1 files changed, 35 insertions, 15 deletions
diff --git a/src/H5Ostab.c b/src/H5Ostab.c index 76aef3b..37f2d0e 100644 --- a/src/H5Ostab.c +++ b/src/H5Ostab.c @@ -77,7 +77,8 @@ H5FL_DEFINE_STATIC(H5O_stab_t); static void * H5O_stab_decode(H5F_t *f, const uint8_t *p, H5O_shared_t UNUSED *sh) { - H5O_stab_t *stab; + H5O_stab_t *stab=NULL; + void *ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5O_stab_decode, NULL); @@ -87,15 +88,23 @@ H5O_stab_decode(H5F_t *f, const uint8_t *p, H5O_shared_t UNUSED *sh) assert (!sh); /* decode */ - if (NULL==(stab = H5FL_ALLOC(H5O_stab_t,1))) { - HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, - "memory allocation failed"); - } + if (NULL==(stab = H5FL_ALLOC(H5O_stab_t,1))) + HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); H5F_addr_decode(f, &p, &(stab->btree_addr)); H5F_addr_decode(f, &p, &(stab->heap_addr)); - FUNC_LEAVE(stab); + /* Set return value */ + ret_value=stab; + +done: + if(ret_value==NULL) { + if(stab!=NULL) + H5FL_FREE(H5O_stab_t,stab); + } /* end if */ + + FUNC_LEAVE(ret_value); } + /*------------------------------------------------------------------------- * Function: H5O_stab_encode @@ -130,6 +139,7 @@ H5O_stab_encode(H5F_t *f, uint8_t *p, const void *_mesg) FUNC_LEAVE(SUCCEED); } + /*------------------------------------------------------------------------- * Function: H5O_stab_fast @@ -153,7 +163,8 @@ H5O_stab_encode(H5F_t *f, uint8_t *p, const void *_mesg) void * H5O_stab_fast(const H5G_cache_t *cache, const H5O_class_t *type, void *_mesg) { - H5O_stab_t *stab = NULL; + H5O_stab_t *stab = NULL; + void *ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5O_stab_fast, NULL); @@ -165,14 +176,19 @@ H5O_stab_fast(const H5G_cache_t *cache, const H5O_class_t *type, void *_mesg) if (_mesg) { stab = (H5O_stab_t *) _mesg; } else if (NULL==(stab = H5FL_ALLOC(H5O_stab_t,1))) { - HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, - "memory allocation failed"); + HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); } stab->btree_addr = cache->stab.btree_addr; stab->heap_addr = cache->stab.heap_addr; } - FUNC_LEAVE(stab); + + /* Set return value */ + ret_value=stab; + +done: + FUNC_LEAVE(ret_value); } + /*------------------------------------------------------------------------- * Function: H5O_stab_copy @@ -197,21 +213,25 @@ H5O_stab_copy(const void *_mesg, void *_dest) { const H5O_stab_t *stab = (const H5O_stab_t *) _mesg; H5O_stab_t *dest = (H5O_stab_t *) _dest; + void *ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5O_stab_copy, NULL); /* check args */ assert(stab); - if (!dest && NULL==(dest = H5FL_ALLOC(H5O_stab_t,1))) { - HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, - "memory allocation failed"); - } + if (!dest && NULL==(dest = H5FL_ALLOC(H5O_stab_t,1))) + HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); /* copy */ *dest = *stab; - FUNC_LEAVE((void *) dest); + /* Set return value */ + ret_value=dest; + +done: + FUNC_LEAVE(ret_value); } + /*------------------------------------------------------------------------- * Function: H5O_stab_size |