summaryrefslogtreecommitdiff
path: root/apps/app_rpt.c
diff options
context:
space:
mode:
authorBJ Weschke <bweschke@btwtech.com>2006-01-13 03:25:23 +0000
committerBJ Weschke <bweschke@btwtech.com>2006-01-13 03:25:23 +0000
commit8637b23569d357bcdc155259642ebc979612806e (patch)
treeac5d62b21dfc242f96e660a8c9bb029b300701cb /apps/app_rpt.c
parent8d4ee3882a0bdad0146f749d48aba1ec335ae9e6 (diff)
More memory wrapper and cleanup work. #6226 w/one very minor compile fix mod in app_rpt.c
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@8044 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'apps/app_rpt.c')
-rw-r--r--apps/app_rpt.c56
1 files changed, 17 insertions, 39 deletions
diff --git a/apps/app_rpt.c b/apps/app_rpt.c
index cc1f1038b..9deba11c1 100644
--- a/apps/app_rpt.c
+++ b/apps/app_rpt.c
@@ -1041,8 +1041,7 @@ struct tm localtm;
/* allocate a pseudo-channel thru asterisk */
- mychannel = ast_request("zap",AST_FORMAT_SLINEAR,"pseudo",NULL);
- if (!mychannel)
+ if (!(mychannel = ast_request("zap",AST_FORMAT_SLINEAR,"pseudo",NULL)))
{
fprintf(stderr,"rpt:Sorry unable to obtain pseudo channel\n");
ast_mutex_lock(&myrpt->lock);
@@ -1312,11 +1311,9 @@ struct tm localtm;
{
l = l->next;
continue;
- }
- m = ast_malloc(sizeof(*m));
- if (!m)
+ }
+ if (!(m = ast_malloc(sizeof(*m))))
{
- ast_log(LOG_WARNING, "Cannot alloc memory on %s\n", mychannel->name);
ast_mutex_lock(&myrpt->lock);
remque((struct qelem *)mytele);
ast_mutex_unlock(&myrpt->lock);
@@ -1563,16 +1560,12 @@ static void rpt_telemetry(struct rpt *myrpt,int mode, void *data)
struct rpt_tele *tele;
struct rpt_link *mylink = (struct rpt_link *) data;
pthread_attr_t attr;
-
- tele = ast_malloc(sizeof(*tele));
- if (!tele)
+
+ if (!(tele = ast_calloc(1, sizeof(*tele))))
{
- ast_log(LOG_WARNING, "Unable to allocate memory\n");
pthread_exit(NULL);
return;
}
- /* zero it out */
- memset((char *)tele,0,sizeof(struct rpt_tele));
tele->rpt = myrpt;
tele->mode = mode;
ast_mutex_lock(&myrpt->lock);
@@ -1605,8 +1598,7 @@ struct ast_channel *mychannel,*genchannel;
myrpt->mydtmf = 0;
/* allocate a pseudo-channel thru asterisk */
- mychannel = ast_request("zap",AST_FORMAT_SLINEAR,"pseudo",NULL);
- if (!mychannel)
+ if (!(mychannel = ast_request("zap",AST_FORMAT_SLINEAR,"pseudo",NULL)))
{
fprintf(stderr,"rpt:Sorry unable to obtain pseudo channel\n");
pthread_exit(NULL);
@@ -1624,8 +1616,7 @@ struct ast_channel *mychannel,*genchannel;
pthread_exit(NULL);
}
/* allocate a pseudo-channel thru asterisk */
- genchannel = ast_request("zap",AST_FORMAT_SLINEAR,"pseudo",NULL);
- if (!genchannel)
+ if (!(genchannel = ast_request("zap",AST_FORMAT_SLINEAR,"pseudo",NULL)))
{
fprintf(stderr,"rpt:Sorry unable to obtain pseudo channel\n");
ast_hangup(mychannel);
@@ -1951,10 +1942,8 @@ static int function_ilink(struct rpt *myrpt, char *param, char *digits, int comm
} else
ast_mutex_unlock(&myrpt->lock);
strncpy(myrpt->lastlinknode,digitbuf,MAXNODESTR - 1);
- /* establish call in monitor mode */
- l = ast_calloc(1, sizeof(*l));
- if (!l){
- ast_log(LOG_WARNING, "Unable to malloc\n");
+ /* establish call in monitor mode */
+ if (!(l = ast_calloc(1, sizeof(*l)))) {
return DC_ERROR;
}
/* zero the silly thing */
@@ -1993,8 +1982,7 @@ static int function_ilink(struct rpt *myrpt, char *param, char *digits, int comm
return DC_ERROR;
}
/* allocate a pseudo-channel thru asterisk */
- l->pchan = ast_request("zap",AST_FORMAT_SLINEAR,"pseudo",NULL);
- if (!l->pchan){
+ if (!(l->pchan = ast_request("zap",AST_FORMAT_SLINEAR,"pseudo",NULL))) {
fprintf(stderr,"rpt:Sorry unable to obtain pseudo channel\n");
ast_hangup(l->chan);
free(l);
@@ -2065,9 +2053,7 @@ static int function_ilink(struct rpt *myrpt, char *param, char *digits, int comm
ast_mutex_unlock(&myrpt->lock);
strncpy(myrpt->lastlinknode,digitbuf,MAXNODESTR - 1);
/* establish call in tranceive mode */
- l = ast_calloc(1, sizeof(*l));
- if (!l){
- ast_log(LOG_WARNING, "Unable to malloc\n");
+ if (!(l = ast_calloc(1, sizeof(*l)))) {
return(DC_ERROR);
}
l->mode = 1;
@@ -2107,8 +2093,7 @@ static int function_ilink(struct rpt *myrpt, char *param, char *digits, int comm
return DC_ERROR;
}
/* allocate a pseudo-channel thru asterisk */
- l->pchan = ast_request("zap",AST_FORMAT_SLINEAR,"pseudo",NULL);
- if (!l->pchan){
+ if (!(l->pchan = ast_request("zap",AST_FORMAT_SLINEAR,"pseudo",NULL))) {
fprintf(stderr,"rpt:Sorry unable to obtain pseudo channel\n");
ast_hangup(l->chan);
free(l);
@@ -4711,8 +4696,7 @@ char cmd[MAXDTMF+1] = "";
ast_indicate(myrpt->txchannel,AST_CONTROL_RADIO_KEY);
ast_indicate(myrpt->txchannel,AST_CONTROL_RADIO_UNKEY);
/* allocate a pseudo-channel thru asterisk */
- myrpt->pchannel = ast_request("zap",AST_FORMAT_SLINEAR,"pseudo",NULL);
- if (!myrpt->pchannel)
+ if (!(myrpt->pchannel = ast_request("zap",AST_FORMAT_SLINEAR,"pseudo",NULL)))
{
fprintf(stderr,"rpt:Sorry unable to obtain pseudo channel\n");
ast_mutex_unlock(&myrpt->lock);
@@ -4760,8 +4744,7 @@ char cmd[MAXDTMF+1] = "";
/* save pseudo channel conference number */
myrpt->conf = ci.confno;
/* allocate a pseudo-channel thru asterisk */
- myrpt->txpchannel = ast_request("zap",AST_FORMAT_SLINEAR,"pseudo",NULL);
- if (!myrpt->txpchannel)
+ if (!(myrpt->txpchannel = ast_request("zap",AST_FORMAT_SLINEAR,"pseudo",NULL)))
{
fprintf(stderr,"rpt:Sorry unable to obtain pseudo channel\n");
ast_mutex_unlock(&myrpt->lock);
@@ -6014,9 +5997,7 @@ static int rpt_exec(struct ast_channel *chan, void *data)
}
l=strlen(options)+2;
- orig_s=ast_malloc(l);
- if(!orig_s) {
- ast_log(LOG_WARNING, "Out of memory\n");
+ if (!(orig_s = ast_malloc(l))) {
return -1;
}
s=orig_s;
@@ -6226,10 +6207,8 @@ static int rpt_exec(struct ast_channel *chan, void *data)
} else
ast_mutex_unlock(&myrpt->lock);
/* establish call in tranceive mode */
- l = ast_calloc(1, sizeof(*l));
- if (!l)
+ if (!(l = ast_calloc(1, sizeof(*l))))
{
- ast_log(LOG_WARNING, "Unable to malloc\n");
pthread_exit(NULL);
}
l->mode = 1;
@@ -6242,8 +6221,7 @@ static int rpt_exec(struct ast_channel *chan, void *data)
ast_set_read_format(l->chan,AST_FORMAT_SLINEAR);
ast_set_write_format(l->chan,AST_FORMAT_SLINEAR);
/* allocate a pseudo-channel thru asterisk */
- l->pchan = ast_request("zap",AST_FORMAT_SLINEAR,"pseudo",NULL);
- if (!l->pchan)
+ if (!(l->pchan = ast_request("zap",AST_FORMAT_SLINEAR,"pseudo",NULL)))
{
fprintf(stderr,"rpt:Sorry unable to obtain pseudo channel\n");
pthread_exit(NULL);