diff options
author | Kevin P. Fleming <kpfleming@digium.com> | 2009-05-05 10:34:19 +0000 |
---|---|---|
committer | Kevin P. Fleming <kpfleming@digium.com> | 2009-05-05 10:34:19 +0000 |
commit | ec5116f80c7ed6922bdc483f11b220ebbee8618b (patch) | |
tree | d0b46bfb8216c1ae395bd39991084a219a5e0966 /main/astobj2.c | |
parent | d8182202efdc2f292f64718cc038eee982850786 (diff) |
Properly account for memory allocated for channels and datastores
As in previous commits, when channels are allocated (with ast_channel_alloc) or datastores are allocated (with ast_datastore_alloc) properly account for the memory being owned by the caller, instead of the allocator function itself.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@192318 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main/astobj2.c')
-rw-r--r-- | main/astobj2.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/main/astobj2.c b/main/astobj2.c index a1e645ff9..81a3982f1 100644 --- a/main/astobj2.c +++ b/main/astobj2.c @@ -302,7 +302,7 @@ static int internal_ao2_ref(void *user_data, const int delta) * We always alloc at least the size of a void *, * for debugging purposes. */ -static void *internal_ao2_alloc(size_t data_size, ao2_destructor_fn destructor_fn, char *file, int line, const char *funcname) +static void *internal_ao2_alloc(size_t data_size, ao2_destructor_fn destructor_fn, const char *file, int line, const char *funcname) { /* allocation */ struct astobj2 *obj; @@ -335,11 +335,12 @@ static void *internal_ao2_alloc(size_t data_size, ao2_destructor_fn destructor_f return EXTERNAL_OBJ(obj); } -void *__ao2_alloc_debug(size_t data_size, ao2_destructor_fn destructor_fn, char *tag, char *file, int line, const char *funcname) +void *__ao2_alloc_debug(size_t data_size, ao2_destructor_fn destructor_fn, char *tag, + const char *file, int line, const char *funcname, int ref_debug) { /* allocation */ void *obj; - FILE *refo = fopen(REF_FILE,"a"); + FILE *refo = ref_debug ? fopen(REF_FILE,"a") : NULL; obj = internal_ao2_alloc(data_size, destructor_fn, file, line, funcname); @@ -443,13 +444,14 @@ static struct ao2_container *internal_ao2_container_alloc(struct ao2_container * } struct ao2_container *__ao2_container_alloc_debug(const unsigned int n_buckets, ao2_hash_fn *hash_fn, - ao2_callback_fn *cmp_fn, char *tag, char *file, int line, const char *funcname) + ao2_callback_fn *cmp_fn, char *tag, char *file, int line, + const char *funcname, int ref_debug) { /* XXX maybe consistency check on arguments ? */ /* compute the container size */ const unsigned int num_buckets = hash_fn ? n_buckets : 1; size_t container_size = sizeof(struct ao2_container) + num_buckets * sizeof(struct bucket); - struct ao2_container *c = __ao2_alloc_debug(container_size, container_destruct_debug, tag, file, line, funcname); + struct ao2_container *c = __ao2_alloc_debug(container_size, container_destruct_debug, tag, file, line, funcname, ref_debug); return internal_ao2_container_alloc(c, num_buckets, hash_fn, cmp_fn); } |