ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
#include <math.h>
#include "asterisk/lock.h"
#include "asterisk/linkedlists.h"
#include "asterisk/indications.h"
#include "asterisk/frame.h"
-#include "asterisk/options.h"
#include "asterisk/channel.h"
-#include "asterisk/logger.h"
#include "asterisk/utils.h"
static int midi_tohz[128] = {
if (chan)
ast_set_write_format(chan, ps->origwfmt);
if (ps->items)
- free(ps->items);
+ ast_free(ps->items);
- free(ps);
+ ast_free(ps);
}
static void * playtones_alloc(struct ast_channel *chan, void *params)
ps->v3_2 = pi->init_v3_2;
ps->oldnpos = ps->npos;
}
- for (x=0;x<len/2;x++) {
+ for (x = 0; x < len/2; x++) {
ps->v1_1 = ps->v2_1;
ps->v2_1 = ps->v3_1;
ps->v3_1 = (pi->fac1 * ps->v2_1 >> 15) - ps->v1_1;
separator = ",";
s = strsep(&stringp,separator);
while (s && *s) {
- int freq1, freq2, time, modulate=0, midinote=0;
+ int freq1, freq2, time, modulate = 0, midinote = 0;
if (s[0]=='!')
s++;
}
if (ast_activate_generator(chan, &playtones, &d)) {
- free(d.items);
+ ast_free(d.items);
return -1;
}
return 0;
if (!country || !(zone = ast_get_indication_zone(country)))
return 1;
- if (option_verbose > 2)
- ast_verbose(VERBOSE_PREFIX_3 "Setting default indication country to '%s'\n", country);
+ ast_verb(3, "Setting default indication country to '%s'\n", country);
/* Protect the current tonezone using the tone_zones lock as well */
AST_RWLIST_WRLOCK(&tone_zones);
if (!strcasecmp(tz->country, country))
break;
}
+ if (!tz)
+ break;
/* If this is an alias then we have to search yet again otherwise we have found the zonezone */
if (tz->alias && tz->alias[0])
country = tz->alias;
{
while (zone->tones) {
struct ind_tone_zone_sound *tmp = zone->tones->next;
- free((void*)zone->tones->name);
- free((void*)zone->tones->data);
- free(zone->tones);
+ ast_free((void *)zone->tones->name);
+ ast_free((void *)zone->tones->data);
+ ast_free(zone->tones);
zone->tones = tmp;
}
if (zone->ringcadence)
- free(zone->ringcadence);
+ ast_free(zone->ringcadence);
- free(zone);
+ ast_free(zone);
}
/*--------------------------------------------*/
if (tz == current_tonezone)
current_tonezone = zone;
/* Remove from the linked list */
- AST_RWLIST_REMOVE_CURRENT(&tone_zones, list);
+ AST_RWLIST_REMOVE_CURRENT(list);
/* Finally free the zone itself */
free_zone(tz);
break;
}
- AST_RWLIST_TRAVERSE_SAFE_END
+ AST_RWLIST_TRAVERSE_SAFE_END;
/* Add zone to the list */
AST_RWLIST_INSERT_TAIL(&tone_zones, zone, list);
/* It's all over. */
AST_RWLIST_UNLOCK(&tone_zones);
- if (option_verbose > 2)
- ast_verbose(VERBOSE_PREFIX_3 "Registered indication country '%s'\n", zone->country);
+ ast_verb(3, "Registered indication country '%s'\n", zone->country);
return 0;
}
current_tonezone = NULL;
}
/* Remove from the list */
- AST_RWLIST_REMOVE_CURRENT(&tone_zones, list);
- if (option_verbose > 2)
- ast_verbose(VERBOSE_PREFIX_3 "Unregistered indication country '%s'\n", tz->country);
+ AST_RWLIST_REMOVE_CURRENT(list);
+ ast_verb(3, "Unregistered indication country '%s'\n", tz->country);
free_zone(tz);
res = 0;
}
- AST_RWLIST_TRAVERSE_SAFE_END
+ AST_RWLIST_TRAVERSE_SAFE_END;
AST_RWLIST_UNLOCK(&tone_zones);
return res;
AST_RWLIST_WRLOCK(&tone_zones);
for (ps=NULL,ts=zone->tones; ts; ps=ts,ts=ts->next) {
- if (strcasecmp(indication,ts->name)==0) {
+ if (!strcasecmp(indication,ts->name)) {
/* indication already there, replace */
- free((void*)ts->name);
- free((void*)ts->data);
+ ast_free((void*)ts->name);
+ ast_free((void*)ts->data);
break;
}
}
AST_RWLIST_WRLOCK(&tone_zones);
ts = zone->tones;
while (ts) {
- if (strcasecmp(indication,ts->name)==0) {
+ if (!strcasecmp(indication,ts->name)) {
/* indication found */
tmp = ts->next;
if (ps)
ps->next = tmp;
else
zone->tones = tmp;
- free((void*)ts->name);
- free((void*)ts->data);
- free(ts);
+ ast_free((void*)ts->name);
+ ast_free((void*)ts->data);
+ ast_free(ts);
ts = tmp;
res = 0;
}