aboutsummaryrefslogtreecommitdiffstats
path: root/indications.c
diff options
context:
space:
mode:
authorrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2006-02-27 01:37:56 +0000
committerrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2006-02-27 01:37:56 +0000
commitbdb1758d158c3f9c92bb3906c2ff7806adebd8ea (patch)
treee9e58673ee6ed381b37010c06f176fcc15e72427 /indications.c
parentfd08bb2afc46851cb3afd0d40b54f1edeb9da3dc (diff)
conversions to allocation wrappers and various other coding guideliens fixes (issue #6582)
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@11231 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'indications.c')
-rw-r--r--indications.c20
1 files changed, 6 insertions, 14 deletions
diff --git a/indications.c b/indications.c
index e9ca85d9c..799c1921c 100644
--- a/indications.c
+++ b/indications.c
@@ -113,10 +113,9 @@ static void playtones_release(struct ast_channel *chan, void *params)
static void * playtones_alloc(struct ast_channel *chan, void *params)
{
struct playtones_def *pd = params;
- struct playtones_state *ps = malloc(sizeof(struct playtones_state));
- if (!ps)
+ struct playtones_state *ps;
+ if (!(ps = ast_calloc(1, sizeof(*ps))))
return NULL;
- memset(ps, 0, sizeof(struct playtones_state));
ps->origwfmt = chan->writeformat;
if (ast_set_write_format(chan, AST_FORMAT_SLINEAR)) {
ast_log(LOG_WARNING, "Unable to set '%s' to signed linear format (write)\n", chan->name);
@@ -300,9 +299,7 @@ int ast_playtones_start(struct ast_channel *chan, int vol, const char *playlst,
freq2 = 0;
}
- d.items = realloc(d.items,(d.nitems+1)*sizeof(struct playtones_item));
- if (d.items == NULL) {
- ast_log(LOG_WARNING, "Realloc failed!\n");
+ if (!(d.items = ast_realloc(d.items, (d.nitems + 1) * sizeof(*d.items)))) {
return -1;
}
d.items[d.nitems].fac1 = 2.0 * cos(2.0 * M_PI * (freq1 / 8000.0)) * 32768.0;
@@ -433,7 +430,7 @@ static inline void free_zone(struct tone_zone* zone)
zone->tones = tmp;
}
if (zone->ringcadence)
- free((void*)zone->ringcadence);
+ free(zone->ringcadence);
free(zone);
}
@@ -547,18 +544,13 @@ int ast_register_indication(struct tone_zone *zone, const char *indication, cons
}
if (!ts) {
/* not there, we have to add */
- ts = malloc(sizeof(struct tone_zone_sound));
- if (!ts) {
- ast_log(LOG_WARNING, "Out of memory\n");
+ if (!(ts = ast_malloc(sizeof(*ts)))) {
ast_mutex_unlock(&tzlock);
return -2;
}
ts->next = NULL;
}
- ts->name = strdup(indication);
- ts->data = strdup(tonelist);
- if (ts->name==NULL || ts->data==NULL) {
- ast_log(LOG_WARNING, "Out of memory\n");
+ if (!(ts->name = ast_strdup(indication)) || !(ts->data = ast_strdup(tonelist))) {
ast_mutex_unlock(&tzlock);
return -2;
}