summaryrefslogtreecommitdiffstats
path: root/src/H5Oname.c
diff options
context:
space:
mode:
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