summaryrefslogtreecommitdiffstats
path: root/src/H5Oname.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/H5Oname.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/H5Oname.c')
-rw-r--r--src/H5Oname.c44
1 files changed, 31 insertions, 13 deletions
diff --git a/src/H5Oname.c b/src/H5Oname.c
index cd39d24..bbd4cb1 100644
--- a/src/H5Oname.c
+++ b/src/H5Oname.c
@@ -73,7 +73,8 @@ static void *
H5O_name_decode(H5F_t UNUSED *f, const uint8_t *p,
H5O_shared_t UNUSED *sh)
{
- H5O_name_t *mesg;
+ H5O_name_t *mesg;
+ void *ret_value; /* Return value */
FUNC_ENTER_NOAPI(H5O_name_decode, NULL);
@@ -84,15 +85,22 @@ H5O_name_decode(H5F_t UNUSED *f, const uint8_t *p,
/* decode */
if (NULL==(mesg = H5MM_calloc(sizeof(H5O_name_t))) ||
- NULL==(mesg->s = H5MM_malloc (HDstrlen((const char*)p)+1))) {
- H5MM_xfree (mesg);
- HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
- "memory allocation failed");
- }
+ NULL==(mesg->s = H5MM_malloc (HDstrlen((const char*)p)+1)))
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
HDstrcpy(mesg->s, (const char*)p);
- FUNC_LEAVE(mesg);
+ /* Set return value */
+ ret_value=mesg;
+
+done:
+ if(ret_value==NULL) {
+ if(mesg)
+ H5MM_xfree (mesg);
+ } /* end if */
+
+ FUNC_LEAVE(ret_value);
}
+
/*-------------------------------------------------------------------------
* Function: H5O_name_encode
@@ -123,8 +131,10 @@ H5O_name_encode(H5F_t UNUSED *f, uint8_t *p, const void *_mesg)
/* encode */
HDstrcpy((char*)p, mesg->s);
+
FUNC_LEAVE(SUCCEED);
}
+
/*-------------------------------------------------------------------------
* Function: H5O_name_copy
@@ -149,22 +159,27 @@ H5O_name_copy(const void *_mesg, void *_dest)
{
const H5O_name_t *mesg = (const H5O_name_t *) _mesg;
H5O_name_t *dest = (H5O_name_t *) _dest;
+ void *ret_value; /* Return value */
FUNC_ENTER_NOAPI(H5O_name_copy, NULL);
/* check args */
assert(mesg);
- if (!dest && NULL==(dest = H5MM_calloc(sizeof(H5O_name_t)))) {
- HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
- "memory allocation failed");
- }
+ if (!dest && NULL==(dest = H5MM_calloc(sizeof(H5O_name_t))))
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
/* copy */
*dest = *mesg;
- dest->s = H5MM_xstrdup(mesg->s);
+ if((dest->s = H5MM_xstrdup(mesg->s))==NULL)
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
- FUNC_LEAVE((void *) dest);
+ /* Set return value */
+ ret_value=dest;
+
+done:
+ FUNC_LEAVE(ret_value);
}
+
/*-------------------------------------------------------------------------
* Function: H5O_name_size
@@ -199,8 +214,10 @@ H5O_name_size(H5F_t UNUSED *f, const void *_mesg)
assert(mesg);
size = mesg->s ? HDstrlen(mesg->s) + 1 : 0;
+
FUNC_LEAVE(size);
}
+
/*-------------------------------------------------------------------------
* Function: H5O_name_reset
@@ -233,6 +250,7 @@ H5O_name_reset(void *_mesg)
FUNC_LEAVE(SUCCEED);
}
+
/*-------------------------------------------------------------------------
* Function: H5O_name_debug