diff options
author | Larry Knox <lrknox@hdfgroup.org> | 2020-10-09 14:17:31 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-09 14:17:31 (GMT) |
commit | d4b1ee1d861686b97a887f47ff3857e338d3f690 (patch) | |
tree | 8e0de772d9992287c1b169fb3fdaee624ab63844 /src/H5E.c | |
parent | 29874423bf155e23cfdc1920336c91674865f417 (diff) | |
parent | d62e0753021df5510b97b38aa632ba570ca84275 (diff) | |
download | hdf5-d4b1ee1d861686b97a887f47ff3857e338d3f690.zip hdf5-d4b1ee1d861686b97a887f47ff3857e338d3f690.tar.gz hdf5-d4b1ee1d861686b97a887f47ff3857e338d3f690.tar.bz2 |
Merge pull request #30 from byrnHDF/hdf5_1_12
Hdf5 1 12 merge changes from develop
Diffstat (limited to 'src/H5E.c')
-rw-r--r-- | src/H5E.c | 74 |
1 files changed, 21 insertions, 53 deletions
@@ -49,7 +49,6 @@ /* Headers */ /***********/ #include "H5private.h" /* Generic Functions */ -#include "H5CXprivate.h" /* API Contexts */ #include "H5Epkg.h" /* Error handling */ #include "H5FLprivate.h" /* Free lists */ #include "H5Iprivate.h" /* IDs */ @@ -498,9 +497,9 @@ done: * * Purpose: Closes an error class. * - * Return: SUCCEED/FAIL + * Return: Non-negative value on success/Negative on failure * - * Programmer: Raymond Lu + * Programmer: Raymond Lu * Friday, July 11, 2003 * *------------------------------------------------------------------------- @@ -1014,9 +1013,9 @@ done: * Purpose: Replaces current stack with specified stack. This closes the * stack ID also. * - * Return: SUCCEED/FAIL + * Return: Non-negative value on success/Negative on failure * - * Programmer: Raymond Lu + * Programmer: Raymond Lu * Friday, July 15, 2003 * *------------------------------------------------------------------------- @@ -1119,9 +1118,9 @@ done: * * Purpose: Closes an error stack. * - * Return: SUCCEED/FAIL + * Return: Non-negative value on success/Negative on failure * - * Programmer: Raymond Lu + * Programmer: Raymond Lu * Friday, July 14, 2003 * *------------------------------------------------------------------------- @@ -1254,9 +1253,9 @@ H5E__get_num(const H5E_t *estack) * * Purpose: Deletes some error messages from the top of error stack. * - * Return: SUCCEED/FAIL + * Return: Non-negative value on success/Negative on failure * - * Programmer: Raymond Lu + * Programmer: Raymond Lu * Friday, July 16, 2003 * *------------------------------------------------------------------------- @@ -1309,9 +1308,9 @@ done: * function name, file name, and error description strings must * be statically allocated. * - * Return: SUCCEED/FAIL + * Return: Non-negative on success/Negative on failure * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Monday, October 18, 1999 * * Notes: Basically a new public API wrapper around the H5E__push_stack @@ -1323,12 +1322,8 @@ herr_t H5Epush2(hid_t err_stack, const char *file, const char *func, unsigned line, hid_t cls_id, hid_t maj_id, hid_t min_id, const char *fmt, ...) { - va_list ap; /* Varargs info */ - H5E_t * estack; /* Pointer to error stack to modify */ -#ifndef H5_HAVE_VASPRINTF - int tmp_len; /* Current size of description buffer */ - int desc_len; /* Actual length of description when formatted */ -#endif /* H5_HAVE_VASPRINTF */ + va_list ap; /* Varargs info */ + H5E_t * estack; /* Pointer to error stack to modify */ char * tmp = NULL; /* Buffer to place formatted description in */ hbool_t va_started = FALSE; /* Whether the variable argument list is open */ herr_t ret_value = SUCCEED; /* Return value */ @@ -1357,31 +1352,9 @@ H5Epush2(hid_t err_stack, const char *file, const char *func, unsigned line, hid HDva_start(ap, fmt); va_started = TRUE; -#ifdef H5_HAVE_VASPRINTF /* Use the vasprintf() routine, since it does what we're trying to do below */ if (HDvasprintf(&tmp, fmt, ap) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") -#else /* H5_HAVE_VASPRINTF */ - /* Allocate space for the formatted description buffer */ - tmp_len = 128; - if (NULL == (tmp = H5MM_malloc((size_t)tmp_len))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") - - /* If the description doesn't fit into the initial buffer size, allocate more space and try again */ - while ((desc_len = HDvsnprintf(tmp, (size_t)tmp_len, fmt, ap)) > (tmp_len - 1)) { - /* shutdown & restart the va_list */ - HDva_end(ap); - HDva_start(ap, fmt); - - /* Release the previous description, it's too small */ - H5MM_xfree(tmp); - - /* Allocate a description of the appropriate length */ - tmp_len = desc_len + 1; - if (NULL == (tmp = H5MM_malloc((size_t)tmp_len))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") - } /* end while */ -#endif /* H5_HAVE_VASPRINTF */ /* Push the error on the stack */ if (H5E__push_stack(estack, file, func, line, cls_id, maj_id, min_id, tmp) < 0) @@ -1390,16 +1363,11 @@ H5Epush2(hid_t err_stack, const char *file, const char *func, unsigned line, hid done: if (va_started) HDva_end(ap); -#ifdef H5_HAVE_VASPRINTF /* Memory was allocated with HDvasprintf so it needs to be freed * with HDfree */ if (tmp) HDfree(tmp); -#else /* H5_HAVE_VASPRINTF */ - if (tmp) - H5MM_xfree(tmp); -#endif /* H5_HAVE_VASPRINTF */ FUNC_LEAVE_API(ret_value) } /* end H5Epush2() */ @@ -1409,9 +1377,9 @@ done: * * Purpose: Clears the error stack for the specified error stack. * - * Return: SUCCEED/FAIL + * Return: Non-negative on success/Negative on failure * - * Programmer: Raymond Lu + * Programmer: Raymond Lu * Wednesday, July 16, 2003 * *------------------------------------------------------------------------- @@ -1453,9 +1421,9 @@ done: * prints error messages. Users are encouraged to write their * own more specific error handlers. * - * Return: SUCCEED/FAIL + * Return: Non-negative on success/Negative on failure * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Friday, February 27, 1998 * *------------------------------------------------------------------------- @@ -1498,9 +1466,9 @@ done: * Purpose: Walks the error stack for the current thread and calls some * function for each error along the way. * - * Return: SUCCEED/FAIL + * Return: Non-negative on success/Negative on failure * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Friday, February 27, 1998 * *------------------------------------------------------------------------- @@ -1548,7 +1516,7 @@ done: * Either (or both) arguments may be null in which case the * value is not returned. * - * Return: SUCCEED/FAIL + * Return: Non-negative value on success/Negative on failure * * Programmer: Robb Matzke * Saturday, February 28, 1998 @@ -1605,7 +1573,7 @@ done: * Automatic stack traversal is always in the H5E_WALK_DOWNWARD * direction. * - * Return: SUCCEED/FAIL + * Return: Non-negative value on success/Negative on failure * * Programmer: Robb Matzke * Friday, February 27, 1998 @@ -1663,7 +1631,7 @@ done: * or the H5E_auto_t typedef. The IS_STACK parameter is set * to 1 for the first case and 0 for the latter case. * - * Return: SUCCEED/FAIL + * Return: Non-negative value on success/Negative on failure * * Programmer: Quincey Koziol * Wednesday, September 8, 2004 |