Get rid of a needless memory allocation and only create a conference structure in find_conf_realtime if data was read from realtime. (issue #8669 reported by robl)

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@48966 65c4cc65-6c06-0410-ace0-fbb531ad65f3
1.4
Joshua Colp 19 years ago
parent 9cc04e026d
commit c4bde5b40a

@ -1961,25 +1961,21 @@ static struct ast_conference *find_conf_realtime(struct ast_channel *chan, char
if (!strcmp(confno, cnf->confno)) if (!strcmp(confno, cnf->confno))
break; break;
} }
if (cnf){ if (cnf) {
cnf->refcount += refcount; cnf->refcount += refcount;
} }
AST_LIST_UNLOCK(&confs); AST_LIST_UNLOCK(&confs);
if (!cnf) { if (!cnf) {
char *pin = NULL, *pinadmin = NULL; /* For temp use */ char *pin = NULL, *pinadmin = NULL; /* For temp use */
var = ast_load_realtime("meetme", "confno", confno, NULL);
cnf = ast_calloc(1, sizeof(struct ast_conference)); if (!var)
if (!cnf) {
ast_log(LOG_ERROR, "Out of memory\n");
return NULL; return NULL;
}
var = ast_load_realtime("meetme", "confno", confno, NULL);
while (var) { while (var) {
if (!strcasecmp(var->name, "confno")) { if (!strcasecmp(var->name, "pin")) {
ast_copy_string(cnf->confno, var->value, sizeof(cnf->confno));
} else if (!strcasecmp(var->name, "pin")) {
pin = ast_strdupa(var->value); pin = ast_strdupa(var->value);
} else if (!strcasecmp(var->name, "adminpin")) { } else if (!strcasecmp(var->name, "adminpin")) {
pinadmin = ast_strdupa(var->value); pinadmin = ast_strdupa(var->value);
@ -1987,7 +1983,7 @@ static struct ast_conference *find_conf_realtime(struct ast_channel *chan, char
var = var->next; var = var->next;
} }
ast_variables_destroy(var); ast_variables_destroy(var);
cnf = build_conf(confno, pin ? pin : "", pinadmin ? pinadmin : "", make, dynamic, refcount); cnf = build_conf(confno, pin ? pin : "", pinadmin ? pinadmin : "", make, dynamic, refcount);
} }

Loading…
Cancel
Save