[asterisk-commits] eliel: trunk r200108 - /trunk/main/channel.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Thu Jun 11 10:40:06 CDT 2009
Author: eliel
Date: Thu Jun 11 10:40:03 2009
New Revision: 200108
URL: http://svn.asterisk.org/svn-view/asterisk?view=rev&rev=200108
Log:
Release the allocated channel decreasing the reference counter.
When allocating the channel use ao2_ref(-1) to release it, instead of calling
ast_free().
Also avoid freeing structures inside that channel (on error) if they will be
released by the channel destructor being called if the reference counter reachs
0.
Modified:
trunk/main/channel.c
Modified: trunk/main/channel.c
URL: http://svn.asterisk.org/svn-view/asterisk/trunk/main/channel.c?view=diff&rev=200108&r1=200107&r2=200108
==============================================================================
--- trunk/main/channel.c (original)
+++ trunk/main/channel.c Thu Jun 11 10:40:03 2009
@@ -812,27 +812,20 @@
if (!(tmp->sched = sched_context_create())) {
ast_log(LOG_WARNING, "Channel allocation failed: Unable to create schedule context\n");
- ast_free(tmp);
- return NULL;
+ return ast_channel_unref(tmp);
}
if ((ast_string_field_init(tmp, 128))) {
- sched_context_destroy(tmp->sched);
- ast_free(tmp);
- return NULL;
+ return ast_channel_unref(tmp);
}
if (cid_name) {
if (!(tmp->cid.cid_name = ast_strdup(cid_name))) {
- ast_string_field_free_memory(tmp);
- sched_context_destroy(tmp->sched);
return ast_channel_unref(tmp);
}
}
if (cid_num) {
if (!(tmp->cid.cid_num = ast_strdup(cid_num))) {
- ast_string_field_free_memory(tmp);
- sched_context_destroy(tmp->sched);
return ast_channel_unref(tmp);
}
}
More information about the asterisk-commits
mailing list