summaryrefslogtreecommitdiffstats
path: root/src/H5MM.c
diff options
context:
space:
mode:
authorDana Robinson <derobins@hdfgroup.org>2011-10-11 20:33:13 (GMT)
committerDana Robinson <derobins@hdfgroup.org>2011-10-11 20:33:13 (GMT)
commit268d79925ba45493c259a96c72c3e89f9d6472c3 (patch)
tree6bc979a3ae28089468eafdfe119d1c81b4575d5f /src/H5MM.c
parent55ae6dfd1a4dcd298195a5ab4c291e444708d143 (diff)
downloadhdf5-268d79925ba45493c259a96c72c3e89f9d6472c3.zip
hdf5-268d79925ba45493c259a96c72c3e89f9d6472c3.tar.gz
hdf5-268d79925ba45493c259a96c72c3e89f9d6472c3.tar.bz2
[svn-r21522] - H5MM_strdup() and H5MM_xstrdup() comments changed to correctly reflect how they respond to an input NULL string.
- H5MM_xstrdup() now reports memory allocation errors via the HDF5 error stack (was previously an assert). Tested on jam (simple change).
Diffstat (limited to 'src/H5MM.c')
-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 *