[svn-commits] branch russell/ast_malloc - r7654
/team/russell/ast_malloc/
svn-commits at lists.digium.com
svn-commits at lists.digium.com
Tue Dec 27 10:28:49 CST 2005
Author: russell
Date: Tue Dec 27 10:28:43 2005
New Revision: 7654
URL: http://svn.digium.com/view/asterisk?rev=7654&view=rev
Log:
revert debug code so i don't have to keep it in sync with the trunk
Modified:
team/russell/ast_malloc/acl.c
team/russell/ast_malloc/app.c
team/russell/ast_malloc/asterisk.c
team/russell/ast_malloc/autoservice.c
team/russell/ast_malloc/callerid.c
team/russell/ast_malloc/cdr.c
team/russell/ast_malloc/channel.c
team/russell/ast_malloc/chanvars.c
team/russell/ast_malloc/cli.c
team/russell/ast_malloc/config.c
team/russell/ast_malloc/db.c
team/russell/ast_malloc/devicestate.c
team/russell/ast_malloc/dnsmgr.c
team/russell/ast_malloc/dsp.c
team/russell/ast_malloc/enum.c
team/russell/ast_malloc/file.c
team/russell/ast_malloc/frame.c
team/russell/ast_malloc/indications.c
Modified: team/russell/ast_malloc/acl.c
URL: http://svn.digium.com/view/asterisk/team/russell/ast_malloc/acl.c?rev=7654&r1=7653&r2=7654&view=diff
==============================================================================
--- team/russell/ast_malloc/acl.c (original)
+++ team/russell/ast_malloc/acl.c Tue Dec 27 10:28:43 2005
@@ -112,11 +112,9 @@
/* Create duplicate of ha structure */
static struct ast_ha *ast_duplicate_ha(struct ast_ha *original)
{
- struct ast_ha *new_ha = ast_malloc(sizeof(struct ast_ha));
-
+ struct ast_ha *new_ha = malloc(sizeof(struct ast_ha));
/* Copy from original to new object */
- if (new_ha)
- ast_copy_ha(original, new_ha);
+ ast_copy_ha(original, new_ha);
return new_ha;
}
@@ -145,66 +143,60 @@
struct ast_ha *ast_append_ha(char *sense, char *stuff, struct ast_ha *path)
{
- struct ast_ha *ha;
+ struct ast_ha *ha = malloc(sizeof(struct ast_ha));
char *nm = "255.255.255.255";
char tmp[256];
struct ast_ha *prev = NULL;
struct ast_ha *ret;
int x, z;
unsigned int y;
-
ret = path;
while (path) {
prev = path;
path = path->next;
}
-
- ha = ast_calloc(1, sizeof(struct ast_ha));
- if (!ha)
- return ret;
-
- ast_copy_string(tmp, stuff, sizeof(tmp));
- nm = strchr(tmp, '/');
- if (!nm) {
- nm = "255.255.255.255";
- } else {
- *nm = '\0';
- nm++;
- }
- if (!strchr(nm, '.')) {
- if ((sscanf(nm, "%d", &x) == 1) && (x >= 0) && (x <= 32)) {
- y = 0;
- for (z=0;z<x;z++) {
- y >>= 1;
- y |= 0x80000000;
+ if (ha) {
+ ast_copy_string(tmp, stuff, sizeof(tmp));
+ nm = strchr(tmp, '/');
+ if (!nm) {
+ nm = "255.255.255.255";
+ } else {
+ *nm = '\0';
+ nm++;
+ }
+ if (!strchr(nm, '.')) {
+ if ((sscanf(nm, "%d", &x) == 1) && (x >= 0) && (x <= 32)) {
+ y = 0;
+ for (z=0;z<x;z++) {
+ y >>= 1;
+ y |= 0x80000000;
+ }
+ ha->netmask.s_addr = htonl(y);
}
- ha->netmask.s_addr = htonl(y);
- }
- } else if (!inet_aton(nm, &ha->netmask)) {
- ast_log(LOG_WARNING, "%s is not a valid netmask\n", nm);
- free(ha);
- return path;
- }
- if (!inet_aton(tmp, &ha->netaddr)) {
- ast_log(LOG_WARNING, "%s is not a valid IP\n", tmp);
- free(ha);
- return path;
- }
- ha->netaddr.s_addr &= ha->netmask.s_addr;
- if (!strncasecmp(sense, "p", 1)) {
- ha->sense = AST_SENSE_ALLOW;
- } else {
- ha->sense = AST_SENSE_DENY;
- }
- ha->next = NULL;
- if (prev) {
- prev->next = ha;
- } else {
- ret = ha;
- }
-
+ } else if (!inet_aton(nm, &ha->netmask)) {
+ ast_log(LOG_WARNING, "%s is not a valid netmask\n", nm);
+ free(ha);
+ return path;
+ }
+ if (!inet_aton(tmp, &ha->netaddr)) {
+ ast_log(LOG_WARNING, "%s is not a valid IP\n", tmp);
+ free(ha);
+ return path;
+ }
+ ha->netaddr.s_addr &= ha->netmask.s_addr;
+ if (!strncasecmp(sense, "p", 1)) {
+ ha->sense = AST_SENSE_ALLOW;
+ } else {
+ ha->sense = AST_SENSE_DENY;
+ }
+ ha->next = NULL;
+ if (prev) {
+ prev->next = ha;
+ } else {
+ ret = ha;
+ }
+ }
ast_log(LOG_DEBUG, "%s/%s appended to acl for peer\n", stuff, nm);
-
return ret;
}
Modified: team/russell/ast_malloc/app.c
URL: http://svn.digium.com/view/asterisk/team/russell/ast_malloc/app.c?rev=7654&r1=7653&r2=7654&view=diff
==============================================================================
--- team/russell/ast_malloc/app.c (original)
+++ team/russell/ast_malloc/app.c Tue Dec 27 10:28:43 2005
@@ -398,8 +398,8 @@
{
struct linear_state *lin;
char tmpf[256];
+ int res = -1;
int autoclose = 0;
-
if (fd < 0) {
if (ast_strlen_zero(filename))
return -1;
@@ -414,16 +414,15 @@
return -1;
}
}
-
- lin = ast_calloc(1, sizeof(struct linear_state));
- if (!lin)
- return -1;
-
- lin->fd = fd;
- lin->allowoverride = allowoverride;
- lin->autoclose = autoclose;
-
- return ast_activate_generator(chan, &linearstream, lin);
+ lin = malloc(sizeof(struct linear_state));
+ if (lin) {
+ memset(lin, 0, sizeof(lin));
+ lin->fd = fd;
+ lin->allowoverride = allowoverride;
+ lin->autoclose = autoclose;
+ res = ast_activate_generator(chan, &linearstream, lin);
+ }
+ return res;
}
int ast_control_streamfile(struct ast_channel *chan, const char *file,
@@ -1487,8 +1486,7 @@
struct stat filesize;
int count=0;
int res;
-
- if (stat(filename,&filesize) == -1){
+ if(stat(filename,&filesize)== -1){
ast_log(LOG_WARNING,"Error can't stat %s\n", filename);
return NULL;
}
@@ -1498,24 +1496,19 @@
ast_log(LOG_WARNING, "Cannot open file '%s' for reading: %s\n", filename, strerror(errno));
return NULL;
}
-
- output = ast_calloc(1, count);
- if (!output) {
- close(fd);
- return NULL;
- }
-
- res = read(fd, output, count - 1);
- if (res == count - 1) {
- 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);
- output = NULL;
- }
-
+ output=(char *)malloc(count);
+ if (output) {
+ res = read(fd, output, count - 1);
+ if (res == count - 1) {
+ 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);
+ output = NULL;
+ }
+ } else
+ ast_log(LOG_WARNING, "Out of memory!\n");
close(fd);
-
return output;
}
Modified: team/russell/ast_malloc/asterisk.c
URL: http://svn.digium.com/view/asterisk/team/russell/ast_malloc/asterisk.c?rev=7654&r1=7653&r2=7654&view=diff
==============================================================================
--- team/russell/ast_malloc/asterisk.c (original)
+++ team/russell/ast_malloc/asterisk.c Tue Dec 27 10:28:43 2005
@@ -230,7 +230,7 @@
work = ast_strip(ast_strip_quoted(work, "$", "$"));
version_length = strlen(work) + 1;
- new = ast_calloc(1, sizeof(*new) + version_length);
+ new = calloc(1, sizeof(*new) + version_length);
if (!new)
return;
@@ -346,21 +346,20 @@
int ast_register_atexit(void (*func)(void))
{
+ int res = -1;
struct ast_atexit *ae;
-
ast_unregister_atexit(func);
-
- ae = ast_calloc(1, sizeof(struct ast_atexit));
- if (!ae)
- return -1;
-
+ ae = malloc(sizeof(struct ast_atexit));
ast_mutex_lock(&atexitslock);
- ae->next = atexits;
- ae->func = func;
- atexits = ae;
+ if (ae) {
+ memset(ae, 0, sizeof(struct ast_atexit));
+ ae->next = atexits;
+ ae->func = func;
+ atexits = ae;
+ res = 0;
+ }
ast_mutex_unlock(&atexitslock);
-
- return 0;
+ return res;
}
void ast_unregister_atexit(void (*func)(void))
@@ -1465,7 +1464,7 @@
break;
if (matches + 1 >= match_list_len) {
match_list_len <<= 1;
- match_list = ast_realloc(match_list, match_list_len * sizeof(char *));
+ match_list = realloc(match_list, match_list_len * sizeof(char *));
}
match_list[matches++] = strdup(retstr);
@@ -1475,7 +1474,7 @@
return (char **) NULL;
if (matches>= match_list_len)
- match_list = ast_realloc(match_list, (match_list_len + 1) * sizeof(char *));
+ match_list = realloc(match_list, (match_list_len + 1) * sizeof(char *));
match_list[matches] = (char *) NULL;
@@ -1577,7 +1576,7 @@
char *mbuf;
int mlen = 0, maxmbuf = 2048;
/* Start with a 2048 byte buffer */
- mbuf = ast_malloc(maxmbuf);
+ mbuf = malloc(maxmbuf);
if (!mbuf)
return (char *)(CC_ERROR);
snprintf(buf, sizeof(buf),"_COMMAND MATCHESARRAY \"%s\" \"%s\"", lf->buffer, ptr);
@@ -1588,7 +1587,7 @@
if (mlen + 1024 > maxmbuf) {
/* Every step increment buffer 1024 bytes */
maxmbuf += 1024;
- mbuf = ast_realloc(mbuf, maxmbuf);
+ mbuf = realloc(mbuf, maxmbuf);
if (!mbuf)
return (char *)(CC_ERROR);
}
Modified: team/russell/ast_malloc/autoservice.c
URL: http://svn.digium.com/view/asterisk/team/russell/ast_malloc/autoservice.c?rev=7654&r1=7653&r2=7654&view=diff
==============================================================================
--- team/russell/ast_malloc/autoservice.c (original)
+++ team/russell/ast_malloc/autoservice.c Tue Dec 27 10:28:43 2005
@@ -105,39 +105,34 @@
int res = -1;
struct asent *as;
int needstart;
-
ast_mutex_lock(&autolock);
-
needstart = (asthread == AST_PTHREADT_NULL) ? 1 : 0 /* aslist ? 0 : 1 */;
-
- for (as = aslist; as; as = as->next) {
- if (as->chan == chan) {
- ast_mutex_unlock(&autolock);
- return res;
+ as = aslist;
+ while(as) {
+ if (as->chan == chan)
+ break;
+ as = as->next;
+ }
+ if (!as) {
+ as = malloc(sizeof(struct asent));
+ if (as) {
+ memset(as, 0, sizeof(struct asent));
+ as->chan = chan;
+ as->next = aslist;
+ aslist = as;
+ res = 0;
+ if (needstart) {
+ if (ast_pthread_create(&asthread, NULL, autoservice_run, NULL)) {
+ ast_log(LOG_WARNING, "Unable to create autoservice thread :(\n");
+ free(aslist);
+ aslist = NULL;
+ res = -1;
+ } else
+ pthread_kill(asthread, SIGURG);
+ }
}
}
-
- as = ast_calloc(1, sizeof(struct asent));
- if (!as) {
- ast_mutex_unlock(&autolock);
- return res;
- }
- as->chan = chan;
- as->next = aslist;
- aslist = as;
- res = 0;
- if (needstart) {
- if (ast_pthread_create(&asthread, NULL, autoservice_run, NULL)) {
- ast_log(LOG_WARNING, "Unable to create autoservice thread :(\n");
- free(aslist);
- aslist = NULL;
- res = -1;
- } else
- pthread_kill(asthread, SIGURG);
- }
-
ast_mutex_unlock(&autolock);
-
return res;
}
Modified: team/russell/ast_malloc/callerid.c
URL: http://svn.digium.com/view/asterisk/team/russell/ast_malloc/callerid.c?rev=7654&r1=7653&r2=7654&view=diff
==============================================================================
--- team/russell/ast_malloc/callerid.c (original)
+++ team/russell/ast_malloc/callerid.c Tue Dec 27 10:28:43 2005
@@ -127,31 +127,32 @@
struct callerid_state *callerid_new(int cid_signalling)
{
struct callerid_state *cid;
-
- cid = ast_calloc(1, sizeof(struct callerid_state));
- if (!cid)
- return NULL;
-
- cid->fskd.spb = 7; /* 1200 baud */
- cid->fskd.hdlc = 0; /* Async */
- cid->fskd.nbit = 8; /* 8 bits */
- cid->fskd.nstop = 1; /* 1 stop bit */
- cid->fskd.paridad = 0; /* No parity */
- cid->fskd.bw=1; /* Filter 800 Hz */
- if (cid_signalling == 2) { /* v23 signalling */
- cid->fskd.f_mark_idx = 4; /* 1300 Hz */
- cid->fskd.f_space_idx = 5; /* 2100 Hz */
- } else { /* Bell 202 signalling as default */
- cid->fskd.f_mark_idx = 2; /* 1200 Hz */
- cid->fskd.f_space_idx = 3; /* 2200 Hz */
- }
- cid->fskd.pcola = 0; /* No clue */
- cid->fskd.cont = 0; /* Digital PLL reset */
- cid->fskd.x0 = 0.0;
- cid->fskd.state = 0;
- cid->flags = CID_UNKNOWN_NAME | CID_UNKNOWN_NUMBER;
- cid->pos = 0;
-
+ cid = malloc(sizeof(struct callerid_state));
+ if (cid) {
+ memset(cid, 0, sizeof(struct callerid_state));
+ cid->fskd.spb = 7; /* 1200 baud */
+ cid->fskd.hdlc = 0; /* Async */
+ cid->fskd.nbit = 8; /* 8 bits */
+ cid->fskd.nstop = 1; /* 1 stop bit */
+ cid->fskd.paridad = 0; /* No parity */
+ cid->fskd.bw=1; /* Filter 800 Hz */
+ if (cid_signalling == 2) { /* v23 signalling */
+ cid->fskd.f_mark_idx = 4; /* 1300 Hz */
+ cid->fskd.f_space_idx = 5; /* 2100 Hz */
+ } else { /* Bell 202 signalling as default */
+ cid->fskd.f_mark_idx = 2; /* 1200 Hz */
+ cid->fskd.f_space_idx = 3; /* 2200 Hz */
+ }
+ cid->fskd.pcola = 0; /* No clue */
+ cid->fskd.cont = 0; /* Digital PLL reset */
+ cid->fskd.x0 = 0.0;
+ cid->fskd.state = 0;
+ memset(cid->name, 0, sizeof(cid->name));
+ memset(cid->number, 0, sizeof(cid->number));
+ cid->flags = CID_UNKNOWN_NAME | CID_UNKNOWN_NUMBER;
+ cid->pos = 0;
+ } else
+ ast_log(LOG_WARNING, "Out of memory\n");
return cid;
}
@@ -257,14 +258,13 @@
int b = 'X';
int res;
int x;
- short *buf;
- short *obuf;
-
- buf = ast_calloc(1, 2 * len + cid->oldlen);
- if (!buf)
+ short *buf = malloc(2 * len + cid->oldlen);
+ short *obuf = buf;
+ if (!buf) {
+ ast_log(LOG_WARNING, "Out of memory\n");
return -1;
- obuf = buf;
-
+ }
+ memset(buf, 0, 2 * len + cid->oldlen);
memcpy(buf, cid->oldstuff, cid->oldlen);
mylen += cid->oldlen/2;
for (x=0;x<len;x++)
Modified: team/russell/ast_malloc/cdr.c
URL: http://svn.digium.com/view/asterisk/team/russell/ast_malloc/cdr.c?rev=7654&r1=7653&r2=7654&view=diff
==============================================================================
--- team/russell/ast_malloc/cdr.c (original)
+++ team/russell/ast_malloc/cdr.c Tue Dec 27 10:28:43 2005
@@ -126,10 +126,11 @@
return -1;
}
- i = ast_calloc(1, sizeof(*i));
+ i = malloc(sizeof(*i));
if (!i)
return -1;
+ memset(i, 0, sizeof(*i));
i->be = be;
ast_copy_string(i->name, name, sizeof(i->name));
ast_copy_string(i->desc, desc, sizeof(i->desc));
@@ -436,7 +437,9 @@
{
struct ast_cdr *cdr;
- cdr = ast_calloc(1, sizeof(*cdr));
+ cdr = malloc(sizeof(*cdr));
+ if (cdr)
+ memset(cdr, 0, sizeof(*cdr));
return cdr;
}
@@ -870,7 +873,7 @@
static int init_batch(void)
{
/* This is the single meta-batch used to keep track of all CDRs during the entire life of the program */
- batch = ast_calloc(1, sizeof(*batch));
+ batch = malloc(sizeof(*batch));
if (!batch) {
ast_log(LOG_WARNING, "CDR: out of memory while trying to handle batched records, data will most likely be lost\n");
return -1;
@@ -981,13 +984,14 @@
ast_log(LOG_DEBUG, "CDR detaching from this thread\n");
/* we'll need a new tail for every CDR */
- newtail = ast_calloc(1, sizeof(*newtail));
+ newtail = malloc(sizeof(*newtail));
if (!newtail) {
ast_log(LOG_WARNING, "CDR: out of memory while trying to detach, will try in this thread instead\n");
post_cdr(cdr);
ast_cdr_free(cdr);
return;
}
+ memset(newtail, 0, sizeof(*newtail));
/* don't traverse a whole list (just keep track of the tail) */
ast_mutex_lock(&cdr_batch_lock);
Modified: team/russell/ast_malloc/channel.c
URL: http://svn.digium.com/view/asterisk/team/russell/ast_malloc/channel.c?rev=7654&r1=7653&r2=7654&view=diff
==============================================================================
--- team/russell/ast_malloc/channel.c (original)
+++ team/russell/ast_malloc/channel.c Tue Dec 27 10:28:43 2005
@@ -320,8 +320,9 @@
}
}
- chan = ast_calloc(1, sizeof(*chan));
+ chan = malloc(sizeof(*chan));
if (!chan) {
+ ast_log(LOG_WARNING, "Out of memory\n");
ast_mutex_unlock(&chlock);
return -1;
}
@@ -514,10 +515,13 @@
return NULL;
}
- tmp = ast_calloc(1, sizeof(struct ast_channel));
- if (!tmp)
+ tmp = malloc(sizeof(struct ast_channel));
+ if (!tmp) {
+ ast_log(LOG_WARNING, "Channel allocation failed: Out of memory\n");
return NULL;
-
+ }
+
+ memset(tmp, 0, sizeof(struct ast_channel));
tmp->sched = sched_context_create();
if (!tmp->sched) {
ast_log(LOG_WARNING, "Channel allocation failed: Unable to create schedule context\n");
@@ -969,8 +973,10 @@
}
if (!chan->spies) {
- if (!(chan->spies = ast_calloc(1, sizeof(*chan->spies))))
+ if (!(chan->spies = calloc(1, sizeof(*chan->spies)))) {
+ ast_log(LOG_WARNING, "Memory allocation failure\n");
return -1;
+ }
AST_LIST_HEAD_INIT_NOLOCK(&chan->spies->list);
AST_LIST_INSERT_HEAD(&chan->spies->list, spy, list);
@@ -3578,10 +3584,9 @@
struct tonepair_state *ts;
struct tonepair_def *td = params;
- ts = ast_calloc(1, sizeof(struct tonepair_state));
+ ts = calloc(1, sizeof(struct tonepair_state));
if (!ts)
return NULL;
-
ts->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);
@@ -3994,7 +3999,7 @@
{
struct ast_silence_generator *state;
- if (!(state = ast_calloc(1, sizeof(*state)))) {
+ if (!(state = calloc(1, sizeof(*state)))) {
ast_log(LOG_WARNING, "Could not allocate state structure\n");
return NULL;
}
Modified: team/russell/ast_malloc/chanvars.c
URL: http://svn.digium.com/view/asterisk/team/russell/ast_malloc/chanvars.c?rev=7654&r1=7653&r2=7654&view=diff
==============================================================================
--- team/russell/ast_malloc/chanvars.c (original)
+++ team/russell/ast_malloc/chanvars.c Tue Dec 27 10:28:43 2005
@@ -32,16 +32,18 @@
#include "asterisk/chanvars.h"
#include "asterisk/logger.h"
#include "asterisk/strings.h"
-#include "asterisk/utils.h"
struct ast_var_t *ast_var_assign(const char *name, const char *value)
{
int i;
struct ast_var_t *var;
- var = ast_calloc(sizeof(struct ast_var_t) + strlen(name) + 1 + strlen(value) + 1, sizeof(char));
- if (!var)
+ var = calloc(sizeof(struct ast_var_t) + strlen(name) + 1 + strlen(value) + 1, sizeof(char));
+
+ if (var == NULL) {
+ ast_log(LOG_WARNING, "Out of memory\n");
return NULL;
+ }
i = strlen(name) + 1;
ast_copy_string(var->name, name, i);
Modified: team/russell/ast_malloc/cli.c
URL: http://svn.digium.com/view/asterisk/team/russell/ast_malloc/cli.c?rev=7654&r1=7653&r2=7654&view=diff
==============================================================================
--- team/russell/ast_malloc/cli.c (original)
+++ team/russell/ast_malloc/cli.c Tue Dec 27 10:28:43 2005
@@ -567,11 +567,10 @@
if (argc != 4)
return RESULT_SHOWUSAGE;
-
- buf = ast_calloc(1, buflen);
+ buf = malloc(buflen);
if (!buf)
return RESULT_FAILURE;
-
+ buf[len] = '\0';
matches = ast_cli_completion_matches(argv[2], argv[3]);
if (matches) {
for (x=0; matches[x]; x++) {
@@ -582,7 +581,7 @@
if (len + matchlen >= buflen) {
buflen += matchlen * 3;
obuf = buf;
- buf = ast_realloc(obuf, buflen);
+ buf = realloc(obuf, buflen);
if (!buf)
/* Out of memory... Just free old buffer and be done */
free(obuf);
@@ -1322,16 +1321,13 @@
max_equal = i;
}
- retstr = ast_calloc(1, max_equal + 1);
- if (!retstr)
- return NULL;
-
+ retstr = malloc(max_equal + 1);
strncpy(retstr, match_list[1], max_equal);
retstr[max_equal] = '\0';
match_list[0] = retstr;
if (matches + 1 >= match_list_len)
- match_list = ast_realloc(match_list, (match_list_len + 1) * sizeof(char *));
+ match_list = realloc(match_list, (match_list_len + 1) * sizeof(char *));
match_list[matches + 1] = (char *) NULL;
return match_list;
Modified: team/russell/ast_malloc/config.c
URL: http://svn.digium.com/view/asterisk/team/russell/ast_malloc/config.c?rev=7654&r1=7653&r2=7654&view=diff
==============================================================================
--- team/russell/ast_malloc/config.c (original)
+++ team/russell/ast_malloc/config.c Tue Dec 27 10:28:43 2005
@@ -101,15 +101,14 @@
struct ast_variable *variable;
int length = strlen(name) + strlen(value) + 2 + sizeof(struct ast_variable);
-
- variable = ast_calloc(1, length);
- if (!variable)
- return NULL;
-
- variable->name = variable->stuff;
- variable->value = variable->stuff + strlen(name) + 1;
- strcpy(variable->name,name);
- strcpy(variable->value,value);
+ variable = malloc(length);
+ if (variable) {
+ memset(variable, 0, length);
+ variable->name = variable->stuff;
+ variable->value = variable->stuff + strlen(name) + 1;
+ strcpy(variable->name,name);
+ strcpy(variable->value,value);
+ }
return variable;
}
@@ -202,11 +201,11 @@
{
struct ast_category *category;
- category = ast_calloc(1, sizeof(struct ast_category));
- if (!category)
- return NULL;
-
- ast_copy_string(category->name, name, sizeof(category->name));
+ category = malloc(sizeof(struct ast_category));
+ if (category) {
+ memset(category, 0, sizeof(struct ast_category));
+ ast_copy_string(category->name, name, sizeof(category->name));
+ }
return category;
}
@@ -328,9 +327,11 @@
{
struct ast_config *config;
- config = ast_calloc(1, sizeof(*config));
- if (config)
+ config = malloc(sizeof(*config));
+ if (config) {
+ memset(config, 0, sizeof(*config));
config->max_include_level = MAX_INCLUDE_LEVEL;
+ }
return config;
}
@@ -765,11 +766,12 @@
length += strlen(database) + 1;
if (table)
length += strlen(table) + 1;
-
- map = ast_calloc(1, length);
+ map = malloc(length);
+
if (!map)
return -1;
+ memset(map, 0, length);
map->name = map->stuff;
strcpy(map->name, name);
map->driver = map->name + strlen(map->name) + 1;
Modified: team/russell/ast_malloc/db.c
URL: http://svn.digium.com/view/asterisk/team/russell/ast_malloc/db.c?rev=7654&r1=7653&r2=7654&view=diff
==============================================================================
--- team/russell/ast_malloc/db.c (original)
+++ team/russell/ast_malloc/db.c Tue Dec 27 10:28:43 2005
@@ -438,7 +438,7 @@
values = "<bad value>";
}
if (keymatch(keys, prefix)) {
- cur = ast_calloc(1, sizeof(struct ast_db_entry) + strlen(keys) + strlen(values) + 2);
+ cur = malloc(sizeof(struct ast_db_entry) + strlen(keys) + strlen(values) + 2);
if (cur) {
cur->next = NULL;
cur->key = cur->data + strlen(values) + 1;
Modified: team/russell/ast_malloc/devicestate.c
URL: http://svn.digium.com/view/asterisk/team/russell/ast_malloc/devicestate.c?rev=7654&r1=7653&r2=7654&view=diff
==============================================================================
--- team/russell/ast_malloc/devicestate.c (original)
+++ team/russell/ast_malloc/devicestate.c Tue Dec 27 10:28:43 2005
@@ -145,7 +145,7 @@
if (!callback)
return -1;
- devcb = ast_calloc(1, sizeof(*devcb));
+ devcb = calloc(1, sizeof(*devcb));
if (!devcb)
return -1;
@@ -204,7 +204,7 @@
if (tmp)
*tmp = '\0';
if (change_thread != AST_PTHREADT_NULL)
- change = ast_calloc(1, sizeof(*change) + strlen(device));
+ change = calloc(1, sizeof(*change) + strlen(device));
if (!change) {
/* we could not allocate a change struct, or */
Modified: team/russell/ast_malloc/dnsmgr.c
URL: http://svn.digium.com/view/asterisk/team/russell/ast_malloc/dnsmgr.c?rev=7654&r1=7653&r2=7654&view=diff
==============================================================================
--- team/russell/ast_malloc/dnsmgr.c (original)
+++ team/russell/ast_malloc/dnsmgr.c Tue Dec 27 10:28:43 2005
@@ -85,7 +85,7 @@
if (!result || ast_strlen_zero(name))
return NULL;
- entry = ast_calloc(1, sizeof(*entry) + strlen(name));
+ entry = calloc(1, sizeof(*entry) + strlen(name));
if (!entry)
return NULL;
Modified: team/russell/ast_malloc/dsp.c
URL: http://svn.digium.com/view/asterisk/team/russell/ast_malloc/dsp.c?rev=7654&r1=7653&r2=7654&view=diff
==============================================================================
--- team/russell/ast_malloc/dsp.c (original)
+++ team/russell/ast_malloc/dsp.c Tue Dec 27 10:28:43 2005
@@ -1574,18 +1574,17 @@
{
struct ast_dsp *dsp;
- dsp = ast_calloc(1, sizeof(struct ast_dsp));
- if (!dsp)
- return NULL;
-
- dsp->threshold = DEFAULT_THRESHOLD;
- dsp->features = DSP_FEATURE_SILENCE_SUPPRESS;
- dsp->busycount = DSP_HISTORY;
- /* Initialize DTMF detector */
- ast_dtmf_detect_init(&dsp->td.dtmf);
- /* Initialize initial DSP progress detect parameters */
- ast_dsp_prog_reset(dsp);
-
+ dsp = malloc(sizeof(struct ast_dsp));
+ if (dsp) {
+ memset(dsp, 0, sizeof(struct ast_dsp));
+ dsp->threshold = DEFAULT_THRESHOLD;
+ dsp->features = DSP_FEATURE_SILENCE_SUPPRESS;
+ dsp->busycount = DSP_HISTORY;
+ /* Initialize DTMF detector */
+ ast_dtmf_detect_init(&dsp->td.dtmf);
+ /* Initialize initial DSP progress detect parameters */
+ ast_dsp_prog_reset(dsp);
+ }
return dsp;
}
Modified: team/russell/ast_malloc/enum.c
URL: http://svn.digium.com/view/asterisk/team/russell/ast_malloc/enum.c?rev=7654&r1=7653&r2=7654&view=diff
==============================================================================
--- team/russell/ast_malloc/enum.c (original)
+++ team/russell/ast_malloc/enum.c Tue Dec 27 10:28:43 2005
@@ -358,7 +358,7 @@
c->position++;
snprintf(c->dst, c->dstlen, "%d", c->position);
} else {
- p = ast_realloc(c->naptr_rrs, sizeof(struct enum_naptr_rr)*(c->naptr_rrs_count+1));
+ p = realloc(c->naptr_rrs, sizeof(struct enum_naptr_rr)*(c->naptr_rrs_count+1));
if (p) {
c->naptr_rrs = (struct enum_naptr_rr*)p;
memcpy(&c->naptr_rrs[c->naptr_rrs_count].naptr, answer, sizeof(struct naptr));
@@ -610,12 +610,11 @@
{
struct enum_search *tmp;
- tmp = ast_calloc(1, sizeof(struct enum_search));
- if (!tmp)
- return NULL;
-
- ast_copy_string(tmp->toplev, s, sizeof(tmp->toplev));
-
+ tmp = malloc(sizeof(struct enum_search));
+ if (tmp) {
+ memset(tmp, 0, sizeof(struct enum_search));
+ ast_copy_string(tmp->toplev, s, sizeof(tmp->toplev));
+ }
return tmp;
}
Modified: team/russell/ast_malloc/file.c
URL: http://svn.digium.com/view/asterisk/team/russell/ast_malloc/file.c?rev=7654&r1=7653&r2=7654&view=diff
==============================================================================
--- team/russell/ast_malloc/file.c (original)
+++ team/russell/ast_malloc/file.c Tue Dec 27 10:28:43 2005
@@ -127,8 +127,9 @@
}
tmp = tmp->next;
}
- tmp = ast_calloc(1, sizeof(struct ast_format));
+ tmp = malloc(sizeof(struct ast_format));
if (!tmp) {
+ ast_log(LOG_WARNING, "Out of memory\n");
ast_mutex_unlock(&formatlock);
return -1;
}
@@ -149,7 +150,6 @@
ast_mutex_unlock(&formatlock);
if (option_verbose > 1)
ast_verbose( VERBOSE_PREFIX_2 "Registered file format %s, extension(s) %s\n", name, exts);
-
return 0;
}
@@ -306,7 +306,7 @@
if (filename[0] == '/') {
fnsize = strlen(filename) + strlen(type) + 2;
- fn = ast_malloc(fnsize);
+ fn = malloc(fnsize);
if (fn)
snprintf(fn, fnsize, "%s.%s", filename, type);
} else {
@@ -314,7 +314,7 @@
snprintf(tmp, sizeof(tmp), "%s/%s", ast_config_AST_VAR_DIR, "sounds");
fnsize = strlen(tmp) + strlen(filename) + strlen(type) + 3;
- fn = ast_malloc(fnsize);
+ fn = malloc(fnsize);
if (fn)
snprintf(fn, fnsize, "%s/%s.%s", tmp, filename, type);
}
Modified: team/russell/ast_malloc/frame.c
URL: http://svn.digium.com/view/asterisk/team/russell/ast_malloc/frame.c?rev=7654&r1=7653&r2=7654&view=diff
==============================================================================
--- team/russell/ast_malloc/frame.c (original)
+++ team/russell/ast_malloc/frame.c Tue Dec 27 10:28:43 2005
@@ -118,7 +118,7 @@
struct ast_smoother *s;
if (size < 1)
return NULL;
- s = ast_malloc(sizeof(struct ast_smoother));
+ s = malloc(sizeof(struct ast_smoother));
if (s)
ast_smoother_reset(s, size);
return s;
@@ -248,8 +248,9 @@
static struct ast_frame *ast_frame_header_new(void)
{
struct ast_frame *f;
-
- f = ast_calloc(1, sizeof(struct ast_frame));
+ f = malloc(sizeof(struct ast_frame));
+ if (f)
+ memset(f, 0, sizeof(struct ast_frame));
#ifdef TRACE_FRAMES
if (f) {
headers++;
@@ -357,7 +358,7 @@
srclen = strlen(f->src);
if (srclen > 0)
len += srclen + 1;
- buf = ast_malloc(len);
+ buf = malloc(len);
if (!buf)
return NULL;
out = buf;
Modified: team/russell/ast_malloc/indications.c
URL: http://svn.digium.com/view/asterisk/team/russell/ast_malloc/indications.c?rev=7654&r1=7653&r2=7654&view=diff
==============================================================================
--- team/russell/ast_malloc/indications.c (original)
+++ team/russell/ast_malloc/indications.c Tue Dec 27 10:28:43 2005
@@ -113,12 +113,10 @@
static void * playtones_alloc(struct ast_channel *chan, void *params)
{
struct playtones_def *pd = params;
- struct playtones_state *ps;
-
- ps = ast_calloc(1, sizeof(struct playtones_state));
+ struct playtones_state *ps = malloc(sizeof(struct playtones_state));
if (!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);
@@ -302,7 +300,7 @@
freq2 = 0;
}
- d.items = ast_realloc(d.items,(d.nitems+1)*sizeof(struct playtones_item));
+ d.items = realloc(d.items,(d.nitems+1)*sizeof(struct playtones_item));
if (d.items == NULL) {
ast_log(LOG_WARNING, "Realloc failed!\n");
return -1;
@@ -549,8 +547,9 @@
}
if (!ts) {
/* not there, we have to add */
- ts = ast_calloc(1, sizeof(struct tone_zone_sound));
+ ts = malloc(sizeof(struct tone_zone_sound));
if (!ts) {
+ ast_log(LOG_WARNING, "Out of memory\n");
ast_mutex_unlock(&tzlock);
return -2;
}
More information about the svn-commits
mailing list