aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2006-12-27 18:29:13 +0000
committerkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2006-12-27 18:29:13 +0000
commit1690223ee5606043a8f768529d35eb52da1b5ea4 (patch)
tree26aeb8f817503c38e44f77aa2ab8ee05d2caa403 /include
parentb0241a8bab4f7dbeba8ca3b824c2e5933e8842eb (diff)
allow 'show memory' and 'show memory summary' to distinguish memory allocations that were done for caching purposes, so they don't look like memory leaks
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@48987 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'include')
-rw-r--r--include/asterisk/astmm.h4
-rw-r--r--include/asterisk/utils.h13
2 files changed, 17 insertions, 0 deletions
diff --git a/include/asterisk/astmm.h b/include/asterisk/astmm.h
index 7e987b099..f1f838ef0 100644
--- a/include/asterisk/astmm.h
+++ b/include/asterisk/astmm.h
@@ -44,6 +44,7 @@
#undef vasprintf
void *__ast_calloc(size_t nmemb, size_t size, const char *file, int lineno, const char *func);
+void *__ast_calloc_cache(size_t nmemb, size_t size, const char *file, int lineno, const char *func);
void *__ast_malloc(size_t size, const char *file, int lineno, const char *func);
void __ast_free(void *ptr, const char *file, int lineno, const char *func);
void *__ast_realloc(void *ptr, size_t size, const char *file, int lineno, const char *func);
@@ -59,6 +60,9 @@ void __ast_mm_init(void);
#define calloc(a,b) \
__ast_calloc(a,b,__FILE__, __LINE__, __PRETTY_FUNCTION__)
+#define ast_calloc_cache(a,b) \
+ __ast_calloc_cache(a,b,__FILE__, __LINE__, __PRETTY_FUNCTION__)
+
#define malloc(a) \
__ast_malloc(a,__FILE__, __LINE__, __PRETTY_FUNCTION__)
diff --git a/include/asterisk/utils.h b/include/asterisk/utils.h
index 3fb817980..0322e506b 100644
--- a/include/asterisk/utils.h
+++ b/include/asterisk/utils.h
@@ -362,6 +362,19 @@ void * attribute_malloc _ast_calloc(size_t num, size_t len, const char *file, in
)
/*!
+ * \brief A wrapper for calloc() for use in cache pools
+ *
+ * ast_calloc_cache() is a wrapper for calloc() that will generate an Asterisk log
+ * message in the case that the allocation fails. When memory debugging is in use,
+ * the memory allocated by this function will be marked as 'cache' so it can be
+ * distinguished from normal memory allocations.
+ *
+ * The arguments and return value are the same as calloc()
+ */
+#define ast_calloc_cache(num, len) \
+ _ast_calloc((num), (len), __FILE__, __LINE__, __PRETTY_FUNCTION__)
+
+/*!
* \brief A wrapper for realloc()
*
* ast_realloc() is a wrapper for realloc() that will generate an Asterisk log