diff options
author | Richard Mudgett <rmudgett@digium.com> | 2013-08-16 16:22:26 +0000 |
---|---|---|
committer | Richard Mudgett <rmudgett@digium.com> | 2013-08-16 16:22:26 +0000 |
commit | 745df0fb81c32a1dbec0c6ec8565f7f426658d39 (patch) | |
tree | 1d9d248bffdf15e3e6592dbf4748b593d52ac409 /include | |
parent | f29d969a7969b1122b5039747550c1cb039abd23 (diff) |
utils.h: Minor formatting tweaks.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@396849 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'include')
-rw-r--r-- | include/asterisk/utils.h | 39 |
1 files changed, 24 insertions, 15 deletions
diff --git a/include/asterisk/utils.h b/include/asterisk/utils.h index 599beba54..1623775b9 100644 --- a/include/asterisk/utils.h +++ b/include/asterisk/utils.h @@ -484,23 +484,26 @@ static void ast_free_ptr(void *ptr) #ifndef __AST_DEBUG_MALLOC -/* This buffer is in static memory. We never intend to read it, +/* + * This buffer is in static memory. We never intend to read it, * nor do we care about multiple threads writing to it at the * same time. We only want to know if we're recursing too deep - * already. 60 entries should be more than enough. Function call - * depth rarely exceeds 20 or so. */ + * already. 60 entries should be more than enough. Function + * call depth rarely exceeds 20 or so. + */ #define _AST_MEM_BACKTRACE_BUFLEN 60 extern void *_ast_mem_backtrace_buffer[_AST_MEM_BACKTRACE_BUFLEN]; +/* + * Ok, this sucks. But if we're already out of mem, we don't + * want the logger to create infinite recursion (and a crash). + */ #define MALLOC_FAILURE_MSG \ - { \ - /* Ok, this sucks. But if we're already out of mem, we don't \ - * want the logger to create infinite recursion (and a crash). */ \ - if (backtrace(_ast_mem_backtrace_buffer, _AST_MEM_BACKTRACE_BUFLEN) < \ - _AST_MEM_BACKTRACE_BUFLEN) { \ + do { \ + if (backtrace(_ast_mem_backtrace_buffer, _AST_MEM_BACKTRACE_BUFLEN) < _AST_MEM_BACKTRACE_BUFLEN) { \ ast_log(LOG_ERROR, "Memory Allocation Failure in function %s at line %d of %s\n", func, lineno, file); \ } \ - } + } while (0) /*! * \brief A wrapper for malloc() @@ -518,8 +521,9 @@ void * attribute_malloc _ast_malloc(size_t len, const char *file, int lineno, co { void *p; - if (!(p = malloc(len))) + if (!(p = malloc(len))) { MALLOC_FAILURE_MSG; + } return p; } @@ -541,8 +545,9 @@ void * attribute_malloc _ast_calloc(size_t num, size_t len, const char *file, in { void *p; - if (!(p = calloc(num, len))) + if (!(p = calloc(num, len))) { MALLOC_FAILURE_MSG; + } return p; } @@ -577,8 +582,9 @@ void * attribute_malloc _ast_realloc(void *p, size_t len, const char *file, int { void *newp; - if (!(newp = realloc(p, len))) + if (!(newp = realloc(p, len))) { MALLOC_FAILURE_MSG; + } return newp; } @@ -605,8 +611,9 @@ char * attribute_malloc _ast_strdup(const char *str, const char *file, int linen char *newstr = NULL; if (str) { - if (!(newstr = strdup(str))) + if (!(newstr = strdup(str))) { MALLOC_FAILURE_MSG; + } } return newstr; @@ -634,8 +641,9 @@ char * attribute_malloc _ast_strndup(const char *str, size_t len, const char *fi char *newstr = NULL; if (str) { - if (!(newstr = strndup(str, len))) + if (!(newstr = strndup(str, len))) { MALLOC_FAILURE_MSG; + } } return newstr; @@ -673,8 +681,9 @@ int _ast_vasprintf(char **ret, const char *file, int lineno, const char *func, c { int res; - if ((res = vasprintf(ret, fmt, ap)) == -1) + if ((res = vasprintf(ret, fmt, ap)) == -1) { MALLOC_FAILURE_MSG; + } return res; } |