summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/H5MM.c47
1 files changed, 22 insertions, 25 deletions
diff --git a/src/H5MM.c b/src/H5MM.c
index c27f9d1..5555fc9 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,36 +164,35 @@ 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 *