doc and log for *MustSucceed()
Replace the "never returns NULL." statement which is manifestly not true.
This commit is contained in:
@ -24,7 +24,7 @@ LIBCOM_API void * callocMustSucceed(size_t count, size_t size, const char *msg)
|
||||
void * mem = NULL;
|
||||
if (count > 0 && size > 0) {
|
||||
while ((mem = calloc(count, size)) == NULL) {
|
||||
errlogPrintf("%s: callocMustSucceed(%lu, %lu) - calloc failed\n",
|
||||
errlogPrintf("%s: callocMustSucceed(%lu, %lu) - " ERL_ERROR " calloc failed\n",
|
||||
msg, (unsigned long)count, (unsigned long)size);
|
||||
errlogPrintf("Thread %s (%p) suspending.\n",
|
||||
epicsThreadGetNameSelf(), (void *)epicsThreadGetIdSelf());
|
||||
@ -40,7 +40,7 @@ LIBCOM_API void * mallocMustSucceed(size_t size, const char *msg)
|
||||
void * mem = NULL;
|
||||
if (size > 0) {
|
||||
while ((mem = malloc(size)) == NULL) {
|
||||
errlogPrintf("%s: mallocMustSucceed(%lu) - malloc failed\n",
|
||||
errlogPrintf("%s: mallocMustSucceed(%lu) - " ERL_ERROR " malloc failed\n",
|
||||
msg, (unsigned long)size);
|
||||
errlogPrintf("Thread %s (%p) suspending.\n",
|
||||
epicsThreadGetNameSelf(), (void *)epicsThreadGetIdSelf());
|
||||
|
@ -56,18 +56,24 @@ LIBCOM_API void cantProceed(
|
||||
* gracefully when memory runs out.
|
||||
*/
|
||||
/** @{ */
|
||||
/** \brief A calloc() that never returns NULL.
|
||||
/** \brief A calloc() which suspends on error.
|
||||
* \param count Number of objects.
|
||||
* \param size Size of each object.
|
||||
* \param errorMessage What this memory is needed for.
|
||||
* \return Pointer to zeroed allocated memory.
|
||||
* \param errorMessage Context added to logged error message
|
||||
* \return Pointer to zeroed allocated memory. Should later be free() d
|
||||
*
|
||||
* Will always return NULL for a zero length allocation.
|
||||
* Will never return NULL otherwise.
|
||||
*/
|
||||
LIBCOM_API void * callocMustSucceed(size_t count, size_t size,
|
||||
const char *errorMessage);
|
||||
/** \brief A malloc() that never returns NULL.
|
||||
/** \brief A malloc() which suspends on error.
|
||||
* \param size Size of block to allocate.
|
||||
* \param errorMessage What this memory is needed for.
|
||||
* \return Pointer to allocated memory.
|
||||
* \param errorMessage Context added to logged error message
|
||||
* \return Pointer to allocated memory. Should later be free() d
|
||||
*
|
||||
* Will always return NULL for a zero length allocation.
|
||||
* Will never return NULL otherwise.
|
||||
*/
|
||||
LIBCOM_API void * mallocMustSucceed(size_t size, const char *errorMessage);
|
||||
/** @} */
|
||||
|
Reference in New Issue
Block a user