Index: main/utils.c =================================================================== --- main/utils.c (revision 67164) +++ main/utils.c (working copy) @@ -539,7 +539,7 @@ keep a copy of the pointer and then ast_unregister_thread will free the memory */ - free(data); + ast_free(data); ast_register_thread(a.name); pthread_cleanup_push(ast_unregister_thread, (void *) pthread_self()); ret = a.start_routine(a.data); Index: main/config.c =================================================================== --- main/config.c (revision 67164) +++ main/config.c (working copy) @@ -140,7 +140,8 @@ static struct ast_comment *ALLOC_COMMENT(const char *buffer) { - struct ast_comment *x = ast_calloc(1,sizeof(struct ast_comment)+strlen(buffer)+1); + struct ast_comment *x; + x = ast_calloc(1, sizeof(*x)+strlen(buffer)+1); strcpy(x->cmt, buffer); return x; } @@ -215,7 +216,7 @@ while (v) { vn = v; v = v->next; - free(vn); + ast_free(vn); } } @@ -344,7 +345,7 @@ void ast_category_destroy(struct ast_category *cat) { ast_variables_destroy(cat->root); - free(cat); + ast_free(cat); } static struct ast_category *next_available_category(struct ast_category *cat) @@ -522,7 +523,7 @@ if (cat == cfg->last) cfg->last = NULL; } - free(cat); + ast_free(cat); return 0; } prev = cat; @@ -543,7 +544,7 @@ if (cat == cfg->last) cfg->last = NULL; } - free(cat); + ast_free(cat); return 0; } prev = cat; @@ -564,9 +565,9 @@ ast_variables_destroy(cat->root); catn = cat; cat = cat->next; - free(catn); + ast_free(catn); } - free(cfg); + ast_free(cfg); } struct ast_category *ast_config_get_current_category(const struct ast_config *cfg) @@ -934,8 +935,8 @@ #endif if (cfg && cfg->include_level == 1 && withcomments && comment_buffer) { - free(comment_buffer); - free(lline_buffer); + ast_free(comment_buffer); + ast_free(lline_buffer); comment_buffer = NULL; lline_buffer = NULL; comment_buffer_size = 0; @@ -1046,7 +1047,7 @@ while (config_maps) { map = config_maps; config_maps = config_maps->next; - free(map); + ast_free(map); } ast_mutex_unlock(&config_lock); @@ -1345,7 +1346,7 @@ /* Eliminate blank entries */ for (cur = res; cur; cur = cur->next) { if (freeme) { - free(freeme); + ast_free(freeme); freeme = NULL; } Index: main/loader.c =================================================================== --- main/loader.c (revision 67164) +++ main/loader.c (working copy) @@ -170,7 +170,7 @@ if (mod) { AST_LIST_HEAD_DESTROY(&mod->users); - free(mod); + ast_free(mod); } } @@ -201,7 +201,7 @@ AST_LIST_REMOVE(&mod->users, u, entry); AST_LIST_UNLOCK(&mod->users); ast_atomic_fetchadd_int(&mod->usecount, -1); - free(u); + ast_free(u); ast_update_use_count(); } @@ -214,7 +214,7 @@ while ((u = AST_LIST_REMOVE_HEAD(&mod->users, entry))) { ast_softhangup(u->chan, AST_SOFTHANGUP_APPUNLOAD); ast_atomic_fetchadd_int(&mod->usecount, -1); - free(u); + ast_free(u); } AST_LIST_UNLOCK(&mod->users); @@ -359,7 +359,7 @@ if (!(lib = dlopen(fn, RTLD_LAZY | RTLD_LOCAL))) { ast_log(LOG_WARNING, "Error loading module '%s': %s\n", resource_in, dlerror()); - free(resource_being_loaded); + ast_free(resource_being_loaded); return NULL; } @@ -396,7 +396,7 @@ if (!dlopen(fn, RTLD_NOLOAD | (wants_global ? RTLD_LAZY | RTLD_GLOBAL : RTLD_NOW | RTLD_LOCAL))) { ast_log(LOG_WARNING, "Unable to promote flags on module '%s': %s\n", resource_in, dlerror()); while (!dlclose(lib)); - free(resource_being_loaded); + ast_free(resource_being_loaded); return NULL; } #else @@ -412,7 +412,7 @@ if (!(lib = dlopen(fn, wants_global ? RTLD_LAZY | RTLD_GLOBAL : RTLD_NOW | RTLD_LOCAL))) { ast_log(LOG_WARNING, "Error loading module '%s': %s\n", resource_in, dlerror()); - free(resource_being_loaded); + ast_free(resource_being_loaded); return NULL; } @@ -791,8 +791,8 @@ AST_LIST_TRAVERSE_SAFE_BEGIN(&load_order, order, entry) { if (!resource_name_match(order->resource, v->value)) { AST_LIST_REMOVE_CURRENT(&load_order, entry); - free(order->resource); - free(order); + ast_free(order->resource); + ast_free(order); } } AST_LIST_TRAVERSE_SAFE_END; @@ -815,8 +815,8 @@ case AST_MODULE_LOAD_SUCCESS: case AST_MODULE_LOAD_DECLINE: AST_LIST_REMOVE_CURRENT(&load_order, entry); - free(order->resource); - free(order); + ast_free(order->resource); + ast_free(order); break; case AST_MODULE_LOAD_FAILURE: res = -1; @@ -834,8 +834,8 @@ case AST_MODULE_LOAD_SUCCESS: case AST_MODULE_LOAD_DECLINE: AST_LIST_REMOVE_CURRENT(&load_order, entry); - free(order->resource); - free(order); + ast_free(order->resource); + ast_free(order); break; case AST_MODULE_LOAD_FAILURE: res = -1; @@ -849,8 +849,8 @@ done: while ((order = AST_LIST_REMOVE_HEAD(&load_order, entry))) { - free(order->resource); - free(order); + ast_free(order->resource); + ast_free(order); } AST_LIST_UNLOCK(&module_list); Index: main/channel.c =================================================================== --- main/channel.c (revision 67164) +++ main/channel.c (working copy) @@ -458,7 +458,7 @@ AST_LIST_TRAVERSE_SAFE_BEGIN(&backends, chan, list) { if (chan->tech == tech) { AST_LIST_REMOVE_CURRENT(&backends, list); - free(chan); + ast_free(chan); if (option_verbose > 1) ast_verbose(VERBOSE_PREFIX_2 "Unregistered channel type '%s'\n", tech->type); break; @@ -648,13 +648,13 @@ if (!(tmp->sched = sched_context_create())) { ast_log(LOG_WARNING, "Channel allocation failed: Unable to create schedule context\n"); - free(tmp); + ast_free(tmp); return NULL; } if ((ast_string_field_init(tmp, 128))) { sched_context_destroy(tmp->sched); - free(tmp); + ast_free(tmp); return NULL; } @@ -681,7 +681,7 @@ if (pipe(tmp->alertpipe)) { ast_log(LOG_WARNING, "Channel allocation failed: Can't create alert pipe!\n"); ast_string_field_free_pools(tmp); - free(tmp); + ast_free(tmp); return NULL; } else { flags = fcntl(tmp->alertpipe[0], F_GETFL); @@ -1057,15 +1057,15 @@ static void free_cid(struct ast_callerid *cid) { if (cid->cid_dnid) - free(cid->cid_dnid); + ast_free(cid->cid_dnid); if (cid->cid_num) - free(cid->cid_num); + ast_free(cid->cid_num); if (cid->cid_name) - free(cid->cid_name); + ast_free(cid->cid_name); if (cid->cid_ani) - free(cid->cid_ani); + ast_free(cid->cid_ani); if (cid->cid_rdnis) - free(cid->cid_rdnis); + ast_free(cid->cid_rdnis); cid->cid_dnid = cid->cid_num = cid->cid_name = cid->cid_ani = cid->cid_rdnis = NULL; } @@ -1089,7 +1089,7 @@ ast_channel_unlock(chan); if (chan->tech_pvt) { ast_log(LOG_WARNING, "Channel '%s' may not have been hung up properly\n", chan->name); - free(chan->tech_pvt); + ast_free(chan->tech_pvt); } if (chan->sched) @@ -1146,7 +1146,7 @@ ast_jb_destroy(chan); ast_string_field_free_pools(chan); - free(chan); + ast_free(chan); AST_LIST_UNLOCK(&channels); ast_device_state_changed_literal(name); @@ -1157,13 +1157,13 @@ struct ast_datastore *datastore = NULL; /* Make sure we at least have type so we can identify this */ - if (info == NULL) { + if (!info) { return NULL; } /* Allocate memory for datastore and clear it */ datastore = ast_calloc(1, sizeof(*datastore)); - if (datastore == NULL) { + if (!datastore) { return NULL; } @@ -1191,7 +1191,7 @@ } /* Finally free memory used by ourselves */ - free(datastore); + ast_free(datastore); return res; } @@ -1329,7 +1329,7 @@ ast_translator_free_path(chan->spies->read_translator.path); if (chan->spies->write_translator.path) ast_translator_free_path(chan->spies->write_translator.path); - free(chan->spies); + ast_free(chan->spies); chan->spies = NULL; return; } @@ -2519,7 +2519,7 @@ if (buf == NULL) return -1; /* error or timeout */ c = *(unsigned char *)buf; - free(buf); + ast_free(buf); return c; } @@ -3699,17 +3699,17 @@ { if (callerid) { if (chan->cid.cid_num) - free(chan->cid.cid_num); + ast_free(chan->cid.cid_num); chan->cid.cid_num = ast_strdup(callerid); } if (calleridname) { if (chan->cid.cid_name) - free(chan->cid.cid_name); + ast_free(chan->cid.cid_name); chan->cid.cid_name = ast_strdup(calleridname); } if (ani) { if (chan->cid.cid_ani) - free(chan->cid.cid_ani); + ast_free(chan->cid.cid_ani); chan->cid.cid_ani = ast_strdup(ani); } if (chan->cdr) @@ -4259,7 +4259,7 @@ if (chan) ast_set_write_format(chan, ts->origwfmt); - free(ts); + ast_free(ts); } static void *tonepair_alloc(struct ast_channel *chan, void *params) @@ -4667,7 +4667,7 @@ if (ast_set_write_format(chan, AST_FORMAT_SLINEAR) < 0) { ast_log(LOG_ERROR, "Could not set write format to SLINEAR\n"); - free(state); + ast_free(state); return NULL; } @@ -4692,7 +4692,7 @@ if (ast_set_write_format(chan, state->old_write_format) < 0) ast_log(LOG_ERROR, "Could not return write format to its original state\n"); - free(state); + ast_free(state); } @@ -4922,6 +4922,6 @@ ast_set_write_format(chan, chan->whisper->original_format); ast_slinfactory_destroy(&chan->whisper->sf); ast_mutex_destroy(&chan->whisper->lock); - free(chan->whisper); + ast_free(chan->whisper); chan->whisper = NULL; } Index: main/cdr.c =================================================================== --- main/cdr.c (revision 67164) +++ main/cdr.c (working copy) @@ -157,7 +157,7 @@ AST_LIST_REMOVE_CURRENT(&be_list, list); if (option_verbose > 1) ast_verbose(VERBOSE_PREFIX_2 "Unregistered '%s' CDR backend\n", name); - free(i); + ast_free(i); break; } } @@ -440,7 +440,7 @@ ast_log(LOG_NOTICE, "CDR on channel '%s' lacks start\n", chan); ast_cdr_free_vars(cdr, 0); - free(cdr); + ast_free(cdr); cdr = next; } } @@ -452,14 +452,15 @@ struct ast_cdr *next = cdr->next; ast_cdr_free_vars(cdr, 0); - free(cdr); + ast_free(cdr); cdr = next; } } struct ast_cdr *ast_cdr_alloc(void) { - struct ast_cdr *x = ast_calloc(1, sizeof(struct ast_cdr)); + struct ast_cdr *x; + x = ast_calloc(1, sizeof(*x)); if (!x) ast_log(LOG_ERROR,"Allocation Failure for a CDR!\n"); return x; @@ -1024,7 +1025,7 @@ ast_cdr_free(batchitem->cdr); processeditem = batchitem; batchitem = batchitem->next; - free(processeditem); + ast_free(processeditem); } return NULL; Index: main/manager.c =================================================================== --- main/manager.c (revision 67164) +++ main/manager.c (working copy) @@ -295,7 +295,7 @@ while ( (ev = AST_LIST_FIRST(&all_events)) && ev->usecount == 0 && AST_LIST_NEXT(ev, eq_next)) { AST_LIST_REMOVE_HEAD(&all_events, eq_next); - free(ev); + ast_free(ev); } AST_LIST_UNLOCK(&all_events); } @@ -696,7 +696,7 @@ if (s->f != NULL) fclose(s->f); ast_mutex_destroy(&s->__lock); - free(s); + ast_free(s); unref_event(eqe); } @@ -1889,7 +1889,7 @@ /* Locked by ast_pbx_outgoing_exten or ast_pbx_outgoing_app */ if (chan) ast_channel_unlock(chan); - free(in); + ast_free(in); return NULL; } @@ -2501,7 +2501,7 @@ destroy_session(s); done: - free(ser); + ast_free(ser); return NULL; } @@ -2641,7 +2641,7 @@ prev->next = cur->next; else first_action = cur->next; - free(cur); + ast_free(cur); if (option_verbose > 1) ast_verbose(VERBOSE_PREFIX_2 "Manager unregistered action %s\n", action); break; @@ -3273,10 +3273,10 @@ ami_tls_cfg.enabled = 0; if (ami_tls_cfg.certfile) - free(ami_tls_cfg.certfile); + ast_free(ami_tls_cfg.certfile); ami_tls_cfg.certfile = ast_strdup(AST_CERTFILE); if (ami_tls_cfg.cipher) - free(ami_tls_cfg.cipher); + ast_free(ami_tls_cfg.cipher); ami_tls_cfg.cipher = ast_strdup(""); for (var = ast_variable_browse(cfg, "general"); var; var = var->next) { @@ -3293,10 +3293,10 @@ ast_log(LOG_WARNING, "Invalid bind address '%s'\n", val); } } else if (!strcasecmp(var->name, "sslcert")) { - free(ami_tls_cfg.certfile); + ast_free(ami_tls_cfg.certfile); ami_tls_cfg.certfile = ast_strdup(val); } else if (!strcasecmp(var->name, "sslcipher")) { - free(ami_tls_cfg.cipher); + ast_free(ami_tls_cfg.cipher); ami_tls_cfg.cipher = ast_strdup(val); } else if (!strcasecmp(var->name, "enabled")) { manager_enabled = ast_true(val); @@ -3359,23 +3359,23 @@ while (var) { if (!strcasecmp(var->name, "secret")) { if (user->secret) - free(user->secret); + ast_free(user->secret); user->secret = ast_strdup(var->value); } else if (!strcasecmp(var->name, "deny") ) { if (user->deny) - free(user->deny); + ast_free(user->deny); user->deny = ast_strdup(var->value); } else if (!strcasecmp(var->name, "permit") ) { if (user->permit) - free(user->permit); + ast_free(user->permit); user->permit = ast_strdup(var->value); } else if (!strcasecmp(var->name, "read") ) { if (user->read) - free(user->read); + ast_free(user->read); user->read = ast_strdup(var->value); } else if (!strcasecmp(var->name, "write") ) { if (user->write) - free(user->write); + ast_free(user->write); user->write = ast_strdup(var->value); } else if (!strcasecmp(var->name, "displayconnects") ) user->displayconnects = ast_true(var->value); @@ -3397,16 +3397,16 @@ AST_LIST_REMOVE_CURRENT(&users, list); /* Free their memory now */ if (user->secret) - free(user->secret); + ast_free(user->secret); if (user->deny) - free(user->deny); + ast_free(user->deny); if (user->permit) - free(user->permit); + ast_free(user->permit); if (user->read) - free(user->read); + ast_free(user->read); if (user->write) - free(user->write); - free(user); + ast_free(user->write); + ast_free(user); } AST_LIST_TRAVERSE_SAFE_END Index: main/tdd.c =================================================================== --- main/tdd.c (revision 67164) +++ main/tdd.c (working copy) @@ -101,9 +101,8 @@ struct tdd_state *tdd_new(void) { struct tdd_state *tdd; - tdd = malloc(sizeof(struct tdd_state)); + tdd = calloc(1, sizeof(*tdd)); if (tdd) { - memset(tdd, 0, sizeof(struct tdd_state)); tdd->fskd.spb = 176; /* 45.5 baud */ tdd->fskd.hdlc = 0; /* Async */ tdd->fskd.nbit = 5; /* 5 bits */ @@ -143,13 +142,12 @@ int b = 'X'; int res; int c,x; - short *buf = malloc(2 * len + tdd->oldlen); + short *buf = calloc(1, 2 * len + tdd->oldlen); short *obuf = buf; if (!buf) { ast_log(LOG_WARNING, "Out of memory\n"); return -1; } - memset(buf, 0, 2 * len + tdd->oldlen); memcpy(buf, tdd->oldstuff, tdd->oldlen); mylen += tdd->oldlen/2; for (x = 0; x < len; x++) Index: main/http.c =================================================================== --- main/http.c (revision 67164) +++ main/http.c (working copy) @@ -206,7 +206,7 @@ *contentlength = read(fd, result->str + result->used, st.st_size); if (*contentlength < 0) { close(fd); - free(result); + ast_free(result); goto out403; } result->used += *contentlength; @@ -747,7 +747,7 @@ if (!ser->f) { close(ser->fd); ast_log(LOG_WARNING, "FILE * open failed!\n"); - free(ser); + ast_free(ser); return NULL; } return ser->parent->worker_fn(ser); @@ -888,14 +888,14 @@ fwrite(tmp + 4, 1, contentlength, ser->f); } } - free(out); + ast_free(out); } if (title) - free(title); + ast_free(title); done: fclose(ser->f); - free(ser); + ast_free(ser); return NULL; } @@ -938,7 +938,7 @@ if (ast_pthread_create_detached_background(&launched, NULL, make_file_from_fd, ser)) { ast_log(LOG_WARNING, "Unable to launch helper thread: %s\n", strerror(errno)); close(ser->fd); - free(ser); + ast_free(ser); } } @@ -1107,10 +1107,10 @@ static void destroy_post_mapping(struct ast_http_post_mapping *post_map) { if (post_map->from) - free(post_map->from); + ast_free(post_map->from); if (post_map->to) - free(post_map->to); - free(post_map); + ast_free(post_map->to); + ast_free(post_map); } static void destroy_post_mappings(void) @@ -1168,15 +1168,15 @@ http_tls_cfg.enabled = 0; if (http_tls_cfg.certfile) - free(http_tls_cfg.certfile); + ast_free(http_tls_cfg.certfile); http_tls_cfg.certfile = ast_strdup(AST_CERTFILE); if (http_tls_cfg.cipher) - free(http_tls_cfg.cipher); + ast_free(http_tls_cfg.cipher); http_tls_cfg.cipher = ast_strdup(""); AST_RWLIST_WRLOCK(&uri_redirects); while ((redirect = AST_RWLIST_REMOVE_HEAD(&uri_redirects, entry))) - free(redirect); + ast_free(redirect); AST_RWLIST_UNLOCK(&uri_redirects); destroy_post_mappings(); @@ -1192,10 +1192,10 @@ else if (!strcasecmp(v->name, "sslbindport")) https_desc.sin.sin_port = htons(atoi(v->value)); else if (!strcasecmp(v->name, "sslcert")) { - free(http_tls_cfg.certfile); + ast_free(http_tls_cfg.certfile); http_tls_cfg.certfile = ast_strdup(v->value); } else if (!strcasecmp(v->name, "sslcipher")) { - free(http_tls_cfg.cipher); + ast_free(http_tls_cfg.cipher); http_tls_cfg.cipher = ast_strdup(v->value); } else if (!strcasecmp(v->name, "enablestatic")) Index: main/app.c =================================================================== --- main/app.c (revision 67164) +++ main/app.c (working copy) @@ -304,7 +304,7 @@ } if (ls->autoclose) close(ls->fd); - free(params); + ast_free(params); } static int linear_generator(struct ast_channel *chan, void *data, int len, int samples) @@ -347,7 +347,7 @@ ls->origwfmt = chan->writeformat; if (ast_set_write_format(chan, AST_FORMAT_SLINEAR)) { ast_log(LOG_WARNING, "Unable to set '%s' to linear format (write)\n", chan->name); - free(ls); + ast_free(ls); ls = params = NULL; } } @@ -842,7 +842,7 @@ break; } - if (!gi && (gi = calloc(1, len))) { + if (!gi && (gi = ast_calloc(1, len))) { gi->chan = chan; gi->group = (char *) gi + sizeof(*gi); strcpy(gi->group, group); @@ -925,7 +925,7 @@ AST_LIST_TRAVERSE_SAFE_BEGIN(&groups, gi, list) { if (gi->chan == chan) { AST_LIST_REMOVE_CURRENT(&groups, list); - free(gi); + ast_free(gi); } } AST_LIST_TRAVERSE_SAFE_END @@ -1376,7 +1376,7 @@ output[res] = '\0'; } else { ast_log(LOG_WARNING, "Short read of %s (%d of %d): %s\n", filename, res, count - 1, strerror(errno)); - free(output); + ast_free(output); output = NULL; } } Index: main/db.c =================================================================== --- main/db.c (revision 67164) +++ main/db.c (working copy) @@ -466,7 +466,7 @@ while (dbe) { last = dbe; dbe = dbe->next; - free(last); + ast_free(last); } } Index: main/translate.c =================================================================== --- main/translate.c (revision 67164) +++ main/translate.c (working copy) @@ -129,7 +129,7 @@ pvt->outbuf = ofs + AST_FRIENDLY_OFFSET; /* call local init routine, if present */ if (t->newpvt && t->newpvt(pvt)) { - free(pvt); + ast_free(pvt); return NULL; } ast_module_ref(t->module); @@ -142,7 +142,7 @@ if (t->destroy) t->destroy(pvt); - free(pvt); + ast_free(pvt); ast_module_unref(t->module); } Index: main/jitterbuf.c =================================================================== --- main/jitterbuf.c (revision 67164) +++ main/jitterbuf.c (working copy) @@ -106,12 +106,12 @@ frame = jb->free; while (frame != NULL) { jb_frame *next = frame->next; - free(frame); + ast_free(frame); frame = next; } /* free ourselves! */ - free(jb); + ast_free(jb); } Index: main/acl.c =================================================================== --- main/acl.c (revision 67164) +++ main/acl.c (working copy) @@ -90,7 +90,7 @@ while (ha) { hal = ha; ha = ha->next; - free(hal); + ast_free(hal); } } @@ -174,14 +174,14 @@ ast_log(LOG_WARNING, "%s is not a valid netmask\n", nm); if (error) *error = 1; - free(ha); + ast_free(ha); return ret; } if (!inet_aton(tmp, &ha->netaddr)) { ast_log(LOG_WARNING, "%s is not a valid IP\n", tmp); if (error) *error = 1; - free(ha); + ast_free(ha); return ret; } ha->netaddr.s_addr &= ha->netmask.s_addr; Index: main/rtp.c =================================================================== --- main/rtp.c (revision 67164) +++ main/rtp.c (working copy) @@ -1936,7 +1936,7 @@ rtcp->them.sin_family = AF_INET; if (rtcp->s < 0) { - free(rtcp); + ast_free(rtcp); ast_log(LOG_WARNING, "Unable to allocate RTCP socket: %s\n", strerror(errno)); return NULL; } @@ -1977,7 +1977,7 @@ rtp->s = rtp_socket(); if (rtp->s < 0) { - free(rtp); + ast_free(rtp); ast_log(LOG_ERROR, "Unable to allocate socket: %s\n", strerror(errno)); return NULL; } @@ -2017,9 +2017,9 @@ close(rtp->s); if (rtp->rtcp) { close(rtp->rtcp->s); - free(rtp->rtcp); + ast_free(rtp->rtcp); } - free(rtp); + ast_free(rtp); return NULL; } /* The port was used, increment it (by two). */ @@ -2035,9 +2035,9 @@ close(rtp->s); if (rtp->rtcp) { close(rtp->rtcp->s); - free(rtp->rtcp); + ast_free(rtp->rtcp); } - free(rtp); + ast_free(rtp); return NULL; } } @@ -2204,13 +2204,13 @@ if (rtp->rtcp->schedid > 0) ast_sched_del(rtp->sched, rtp->rtcp->schedid); close(rtp->rtcp->s); - free(rtp->rtcp); + ast_free(rtp->rtcp); rtp->rtcp=NULL; } #ifdef P2P_INTENSE ast_mutex_destroy(&rtp->bridge_lock); #endif - free(rtp); + ast_free(rtp); } static unsigned int calc_txstamp(struct ast_rtp *rtp, struct timeval *delivery) Index: main/chanvars.c =================================================================== --- main/chanvars.c (revision 67164) +++ main/chanvars.c (working copy) @@ -56,7 +56,7 @@ void ast_var_delete(struct ast_var_t *var) { if (var) - free(var); + ast_free(var); } const char *ast_var_name(const struct ast_var_t *var) Index: main/fixedjitterbuf.c =================================================================== --- main/fixedjitterbuf.c (revision 67164) +++ main/fixedjitterbuf.c (working copy) @@ -66,12 +66,12 @@ static inline struct fixed_jb_frame *alloc_jb_frame(struct fixed_jb *jb) { - return ast_calloc(1, sizeof(struct fixed_jb_frame)); + return ast_calloc(1, sizeof(*jb)); } static inline void release_jb_frame(struct fixed_jb *jb, struct fixed_jb_frame *frame) { - free(frame); + ast_free(frame); } static void get_jb_head(struct fixed_jb *jb, struct fixed_jb_frame *frame) @@ -131,7 +131,7 @@ /* jitterbuf MUST be empty before it can be destroyed */ ASSERT(jb->frames == NULL); - free(jb); + ast_free(jb); } Index: main/event.c =================================================================== --- main/event.c (revision 67164) +++ main/event.c (working copy) @@ -109,9 +109,9 @@ static void ast_event_ie_val_destroy(struct ast_event_ie_val *ie_val) { if (ie_val->ie_pltype == AST_EVENT_IE_PLTYPE_STR) - free((void *) ie_val->payload.str); + ast_free((void *) ie_val->payload.str); - free(ie_val); + ast_free(ie_val); } enum ast_event_subscriber_res ast_event_check_subscriber(enum ast_event_type type, ...) @@ -270,7 +270,7 @@ ie_val->payload.uint = va_arg(ap, uint32_t); else if (ie_val->ie_pltype == AST_EVENT_IE_PLTYPE_STR) { if (!(ie_val->payload.str = ast_strdup(va_arg(ap, const char *)))) { - free(ie_val); + ast_free(ie_val); continue; } } @@ -327,7 +327,7 @@ while ((ie_val = AST_LIST_REMOVE_HEAD(&sub->ie_vals, entry))) ast_event_ie_val_destroy(ie_val); - free(sub); + ast_free(sub); } void ast_event_unsubscribe(struct ast_event_sub *sub) @@ -481,13 +481,13 @@ void ast_event_destroy(struct ast_event *event) { - free(event); + ast_free(event); } static void ast_event_ref_destroy(struct ast_event_ref *event_ref) { ast_event_destroy(event_ref->event); - free(event_ref); + ast_free(event_ref); } static struct ast_event *ast_event_dup(const struct ast_event *event) Index: main/asterisk.c =================================================================== --- main/asterisk.c (revision 67164) +++ main/asterisk.c (working copy) @@ -293,7 +293,7 @@ AST_LIST_TRAVERSE_SAFE_END; AST_LIST_UNLOCK(&file_versions); if (find) - free(find); + ast_free(find); } struct thread_list_t { @@ -335,8 +335,8 @@ AST_LIST_TRAVERSE_SAFE_END; AST_LIST_UNLOCK(&thread_list); if (x) { - free(x->name); - free(x); + ast_free(x->name); + ast_free(x); } } @@ -2032,7 +2032,7 @@ /* Don't print dupes */ if ( (matches[idx+1] != NULL && strcmp(matches[idx], matches[idx+1]) == 0 ) ) { i--; - free(matches[idx]); + ast_free(matches[idx]); matches[idx] = NULL; continue; } @@ -2040,7 +2040,7 @@ numoutput++; numoutputline++; fprintf(stdout, "%-*s ", max, matches[idx]); - free(matches[idx]); + ast_free(matches[idx]); matches[idx] = NULL; } if (numoutputline > 0) @@ -2109,7 +2109,7 @@ mbuf[mlen] = '\0'; matches = ast_el_strtoarr(mbuf); - free(mbuf); + ast_free(mbuf); } else matches = (char **) NULL; } else { @@ -2155,8 +2155,8 @@ } } for (i = 0; matches[i]; i++) - free(matches[i]); - free(matches); + ast_free(matches[i]); + ast_free(matches); } return (char *)(long)retval; Index: main/dsp.c =================================================================== --- main/dsp.c (revision 67164) +++ main/dsp.c (working copy) @@ -1625,7 +1625,7 @@ void ast_dsp_free(struct ast_dsp *dsp) { - free(dsp); + ast_free(dsp); } void ast_dsp_set_threshold(struct ast_dsp *dsp, int threshold) Index: main/udptl.c =================================================================== --- main/udptl.c (revision 67164) +++ main/udptl.c (working copy) @@ -824,7 +824,7 @@ udptl->us.sin_family = AF_INET; if ((udptl->fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { - free(udptl); + ast_free(udptl); ast_log(LOG_WARNING, "Unable to allocate socket: %s\n", strerror(errno)); return NULL; } @@ -845,7 +845,7 @@ if (errno != EADDRINUSE) { ast_log(LOG_WARNING, "Unexpected bind error: %s\n", strerror(errno)); close(udptl->fd); - free(udptl); + ast_free(udptl); return NULL; } if (++x > udptlend) @@ -853,7 +853,7 @@ if (x == startplace) { ast_log(LOG_WARNING, "No UDPTL ports remaining\n"); close(udptl->fd); - free(udptl); + ast_free(udptl); return NULL; } } @@ -908,7 +908,7 @@ ast_io_remove(udptl->io, udptl->ioid); if (udptl->fd > -1) close(udptl->fd); - free(udptl); + ast_free(udptl); } int ast_udptl_write(struct ast_udptl *s, struct ast_frame *f) Index: main/autoservice.c =================================================================== --- main/autoservice.c (revision 67164) +++ main/autoservice.c (working copy) @@ -117,7 +117,7 @@ /* There will only be a single member in the list at this point, the one we just added. */ AST_RWLIST_REMOVE(&aslist, as, list); - free(as); + ast_free(as); res = -1; } else pthread_kill(asthread, SIGURG); @@ -136,7 +136,7 @@ AST_RWLIST_TRAVERSE_SAFE_BEGIN(&aslist, as, list) { if (as->chan == chan) { AST_RWLIST_REMOVE_CURRENT(&aslist, list); - free(as); + ast_free(as); if (!chan->_softhangup) res = 0; break; Index: main/frame.c =================================================================== --- main/frame.c (revision 67164) +++ main/frame.c (working copy) @@ -285,7 +285,7 @@ void ast_smoother_free(struct ast_smoother *s) { - free(s); + ast_free(s); } static struct ast_frame *ast_frame_header_new(void) @@ -330,9 +330,9 @@ struct ast_frame *f; while ((f = AST_LIST_REMOVE_HEAD(&frames->list, frame_list))) - free(f); + ast_free(f); - free(frames); + ast_free(frames); } #endif @@ -358,11 +358,11 @@ if (fr->mallocd & AST_MALLOCD_DATA) { if (fr->data) - free(fr->data - fr->offset); + ast_free(fr->data - fr->offset); } if (fr->mallocd & AST_MALLOCD_SRC) { if (fr->src) - free((char *)fr->src); + ast_free((char *)fr->src); } if (fr->mallocd & AST_MALLOCD_HDR) { #ifdef TRACE_FRAMES @@ -371,7 +371,7 @@ AST_LIST_REMOVE(&headerlist, fr, frame_list); AST_LIST_UNLOCK(&headerlist); #endif - free(fr); + ast_free(fr); } } @@ -409,7 +409,7 @@ if (fr->src) { if (!(out->src = ast_strdup(fr->src))) { if (out != fr) - free(out); + ast_free(out); return NULL; } } @@ -419,9 +419,9 @@ if (!(fr->mallocd & AST_MALLOCD_DATA)) { if (!(newdata = ast_malloc(fr->datalen + AST_FRIENDLY_OFFSET))) { if (out->src != fr->src) - free((void *) out->src); + ast_free((void *) out->src); if (out != fr) - free(out); + ast_free(out); return NULL; } newdata += AST_FRIENDLY_OFFSET; Index: main/threadstorage.c =================================================================== --- main/threadstorage.c (revision 67164) +++ main/threadstorage.c (working copy) @@ -85,7 +85,7 @@ AST_LIST_TRAVERSE_SAFE_END; AST_RWLIST_UNLOCK(&tls_objects); if (to) - free(to); + ast_free(to); } void __ast_threadstorage_object_replace(void *key_old, void *key_new, size_t len) Index: main/say.c =================================================================== --- main/say.c (revision 67164) +++ main/say.c (working copy) @@ -1962,7 +1962,7 @@ static odmiana *odmiana_zenska = NULL; if (odmiana_nieosobowa == NULL) { - odmiana_nieosobowa = (odmiana *) malloc(sizeof(odmiana)); + odmiana_nieosobowa = ast_malloc(sizeof(*odmiana_nieosobowa)); odmiana_nieosobowa->separator_dziesiatek = " "; @@ -1975,7 +1975,7 @@ } if (odmiana_zenska == NULL) { - odmiana_zenska = (odmiana *) malloc(sizeof(odmiana)); + odmiana_zenska = ast_malloc(sizeof(*odmiana_zenska)); odmiana_zenska->separator_dziesiatek = " "; @@ -1988,7 +1988,7 @@ } if (odmiana_meska == NULL) { - odmiana_meska = (odmiana *) malloc(sizeof(odmiana)); + odmiana_meska = ast_malloc(sizeof(*odmiana_meska)); odmiana_meska->separator_dziesiatek = " "; @@ -6908,7 +6908,7 @@ while (res == 0 && (s = strstr(remainder, " "))) { size_t len = s - remainder; - char* new_string = malloc(len + 1 + strlen("digits/")); + char* new_string = ast_malloc(len + 1 + strlen("digits/")); sprintf(new_string, "digits/"); strncat(new_string, remainder, len); /* we can't sprintf() it, it's not null-terminated. */ @@ -6922,7 +6922,7 @@ } ast_stopstream(chan); - free(new_string); + ast_free(new_string); remainder = s + 1; /* position just after the found space char. */ while(*remainder == ' ') /* skip multiple spaces */ @@ -6933,7 +6933,7 @@ /* the last chunk. */ if (res == 0 && *remainder) { - char* new_string = malloc(strlen(remainder) + 1 + strlen("digits/")); + char* new_string = ast_malloc(strlen(remainder) + 1 + strlen("digits/")); sprintf(new_string, "digits/%s", remainder); if (!ast_streamfile(chan, new_string, language)) { @@ -6944,7 +6944,7 @@ } ast_stopstream(chan); - free(new_string); + ast_free(new_string); } Index: main/devicestate.c =================================================================== --- main/devicestate.c (revision 67164) +++ main/devicestate.c (working copy) @@ -339,7 +339,7 @@ AST_RWLIST_TRAVERSE_SAFE_BEGIN(&devstate_provs, devcb, list) { if (!strcasecmp(devcb->label, label)) { AST_RWLIST_REMOVE_CURRENT(&devstate_provs, list); - free(devcb); + ast_free(devcb); res = 0; break; } @@ -464,7 +464,7 @@ while ((current = next)) { next = AST_LIST_NEXT(current, list); do_state_change(current->device); - free(current); + ast_free(current); } } Index: main/enum.c =================================================================== --- main/enum.c (revision 67164) +++ main/enum.c (working copy) @@ -443,7 +443,7 @@ } if (chan && ast_autoservice_start(chan) < 0) { - free(context); + ast_free(context); return -1; } @@ -523,11 +523,11 @@ if (!argcontext) { for (k = 0; k < context->naptr_rrs_count; k++) { - free(context->naptr_rrs[k].result); - free(context->naptr_rrs[k].tech); + ast_free(context->naptr_rrs[k].result); + ast_free(context->naptr_rrs[k].tech); } - free(context->naptr_rrs); - free(context); + ast_free(context->naptr_rrs); + ast_free(context); } else *argcontext = context; @@ -622,7 +622,7 @@ while (s) { sl = s; s = s->next; - free(sl); + ast_free(sl); } toplevs = NULL; cfg = ast_config_load("enum.conf"); Index: main/indications.c =================================================================== --- main/indications.c (revision 67164) +++ main/indications.c (working copy) @@ -108,9 +108,9 @@ 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) @@ -324,7 +324,7 @@ } if (ast_activate_generator(chan, &playtones, &d)) { - free(d.items); + ast_free(d.items); return -1; } return 0; @@ -453,16 +453,16 @@ { 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); } /*--------------------------------------------*/ @@ -543,8 +543,8 @@ for (ps=NULL,ts=zone->tones; ts; ps=ts,ts=ts->next) { if (strcasecmp(indication,ts->name)==0) { /* indication already there, replace */ - free((void*)ts->name); - free((void*)ts->data); + ast_free((void*)ts->name); + ast_free((void*)ts->data); break; } } @@ -588,9 +588,9 @@ 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; } Index: main/cli.c =================================================================== --- main/cli.c (revision 67164) +++ main/cli.c (working copy) @@ -624,19 +624,19 @@ obuf = buf; if (!(buf = ast_realloc(obuf, buflen))) /* Memory allocation failure... Just free old buffer and be done */ - free(obuf); + ast_free(obuf); } if (buf) len += sprintf( buf + len, "%s ", matches[x]); - free(matches[x]); + ast_free(matches[x]); matches[x] = NULL; } - free(matches); + ast_free(matches); } if (buf) { ast_cli(fd, "%s%s",buf, AST_CLI_COMPLETE_EOF); - free(buf); + ast_free(buf); } else ast_cli(fd, "NULL\n"); @@ -668,7 +668,7 @@ buf = __ast_cli_generator(argv[2], argv[3], atoi(argv[4]), 0); if (buf) { ast_cli(fd, buf); - free(buf); + ast_free(buf); } else ast_cli(fd, "NULL\n"); return RESULT_SUCCESS; @@ -1245,12 +1245,12 @@ AST_LIST_LOCK(&helpers); AST_LIST_REMOVE(&helpers, e, list); AST_LIST_UNLOCK(&helpers); - free(e->_full_cmd); + ast_free(e->_full_cmd); e->_full_cmd = NULL; if (e->new_handler) { /* this is a new-style entry. Reset fields and free memory. */ bzero((char **)(e->cmda), sizeof(e->cmda)); - free(e->command); + ast_free(e->command); e->command = NULL; e->usage = NULL; } @@ -1289,7 +1289,7 @@ if (find_cli(e->cmda, 1)) { ast_log(LOG_WARNING, "Command '%s' already registered (or something close enough)\n", e->_full_cmd); - free(e->_full_cmd); + ast_free(e->_full_cmd); e->_full_cmd = NULL; goto done; } @@ -1523,11 +1523,11 @@ if (!oldbuf || strcmp(buf,oldbuf)) matches++; if (oldbuf) - free(oldbuf); + ast_free(oldbuf); oldbuf = buf; } if (oldbuf) - free(oldbuf); + ast_free(oldbuf); return matches; } @@ -1646,7 +1646,7 @@ */ if (matchnum > state) break; - free(ret); + ast_free(ret); ret = NULL; } else if (ast_strlen_zero(e->cmda[dst])) { /* @@ -1669,7 +1669,7 @@ } if (lock) AST_LIST_UNLOCK(&helpers); - free(dup); + ast_free(dup); return ret; } @@ -1743,6 +1743,6 @@ } ast_atomic_fetchadd_int(&e->inuse, -1); done: - free(dup); + ast_free(dup); return 0; } Index: main/io.c =================================================================== --- main/io.c (revision 67164) +++ main/io.c (working copy) @@ -87,12 +87,12 @@ tmp->current_ioc = -1; if (!(tmp->fds = ast_calloc(1, (GROW_SHRINK_SIZE / 2) * sizeof(*tmp->fds)))) { - free(tmp); + ast_free(tmp); tmp = NULL; } else { if (!(tmp->ior = ast_calloc(1, (GROW_SHRINK_SIZE / 2) * sizeof(*tmp->ior)))) { - free(tmp->fds); - free(tmp); + ast_free(tmp->fds); + ast_free(tmp); tmp = NULL; } } @@ -104,11 +104,11 @@ { /* Free associated memory with an I/O context */ if (ioc->fds) - free(ioc->fds); + ast_free(ioc->fds); if (ioc->ior) - free(ioc->ior); + ast_free(ioc->ior); - free(ioc); + ast_free(ioc); } /*! \brief @@ -250,7 +250,7 @@ for (x = 0; x < ioc->fdcnt; x++) { if (ioc->ior[x].id == _id) { /* Free the int immediately and set to NULL so we know it's unused now */ - free(ioc->ior[x].id); + ast_free(ioc->ior[x].id); ioc->ior[x].id = NULL; ioc->fds[x].events = 0; ioc->fds[x].revents = 0; Index: main/dial.c =================================================================== --- main/dial.c (revision 67164) +++ main/dial.c (working copy) @@ -115,10 +115,10 @@ /* If arguments are present, free them too */ if (answer_exec->args) - free(answer_exec->args); + ast_free(answer_exec->args); /* This is simple - just free the structure */ - free(answer_exec); + ast_free(answer_exec); return 0; } @@ -133,7 +133,7 @@ if (!data) return -1; - free(data); + ast_free(data); return 0; } @@ -707,7 +707,7 @@ channel->owner = NULL; } /* Free structure */ - free(channel); + ast_free(channel); } /* Disable any enabled options globally */ @@ -720,7 +720,7 @@ } /* Free structure */ - free(dial); + ast_free(dial); return 0; } Index: main/strcompat.c =================================================================== --- main/strcompat.c (revision 67164) +++ main/strcompat.c (working copy) @@ -141,7 +141,7 @@ char *strndup(const char *s, size_t n) { size_t len = strnlen(s, n); - char *new = malloc(len + 1); + char *new = ast_malloc(len + 1); if (!new) return NULL; @@ -162,7 +162,7 @@ va_copy(ap2, ap); size = vsnprintf(&s, 1, fmt, ap2); va_end(ap2); - *strp = malloc(size + 1); + *strp = ast_malloc(size + 1); if (!*strp) return -1; vsnprintf(*strp, size + 1, fmt, ap); Index: main/sched.c =================================================================== --- main/sched.c (revision 67164) +++ main/sched.c (working copy) @@ -94,17 +94,17 @@ #ifdef SCHED_MAX_CACHE /* Eliminate the cache */ while ((s = AST_LIST_REMOVE_HEAD(&con->schedc, list))) - free(s); + ast_free(s); #endif /* And the queue */ while ((s = AST_LIST_REMOVE_HEAD(&con->schedq, list))) - free(s); + ast_free(s); /* And the context */ ast_mutex_unlock(&con->lock); ast_mutex_destroy(&con->lock); - free(con); + ast_free(con); } static struct sched *sched_alloc(struct sched_context *con) @@ -138,7 +138,7 @@ con->schedccnt++; } else #endif - free(tmp); + ast_free(tmp); } /*! \brief Index: main/pbx.c =================================================================== --- main/pbx.c (revision 67164) +++ main/pbx.c (working copy) @@ -609,7 +609,7 @@ static void pbx_destroy(struct ast_pbx *p) { - free(p); + ast_free(p); } /* @@ -2022,7 +2022,7 @@ handle_statechange(sc->dev); - free(sc); + ast_free(sc); } return NULL; @@ -2133,7 +2133,7 @@ if (p_cur && *p_cur) { struct ast_state_cb *cur = *p_cur; *p_cur = cur->next; - free(cur); + ast_free(cur); ret = 0; } AST_RWLIST_UNLOCK(&hints); @@ -2215,11 +2215,11 @@ cbprev = cblist; cblist = cblist->next; cbprev->callback(hint->exten->parent->name, hint->exten->exten, AST_EXTENSION_DEACTIVATED, cbprev->data); - free(cbprev); + ast_free(cbprev); } hint->callbacks = NULL; AST_RWLIST_REMOVE_CURRENT(&hints, list); - free(hint); + ast_free(hint); res = 0; break; } @@ -2326,7 +2326,7 @@ if (c->pbx) { ast_log(LOG_WARNING, "%s already has PBX structure??\n", c->name); /* XXX and now what ? */ - free(c->pbx); + ast_free(c->pbx); } if (!(c->pbx = ast_calloc(1, sizeof(*c->pbx)))) return -1; @@ -2335,7 +2335,7 @@ c->cdr = ast_cdr_alloc(); if (!c->cdr) { ast_log(LOG_WARNING, "Unable to create Call Detail Record\n"); - free(c->pbx); + ast_free(c->pbx); return -1; } ast_cdr_init(c->cdr, c); @@ -2593,7 +2593,7 @@ if (e->datad) e->datad(e->data); - free(e); + ast_free(e); } static void *pbx_thread(void *data) @@ -2722,7 +2722,7 @@ else con->includes = i->next; /* free include and return */ - free(i); + ast_free(i); ret = 0; break; } @@ -2772,7 +2772,7 @@ (!registrar || !strcmp(i->registrar, registrar))) { /* found, remove from list */ AST_LIST_REMOVE_CURRENT(&con->alts, list); - free(i); /* free switch and return */ + ast_free(i); /* free switch and return */ ret = 0; break; } @@ -3925,7 +3925,7 @@ AST_RWLIST_REMOVE_CURRENT(&apps, list); if (option_verbose > 1) ast_verbose( VERBOSE_PREFIX_2 "Unregistered application '%s'\n", tmp->name); - free(tmp); + ast_free(tmp); break; } } @@ -4083,7 +4083,7 @@ prevcb = thiscb; thiscb = thiscb->next; prevcb->callback(this->context, this->exten, AST_EXTENSION_REMOVED, prevcb->data); - free(prevcb); + ast_free(prevcb); } } else { thiscb = this->callbacks; @@ -4093,7 +4093,7 @@ hint->callbacks = this->callbacks; hint->laststate = this->laststate; } - free(this); + ast_free(this); } AST_RWLIST_UNLOCK(&hints); @@ -4406,7 +4406,7 @@ /* ... go to last include and check if context is already included too... */ for (i = con->includes; i; i = i->next) { if (!strcasecmp(i->name, new_include->name)) { - free(new_include); + ast_free(new_include); ast_unlock_context(con); errno = EEXIST; return -1; @@ -4497,7 +4497,7 @@ /* ... go to last sw and check if context is already swd too... */ AST_LIST_TRAVERSE(&con->alts, i, list) { if (!strcasecmp(i->name, new_sw->name) && !strcasecmp(i->data, new_sw->data)) { - free(new_sw); + ast_free(new_sw); ast_unlock_context(con); errno = EEXIST; return -1; @@ -4542,10 +4542,10 @@ (!registrar || (registrar == ip->registrar))) { if (ipl) { ipl->next = ip->next; - free(ip); + ast_free(ip); } else { con->ignorepats = ip->next; - free(ip); + ast_free(ip); } ast_unlock_context(con); return 0; @@ -4766,7 +4766,7 @@ ast_log(LOG_WARNING, "Unable to register extension '%s', priority %d in '%s', already in use\n", tmp->exten, tmp->priority, con->name); if (tmp->datad) tmp->datad(tmp->data); - free(tmp); + ast_free(tmp); return -1; } /* we are replacing e, so copy the link fields and then update @@ -4785,7 +4785,7 @@ /* Destroy the old one */ if (e->datad) e->datad(e->data); - free(e); + ast_free(e); } else { /* Slip ourselves in just before e */ tmp->peer = e; tmp->next = e->next; /* extension chain, or NULL if e is not the first extension */ @@ -5020,7 +5020,7 @@ } } } - free(as); + ast_free(as); if (chan) ast_hangup(chan); return NULL; @@ -5162,7 +5162,7 @@ ast_channel_lock(chan); } if (!chan) { - free(as); + ast_free(as); res = -1; goto outgoing_exten_cleanup; } @@ -5175,7 +5175,7 @@ ast_cdr_setaccount(chan, account); if (ast_pthread_create_detached(&as->p, NULL, async_wait, as)) { ast_log(LOG_WARNING, "Failed to start async wait\n"); - free(as); + ast_free(as); if (channel) { *channel = NULL; ast_channel_unlock(chan); @@ -5211,7 +5211,7 @@ } else ast_log(LOG_WARNING, "No such application '%s'\n", tmp->app); ast_hangup(tmp->chan); - free(tmp); + ast_free(tmp); return NULL; } @@ -5241,7 +5241,7 @@ chan->cdr = ast_cdr_alloc(); /* allocate a cdr for the channel */ if (!chan->cdr) { /* allocation of the cdr failed */ - free(chan->pbx); + ast_free(chan->pbx); res = -1; goto outgoing_app_cleanup; } @@ -5273,7 +5273,7 @@ ast_channel_lock(chan); if (ast_pthread_create_detached(&tmp->t, NULL, ast_pbx_run_app, tmp)) { ast_log(LOG_WARNING, "Unable to spawn execute thread on %s: %s\n", chan->name, strerror(errno)); - free(tmp); + ast_free(tmp); if (locked_channel) ast_channel_unlock(chan); ast_hangup(chan); @@ -5316,7 +5316,7 @@ } chan = __ast_request_and_dial(type, format, data, timeout, reason, cid_num, cid_name, &oh); if (!chan) { - free(as); + ast_free(as); res = -1; goto outgoing_app_cleanup; } @@ -5333,7 +5333,7 @@ ast_channel_lock(chan); if (ast_pthread_create_detached(&as->p, NULL, async_wait, as)) { ast_log(LOG_WARNING, "Failed to start async wait\n"); - free(as); + ast_free(as); if (locked_channel) ast_channel_unlock(chan); ast_hangup(chan); @@ -5383,15 +5383,15 @@ for (tmpi = tmp->includes; tmpi; ) { /* Free includes */ struct ast_include *tmpil = tmpi; tmpi = tmpi->next; - free(tmpil); + ast_free(tmpil); } for (ipi = tmp->ignorepats; ipi; ) { /* Free ignorepats */ struct ast_ignorepat *ipl = ipi; ipi = ipi->next; - free(ipl); + ast_free(ipl); } while ((sw = AST_LIST_REMOVE_HEAD(&tmp->alts, list))) - free(sw); + ast_free(sw); for (e = tmp->root; e;) { for (en = e->peer; en;) { el = en; @@ -5403,7 +5403,7 @@ destroy_exten(el); } ast_rwlock_destroy(&tmp->lock); - free(tmp); + ast_free(tmp); /* if we have a specific match, we are done, otherwise continue */ tmp = con ? NULL : next; } Index: main/dnsmgr.c =================================================================== --- main/dnsmgr.c (revision 67164) +++ main/dnsmgr.c (working copy) @@ -116,7 +116,7 @@ ast_verbose(VERBOSE_PREFIX_4 "removing dns manager for '%s'\n", entry->name); ast_mutex_destroy(&entry->lock); - free(entry); + ast_free(entry); } int ast_dnsmgr_lookup(const char *name, struct in_addr *result, struct ast_dnsmgr_entry **dnsmgr) Index: main/netsock.c =================================================================== --- main/netsock.c (revision 67164) +++ main/netsock.c (working copy) @@ -80,7 +80,7 @@ { ast_io_remove(netsock->ioc, netsock->ioref); close(netsock->sockfd); - free(netsock); + ast_free(netsock); } struct ast_netsock_list *ast_netsock_list_alloc(void) @@ -147,7 +147,7 @@ ast_enable_packet_fragmentation(netsocket); - if (!(ns = ast_calloc(1, sizeof(struct ast_netsock)))) { + if (!(ns = ast_calloc(1, sizeof(*ns)))) { close(netsocket); return NULL; } @@ -155,7 +155,7 @@ /* Establish I/O callback for socket read */ if (!(ioref = ast_io_add(ioc, netsocket, callback, AST_IO_IN, ns))) { close(netsocket); - free(ns); + ast_free(ns); return NULL; } ASTOBJ_INIT(ns); Index: main/file.c =================================================================== --- main/file.c (revision 67164) +++ main/file.c (working copy) @@ -112,7 +112,7 @@ AST_RWLIST_TRAVERSE_SAFE_BEGIN(&formats, tmp, list) { if (!strcasecmp(name, tmp->name)) { AST_RWLIST_REMOVE_CURRENT(&formats, list); - free(tmp); + ast_free(tmp); res = 0; } } @@ -372,7 +372,7 @@ continue; if ( stat(fn, &st) ) { /* file not existent */ - free(fn); + ast_free(fn); continue; } /* for 'OPEN' we need to be sure that the format matches @@ -385,23 +385,23 @@ if ( !(chan->writeformat & f->format) && !(f->format >= AST_FORMAT_MAX_AUDIO && fmt)) { - free(fn); + ast_free(fn); continue; /* not a supported format */ } if ( (bfile = fopen(fn, "r")) == NULL) { - free(fn); + ast_free(fn); continue; /* cannot open file */ } s = get_filestream(f, bfile); if (!s) { fclose(bfile); - free(fn); /* cannot allocate descriptor */ + ast_free(fn); /* cannot allocate descriptor */ continue; } if (open_wrapper(s)) { fclose(bfile); - free(fn); - free(s); + ast_free(fn); + ast_free(s); continue; /* cannot run open on file */ } /* ok this is good for OPEN */ @@ -419,7 +419,7 @@ ast_closestream(chan->vstream); chan->vstream = s; } - free(fn); + ast_free(fn); break; } switch (action) { @@ -446,7 +446,7 @@ ast_log(LOG_WARNING, "%s(%s,%s) failed: %s\n", action == ACTION_COPY ? "copy" : "rename", fn, nfn, strerror(errno)); - free(nfn); + ast_free(nfn); } } break; @@ -454,7 +454,7 @@ default: ast_log(LOG_WARNING, "Unknown helper %d\n", action); } - free(fn); + ast_free(fn); } } AST_RWLIST_UNLOCK(&formats); @@ -732,16 +732,16 @@ } if (f->filename) - free(f->filename); + ast_free(f->filename); if (f->realfilename) - free(f->realfilename); + ast_free(f->realfilename); if (f->fmt->close) f->fmt->close(f); fclose(f->f); if (f->vfs) ast_closestream(f->vfs); ast_module_unref(f->fmt->module); - free(f); + ast_free(f); return 0; } @@ -833,7 +833,7 @@ ast_free(fs); if (bfile) fclose(bfile); - free(fn); + ast_free(fn); continue; } /* found it */ @@ -919,7 +919,7 @@ strcpy(buf, record_cache_dir); strcat(buf, "/"); strcat(buf, fn); - free(fn); + ast_free(fn); fn = buf; fd = open(fn, flags | myflags, mode); if (fd > -1) { @@ -966,7 +966,7 @@ } /* if buf != NULL then fn is already free and pointing to it */ if (!buf) - free(fn); + ast_free(fn); } AST_RWLIST_UNLOCK(&formats); Index: main/callerid.c =================================================================== --- main/callerid.c (revision 67164) +++ main/callerid.c (working copy) @@ -683,7 +683,7 @@ void callerid_free(struct callerid_state *cid) { - free(cid); + ast_free(cid); } static int callerid_genmsg(char *msg, int size, const char *number, const char *name, int flags) Index: main/dlfcn.c =================================================================== --- main/dlfcn.c (revision 67164) +++ main/dlfcn.c (working copy) @@ -287,7 +287,7 @@ if (!buf) { buf_size = strlen(ldlp) + strlen(dyldlp) + strlen(stdpath) + 4; - buf = malloc(buf_size); + buf = ast_malloc(buf_size); snprintf(buf, buf_size, "%s%s%s%s%s%c", dyldlp, (dyldlp[0] ? ":" : ""), ldlp, (ldlp[0] ? ":" : ""), stdpath, '\0'); } @@ -309,18 +309,18 @@ } if (!path) { - path = (char **)calloc(MAX_SEARCH_PATHS, sizeof(char **)); + path = ast_calloc(MAX_SEARCH_PATHS, sizeof(char **)); } if (!list && !end) list = searchList(); if (i >= (numsize)) { debug("Increasing size for long PATH"); - tmp = (char **)calloc((MAX_SEARCH_PATHS + numsize), sizeof(char **)); + tmp = ast_calloc((MAX_SEARCH_PATHS + numsize), sizeof(char **)); if (tmp) { memcpy(tmp, path, sizeof(char **) * numsize); - free(path); + ast_free(path); path = tmp; numsize += MAX_SEARCH_PATHS; } @@ -434,7 +434,7 @@ dls = dls->next; if (!dls) #endif - dls = malloc(sizeof(*dls)); + dls = ast_malloc(sizeof(*dls)); dls->flags = 0; return dls; } @@ -551,7 +551,7 @@ NSLinkEditError(&dylder, &dylderno, &dyldfile, &dylderrstr); if (dylderrstr && strlen(dylderrstr)) { - retStr = malloc(strlen(dylderrstr) +1); + retStr = ast_malloc(strlen(dylderrstr) +1); strcpy((char*)retStr,dylderrstr); } return retStr; @@ -651,8 +651,8 @@ else { if (savedErrorStr) - free((char*)savedErrorStr); - savedErrorStr = malloc(256); + ast_free(savedErrorStr); + savedErrorStr = ast_malloc(256); snprintf((char*)savedErrorStr, 256, "Symbol \"%s\" not in global context",symbol); } } @@ -663,8 +663,8 @@ if (!savedErrorStr || !strlen(savedErrorStr)) { if (savedErrorStr) - free((char*)savedErrorStr); - savedErrorStr = malloc(256); + ast_free(savedErrorStr); + savedErrorStr = ast_malloc(256); snprintf((char*)savedErrorStr, 256,"Symbol \"%s\" not found",symbol); } if (canSetError) @@ -676,7 +676,7 @@ debug(savedErrorStr); } if (savedErrorStr) - free((char*)savedErrorStr); + ast_free(savedErrorStr); return NULL; } return NSAddressOfSymbol(nssym); @@ -760,7 +760,7 @@ error(errstr); if ((dls->flags & DL_IN_LIST) == 0) { - free(dls); + ast_free(dls); } return NULL; } @@ -782,7 +782,7 @@ NSLinkEditError(&ler, &lerno, &file, &errstr); if ((dls->flags & DL_IN_LIST) == 0) { - free(dls); + ast_free(dls); } error(errstr); return NULL; @@ -828,10 +828,10 @@ char *data; data = (char *)searchList(); if ( data ) - free( data ); + ast_free(data); data = (char *)getSearchPath(-1); if ( data ) - free( data ); + ast_free(data); pthread_mutex_destroy(&dlcompat_mutex); pthread_key_delete(dlerror_key); next = stqueue; @@ -839,7 +839,7 @@ { dls = next; next = dls->next; - free(dls); + ast_free(dls); } } @@ -852,7 +852,7 @@ static void dlerrorfree(void *data) { - free(data); + ast_free(data); } /* We kind of want a recursive lock here, but meet a little trouble @@ -866,7 +866,7 @@ tss = pthread_getspecific(dlerror_key); if (!tss) { - tss = malloc(sizeof(struct dlthread)); + tss = ast_malloc(sizeof(*tss)); tss->lockcnt = 0; tss->errset = 0; if (pthread_setspecific(dlerror_key, tss)) @@ -948,12 +948,12 @@ void *value = NULL; char *malloc_sym = NULL; dolock(); - malloc_sym = malloc(sym_len + 2); + malloc_sym = ast_malloc(sym_len + 2); if (malloc_sym) { sprintf(malloc_sym, "_%s", symbol); value = dlsymIntern(handle, malloc_sym, 1); - free(malloc_sym); + ast_free(malloc_sym); } else { @@ -993,12 +993,12 @@ int sym_len = strlen(symbol); void *value = NULL; char *malloc_sym = NULL; - malloc_sym = malloc(sym_len + 2); + malloc_sym = ast_malloc(sym_len + 2); if (malloc_sym) { sprintf(malloc_sym, "_%s", symbol); value = dlsymIntern(handle, malloc_sym, 1); - free(malloc_sym); + ast_free(malloc_sym); } else { @@ -1293,12 +1293,12 @@ int sym_len = strlen(symbol); char *malloc_sym = NULL; dolock(); - malloc_sym = malloc(sym_len + 2); + malloc_sym = ast_malloc(sym_len + 2); if (malloc_sym) { sprintf(malloc_sym, "_%s", symbol); rv.d = dlsymIntern(handle, malloc_sym, 1); - free(malloc_sym); + ast_free(malloc_sym); } else {