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/H5Gent.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/H5Gent.c')
-rw-r--r-- | src/H5Gent.c | 62 |
1 files changed, 37 insertions, 25 deletions
diff --git a/src/H5Gent.c b/src/H5Gent.c index 35fd0af..c973400 100644 --- a/src/H5Gent.c +++ b/src/H5Gent.c @@ -42,16 +42,22 @@ static int interface_initialize_g = 0; H5G_cache_t * H5G_ent_cache(H5G_entry_t *ent, H5G_type_t *cache_type) { + H5G_cache_t *ret_value; /* Return value */ + FUNC_ENTER_NOAPI(H5G_ent_cache, NULL); - if (!ent) { - HRETURN_ERROR(H5E_SYM, H5E_BADVALUE, NULL, "no entry"); - } + if (!ent) + HGOTO_ERROR(H5E_SYM, H5E_BADVALUE, NULL, "no entry"); if (cache_type) *cache_type = ent->type; - FUNC_LEAVE(&(ent->cache)); + /* Set return value */ + ret_value=&(ent->cache); + +done: + FUNC_LEAVE(ret_value); } + /*------------------------------------------------------------------------- * Function: H5G_ent_modified @@ -78,11 +84,13 @@ H5G_ent_modified(H5G_entry_t *ent, H5G_type_t cache_type) assert(ent); - if (H5G_NO_CHANGE != ent->type) ent->type = cache_type; + if (H5G_NO_CHANGE != ent->type) + ent->type = cache_type; ent->dirty = TRUE; FUNC_LEAVE(SUCCEED); } + /*------------------------------------------------------------------------- * Function: H5G_ent_decode_vec @@ -110,6 +118,7 @@ herr_t H5G_ent_decode_vec(H5F_t *f, const uint8_t **pp, H5G_entry_t *ent, int n) { int i; + herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5G_ent_decode_vec, FAIL); @@ -121,13 +130,14 @@ H5G_ent_decode_vec(H5F_t *f, const uint8_t **pp, H5G_entry_t *ent, int n) /* decode entries */ for (i = 0; i < n; i++) { - if (H5G_ent_decode(f, pp, ent + i) < 0) { - HRETURN_ERROR(H5E_SYM, H5E_CANTDECODE, FAIL, "can't decode"); - } + if (H5G_ent_decode(f, pp, ent + i) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTDECODE, FAIL, "can't decode"); } - FUNC_LEAVE(SUCCEED); +done: + FUNC_LEAVE(ret_value); } + /*------------------------------------------------------------------------- * Function: H5G_ent_decode @@ -222,6 +232,7 @@ herr_t H5G_ent_encode_vec(H5F_t *f, uint8_t **pp, const H5G_entry_t *ent, int n) { int i; + herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5G_ent_encode_vec, FAIL); @@ -233,13 +244,14 @@ H5G_ent_encode_vec(H5F_t *f, uint8_t **pp, const H5G_entry_t *ent, int n) /* encode entries */ for (i = 0; i < n; i++) { - if (H5G_ent_encode(f, pp, ent + i) < 0) { - HRETURN_ERROR(H5E_SYM, H5E_CANTENCODE, FAIL, "can't encode"); - } + if (H5G_ent_encode(f, pp, ent + i) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTENCODE, FAIL, "can't encode"); } - FUNC_LEAVE(SUCCEED); +done: + FUNC_LEAVE(ret_value); } + /*------------------------------------------------------------------------- * Function: H5G_ent_encode @@ -286,21 +298,21 @@ H5G_ent_encode(H5F_t *f, uint8_t **pp, const H5G_entry_t *ent) /* encode scratch-pad */ switch (ent->type) { - case H5G_NOTHING_CACHED: - break; + case H5G_NOTHING_CACHED: + break; - case H5G_CACHED_STAB: - assert(2 * H5F_SIZEOF_ADDR(f) <= H5G_SIZEOF_SCRATCH); - H5F_addr_encode(f, pp, ent->cache.stab.btree_addr); - H5F_addr_encode(f, pp, ent->cache.stab.heap_addr); - break; + case H5G_CACHED_STAB: + assert(2 * H5F_SIZEOF_ADDR(f) <= H5G_SIZEOF_SCRATCH); + H5F_addr_encode(f, pp, ent->cache.stab.btree_addr); + H5F_addr_encode(f, pp, ent->cache.stab.heap_addr); + break; - case H5G_CACHED_SLINK: - UINT32ENCODE (*pp, ent->cache.slink.lval_offset); - break; + case H5G_CACHED_SLINK: + UINT32ENCODE (*pp, ent->cache.slink.lval_offset); + break; - default: - HDabort(); + default: + HDabort(); } } else { H5F_ENCODE_LENGTH(f, *pp, 0); |