summaryrefslogtreecommitdiffstats
path: root/src/H5Oshared.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2002-08-08 16:52:55 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2002-08-08 16:52:55 (GMT)
commitd8397a6f426227d09d20e647ce8b12b8c6295b2d (patch)
tree2943fbfd2bfb66cf167eb642835fdb4deb3afd3c /src/H5Oshared.c
parent573307786a1f5f7ce597e5191ea08c3bbd95b66c (diff)
downloadhdf5-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/H5Oshared.c')
-rw-r--r--src/H5Oshared.c26
1 files changed, 16 insertions, 10 deletions
diff --git a/src/H5Oshared.c b/src/H5Oshared.c
index d012149..29e93bf 100644
--- a/src/H5Oshared.c
+++ b/src/H5Oshared.c
@@ -68,8 +68,9 @@ static int interface_initialize_g = 0;
static void *
H5O_shared_decode (H5F_t *f, const uint8_t *buf, H5O_shared_t UNUSED *sh)
{
- H5O_shared_t *mesg;
+ H5O_shared_t *mesg=NULL;
unsigned flags, version;
+ void *ret_value; /* Return value */
FUNC_ENTER_NOAPI(H5O_shared_decode, NULL);
@@ -79,17 +80,13 @@ H5O_shared_decode (H5F_t *f, const uint8_t *buf, H5O_shared_t UNUSED *sh)
assert (!sh);
/* Decode */
- if (NULL==(mesg = H5MM_calloc (sizeof *mesg))) {
- HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
- "memory allocation failed");
- }
+ if (NULL==(mesg = H5MM_calloc (sizeof *mesg)))
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
/* Version */
version = *buf++;
- if (version!=H5O_SHARED_VERSION) {
- HRETURN_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL,
- "bad version number for shared object message");
- }
+ if (version!=H5O_SHARED_VERSION)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "bad version number for shared object message");
/* Flags */
flags = *buf++;
@@ -106,7 +103,16 @@ H5O_shared_decode (H5F_t *f, const uint8_t *buf, H5O_shared_t UNUSED *sh)
H5G_ent_decode (f, &buf, &(mesg->u.ent));
}
- FUNC_LEAVE (mesg);
+ /* Set return value */
+ ret_value=mesg;
+
+done:
+ if(ret_value==NULL) {
+ if(mesg!=NULL)
+ H5MM_xfree(mesg);
+ } /* end if */
+
+ FUNC_LEAVE (ret_value);
}