mirror of
https://github.com/asterisk/asterisk.git
synced 2025-11-21 01:01:02 +00:00
Merged revisions 192318 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk ........ r192318 | kpfleming | 2009-05-05 12:34:19 +0200 (Tue, 05 May 2009) | 5 lines 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/branches/1.6.0@192353 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -761,13 +761,16 @@ static const struct ast_channel_tech null_tech = {
|
||||
};
|
||||
|
||||
/*! \brief Create a new channel structure */
|
||||
struct ast_channel *ast_channel_alloc(int needqueue, int state, const char *cid_num, const char *cid_name, const char *acctcode, const char *exten, const char *context, const int amaflag, const char *name_fmt, ...)
|
||||
static struct ast_channel * attribute_malloc __attribute__((format(printf, 12, 0)))
|
||||
__ast_channel_alloc_ap(int needqueue, int state, const char *cid_num, const char *cid_name,
|
||||
const char *acctcode, const char *exten, const char *context,
|
||||
const int amaflag, const char *file, int line, const char *function,
|
||||
const char *name_fmt, va_list ap1, va_list ap2)
|
||||
{
|
||||
struct ast_channel *tmp;
|
||||
int x;
|
||||
int flags;
|
||||
struct varshead *headp;
|
||||
va_list ap1, ap2;
|
||||
|
||||
/* If shutting down, don't allocate any new channels */
|
||||
if (shutting_down) {
|
||||
@@ -775,8 +778,15 @@ struct ast_channel *ast_channel_alloc(int needqueue, int state, const char *cid_
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!(tmp = ast_calloc(1, sizeof(*tmp))))
|
||||
#if defined(__AST_DEBUG_MALLOC)
|
||||
if (!(tmp = __ast_calloc(1, sizeof(*tmp), file, line, function))) {
|
||||
return NULL;
|
||||
}
|
||||
#else
|
||||
if (!(tmp = ast_calloc(1, sizeof(*tmp)))) {
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!(tmp->sched = sched_context_create())) {
|
||||
ast_log(LOG_WARNING, "Channel allocation failed: Unable to create schedule context\n");
|
||||
@@ -878,11 +888,7 @@ alertpipe_failed:
|
||||
* uses them to build the string, instead of forming the va_lists internally from the vararg ... list.
|
||||
* This new function was written so this can be accomplished.
|
||||
*/
|
||||
va_start(ap1, name_fmt);
|
||||
va_start(ap2, name_fmt);
|
||||
ast_string_field_build_va(tmp, name, name_fmt, ap1, ap2);
|
||||
va_end(ap1);
|
||||
va_end(ap2);
|
||||
}
|
||||
|
||||
/* Reminder for the future: under what conditions do we NOT want to track cdrs on channels? */
|
||||
@@ -956,6 +962,25 @@ alertpipe_failed:
|
||||
return tmp;
|
||||
}
|
||||
|
||||
struct ast_channel *__ast_channel_alloc(int needqueue, int state, const char *cid_num,
|
||||
const char *cid_name, const char *acctcode,
|
||||
const char *exten, const char *context,
|
||||
const int amaflag, const char *file, int line,
|
||||
const char *function, const char *name_fmt, ...)
|
||||
{
|
||||
va_list ap1, ap2;
|
||||
struct ast_channel *result;
|
||||
|
||||
va_start(ap1, name_fmt);
|
||||
va_start(ap2, name_fmt);
|
||||
result = __ast_channel_alloc_ap(needqueue, state, cid_num, cid_name, acctcode, exten, context,
|
||||
amaflag, file, line, function, name_fmt, ap1, ap2);
|
||||
va_end(ap1);
|
||||
va_end(ap2);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/*! \brief Queue an outgoing media frame */
|
||||
static int __ast_queue_frame(struct ast_channel *chan, struct ast_frame *fin, int head)
|
||||
{
|
||||
@@ -5467,3 +5492,37 @@ int ast_say_digits_full(struct ast_channel *chan, int num,
|
||||
|
||||
return ast_say_digit_str_full(chan, buf, ints, lang, audiofd, ctrlfd);
|
||||
}
|
||||
|
||||
/* DO NOT PUT ADDITIONAL FUNCTIONS BELOW THIS BOUNDARY
|
||||
*
|
||||
* ONLY FUNCTIONS FOR PROVIDING BACKWARDS ABI COMPATIBILITY BELONG HERE
|
||||
*
|
||||
*/
|
||||
|
||||
/* Provide binary compatibility for modules that call ast_channel_alloc() directly;
|
||||
* newly compiled modules will call __ast_channel_alloc() via the macros in channel.h
|
||||
*/
|
||||
#undef ast_channel_alloc
|
||||
struct ast_channel __attribute__((format(printf, 9, 10)))
|
||||
*ast_channel_alloc(int needqueue, int state, const char *cid_num,
|
||||
const char *cid_name, const char *acctcode,
|
||||
const char *exten, const char *context,
|
||||
const int amaflag, const char *name_fmt, ...);
|
||||
struct ast_channel *ast_channel_alloc(int needqueue, int state, const char *cid_num,
|
||||
const char *cid_name, const char *acctcode,
|
||||
const char *exten, const char *context,
|
||||
const int amaflag, const char *name_fmt, ...)
|
||||
{
|
||||
va_list ap1, ap2;
|
||||
struct ast_channel *result;
|
||||
|
||||
|
||||
va_start(ap1, name_fmt);
|
||||
va_start(ap2, name_fmt);
|
||||
result = __ast_channel_alloc_ap(needqueue, state, cid_num, cid_name, acctcode, exten, context,
|
||||
amaflag, __FILE__, __LINE__, __FUNCTION__, name_fmt, ap1, ap2);
|
||||
va_end(ap1);
|
||||
va_end(ap2);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user