mirror of
https://github.com/asterisk/asterisk.git
synced 2025-11-17 15:29:05 +00:00
Merged revisions 79947 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r79947 | tilghman | 2007-08-18 09:30:44 -0500 (Sat, 18 Aug 2007) | 3 lines Don't allocate vmu for messagecount when we could just use the stack instead (closes issue #10490) Also, remove a useless (and leaky) SQLAllocHandle (closes issue #10480) ........ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@79949 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -2383,12 +2383,6 @@ static int inboxcount(const char *mailbox, int *newmsgs, int *oldmsgs)
|
||||
*newmsgs = atoi(rowdata);
|
||||
SQLFreeHandle (SQL_HANDLE_STMT, stmt);
|
||||
|
||||
res = SQLAllocHandle(SQL_HANDLE_STMT, obj->con, &stmt);
|
||||
if ((res != SQL_SUCCESS) && (res != SQL_SUCCESS_WITH_INFO)) {
|
||||
ast_log(LOG_WARNING, "SQL Alloc Handle failed!\n");
|
||||
ast_odbc_release_obj(obj);
|
||||
goto yuck;
|
||||
}
|
||||
snprintf(sql, sizeof(sql), "SELECT COUNT(*) FROM %s WHERE dir = '%s%s/%s/%s'", odbc_table, VM_SPOOL_DIR, context, tmp, "Old");
|
||||
stmt = ast_odbc_prepare_and_execute(obj, generic_prepare, &gps);
|
||||
if (!stmt) {
|
||||
@@ -2556,7 +2550,7 @@ static int messagecount(const char *context, const char *mailbox, const char *fo
|
||||
SEARCHPGM *pgm;
|
||||
SEARCHHEADER *hdr;
|
||||
|
||||
struct ast_vm_user *vmu;
|
||||
struct ast_vm_user *vmu, vmus;
|
||||
struct vm_state *vms_p;
|
||||
int ret = 0;
|
||||
int fold = folder_int(folder);
|
||||
@@ -2566,10 +2560,16 @@ static int messagecount(const char *context, const char *mailbox, const char *fo
|
||||
|
||||
/* We have to get the user before we can open the stream! */
|
||||
/* ast_log (LOG_DEBUG,"Before find_user, context is %s and mailbox is %s\n",context,mailbox); */
|
||||
vmu = find_user(NULL, context, mailbox);
|
||||
vmu = find_user(&vmus, context, mailbox);
|
||||
if (!vmu) {
|
||||
ast_log (LOG_ERROR,"Couldn't find mailbox %s in context %s\n",mailbox,context);
|
||||
return -1;
|
||||
} else {
|
||||
/* No IMAP account available */
|
||||
if (vmu->imapuser[0] == '\0') {
|
||||
ast_log (LOG_WARNING,"IMAP user not set for mailbox %s\n",vmu->mailbox);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/* No IMAP account available */
|
||||
@@ -2587,11 +2587,9 @@ static int messagecount(const char *context, const char *mailbox, const char *fo
|
||||
if (vms_p) {
|
||||
ast_debug(3, "Returning before search - user is logged in\n");
|
||||
if(fold == 0) {/*INBOX*/
|
||||
free_user(vmu);
|
||||
return vms_p->newmessages;
|
||||
}
|
||||
if(fold == 1) {/*Old messages*/
|
||||
free_user(vmu);
|
||||
return vms_p->oldmessages;
|
||||
}
|
||||
}
|
||||
@@ -2605,7 +2603,6 @@ static int messagecount(const char *context, const char *mailbox, const char *fo
|
||||
if (!vms_p) {
|
||||
ast_debug(3,"Adding new vmstate for %s\n",vmu->imapuser);
|
||||
if (!(vms_p = ast_calloc(1, sizeof(*vms_p)))) {
|
||||
free_user(vmu);
|
||||
return -1;
|
||||
}
|
||||
ast_copy_string(vms_p->imapuser,vmu->imapuser, sizeof(vms_p->imapuser));
|
||||
@@ -2621,7 +2618,6 @@ static int messagecount(const char *context, const char *mailbox, const char *fo
|
||||
ret = init_mailstream(vms_p, fold);
|
||||
if (!vms_p->mailstream) {
|
||||
ast_log (LOG_ERROR,"Houston we have a problem - IMAP mailstream is NULL\n");
|
||||
free_user(vmu);
|
||||
return -1;
|
||||
}
|
||||
if (ret == 0) {
|
||||
@@ -2650,13 +2646,11 @@ static int messagecount(const char *context, const char *mailbox, const char *fo
|
||||
vms_p->oldmessages = vms_p->vmArrayIndex;
|
||||
/*Freeing the searchpgm also frees the searchhdr*/
|
||||
mail_free_searchpgm(&pgm);
|
||||
free_user(vmu);
|
||||
vms_p->updated = 0;
|
||||
return vms_p->vmArrayIndex;
|
||||
} else {
|
||||
mail_ping(vms_p->mailstream);
|
||||
}
|
||||
free_user(vmu);
|
||||
return 0;
|
||||
}
|
||||
static int inboxcount(const char *mailbox_context, int *newmsgs, int *oldmsgs)
|
||||
|
||||
Reference in New Issue
Block a user