aboutsummaryrefslogtreecommitdiffstats
path: root/main/astobj2.c
diff options
context:
space:
mode:
authorkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2009-05-04 19:20:58 +0000
committerkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2009-05-04 19:20:58 +0000
commitafd79973ae1fedd5ad132ba221e29e76fb32f336 (patch)
tree9c2daae4bc4f53200ba91894fd0e2dcb55d83f0f /main/astobj2.c
parente9ec26aac95bc2194091190cd6b366e5289cdcfb (diff)
Merged revisions 192059 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk ........ r192059 | kpfleming | 2009-05-04 18:24:16 +0200 (Mon, 04 May 2009) | 5 lines Ensure that astobj2 memory allocations are properly accounted for when MALLOC_DEBUG is used This commit ensures that all astobj2 allocated objects are properly accounted for in MALLOC_DEBUG mode by passing down the file/function/line information from the module/function that actually called the astobj2 allocation function. ........ git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.6.1@192154 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'main/astobj2.c')
-rw-r--r--main/astobj2.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/main/astobj2.c b/main/astobj2.c
index 2e749a99b..5b969c6cc 100644
--- a/main/astobj2.c
+++ b/main/astobj2.c
@@ -130,7 +130,6 @@ static inline struct astobj2 *INTERNAL_OBJ(void *user_data)
/* the underlying functions common to debug and non-debug versions */
static int __ao2_ref(void *user_data, const int delta);
-static void *__ao2_alloc(size_t data_size, ao2_destructor_fn destructor_fn);
static struct ao2_container *__ao2_container_alloc(struct ao2_container *c, const uint n_buckets, ao2_hash_fn *hash_fn,
ao2_callback_fn *cmp_fn);
static struct bucket_list *__ao2_link(struct ao2_container *c, void *user_data);
@@ -298,7 +297,7 @@ static int __ao2_ref(void *user_data, const int delta)
* We always alloc at least the size of a void *,
* for debugging purposes.
*/
-static void *__ao2_alloc(size_t data_size, ao2_destructor_fn destructor_fn)
+static void *__ao2_alloc(size_t data_size, ao2_destructor_fn destructor_fn, char *file, int line, const char *funcname)
{
/* allocation */
struct astobj2 *obj;
@@ -306,7 +305,11 @@ static void *__ao2_alloc(size_t data_size, ao2_destructor_fn destructor_fn)
if (data_size < sizeof(void *))
data_size = sizeof(void *);
+#if defined(__AST_DEBUG_MALLOC)
+ obj = __ast_calloc(1, sizeof(*obj) + data_size, file, line, funcname);
+#else
obj = ast_calloc(1, sizeof(*obj) + data_size);
+#endif
if (obj == NULL)
return NULL;
@@ -333,7 +336,7 @@ void *_ao2_alloc_debug(size_t data_size, ao2_destructor_fn destructor_fn, char *
void *obj;
FILE *refo = fopen(REF_FILE,"a");
- obj = __ao2_alloc(data_size, destructor_fn);
+ obj = __ao2_alloc(data_size, destructor_fn, file, line, funcname);
if (obj == NULL)
return NULL;
@@ -349,7 +352,7 @@ void *_ao2_alloc_debug(size_t data_size, ao2_destructor_fn destructor_fn, char *
void *_ao2_alloc(size_t data_size, ao2_destructor_fn destructor_fn)
{
- return __ao2_alloc(data_size, destructor_fn);
+ return __ao2_alloc(data_size, destructor_fn, NULL, 0, NULL);
}