summaryrefslogtreecommitdiffstats
path: root/src/H5MM.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/H5MM.c')
-rw-r--r--src/H5MM.c53
1 files changed, 25 insertions, 28 deletions
diff --git a/src/H5MM.c b/src/H5MM.c
index c27f9d1..19aafdf 100644
--- a/src/H5MM.c
+++ b/src/H5MM.c
@@ -145,20 +145,18 @@ H5MM_realloc(void *mem, size_t size)
/*-------------------------------------------------------------------------
- * Function: H5MM_xstrdup
+ * Function: H5MM_xstrdup
*
- * Purpose: Duplicates a string. If the string to be duplicated is the
- * null pointer, then return null. If the string to be duplicated
- * is the empty string then return a new empty string.
+ * Purpose: Duplicates a string, including memory allocation.
+ * NULL is an acceptable value for the input string.
*
- * Return: Success: Ptr to a new string (or null if no string).
+ * Return: Success: Pointer to a new string (NULL if s is NULL).
*
- * Failure: abort()
- *
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Jul 10 1997
+ * Failure: abort()
*
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Jul 10 1997
*-------------------------------------------------------------------------
*/
char *
@@ -166,49 +164,48 @@ H5MM_xstrdup(const char *s)
{
char *ret_value = NULL;
- /* Use FUNC_ENTER_NOAPI_NOINIT_NOFUNC here to avoid performance issues */
- FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5MM_xstrdup)
+ FUNC_ENTER_NOAPI(H5MM_xstrdup, NULL)
if(s) {
- ret_value = (char *)H5MM_malloc(HDstrlen(s) + 1);
- HDassert(ret_value);
+ if(NULL == (ret_value = (char *)H5MM_malloc(HDstrlen(s) + 1)))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
HDstrcpy(ret_value, s);
} /* end if */
+done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5MM_xstrdup() */
/*-------------------------------------------------------------------------
- * Function: H5MM_strdup
+ * Function: H5MM_strdup
*
- * Purpose: Duplicates a string. If the string to be duplicated is the
- * null pointer, then return null. If the string to be duplicated
- * is the empty string then return a new empty string.
+ * Purpose: Duplicates a string, including memory allocation.
+ * NULL is NOT an acceptable value for the input string.
*
- * Return: Success: Ptr to a new string (or null if no string).
+ * If the string to be duplicated is the NULL pointer, then
+ * an error will be raised.
*
- * Failure: abort()
+ * Return: Success: Pointer to a new string
*
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Jul 10 1997
- *
- * Modifications:
+ * Failure: abort()
*
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Jul 10 1997
*-------------------------------------------------------------------------
*/
char *
H5MM_strdup(const char *s)
{
- char *ret_value;
+ char *ret_value;
FUNC_ENTER_NOAPI(H5MM_strdup, NULL)
if(!s)
- HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "null string")
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "null string")
if(NULL == (ret_value = (char *)H5MM_malloc(HDstrlen(s) + 1)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
HDstrcpy(ret_value, s);
done: