aboutsummaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authormmichelson <mmichelson@f38db490-d61c-443f-a65b-d21fe96a405b>2008-07-10 20:33:13 +0000
committermmichelson <mmichelson@f38db490-d61c-443f-a65b-d21fe96a405b>2008-07-10 20:33:13 +0000
commitb1b9a7850588771d172784f5d2bf371542dc91f6 (patch)
treeca4f86ce8c8d3b5c795435ce37ef850fe4b5a07e /apps
parent4bc06f4114e32e0fa02353ac645f0827ffc26c18 (diff)
Removed the fn2 field from the vm_state structure.
fn2 was used in three functions. In every case, it was initialized in the function it was used in. This meant there was no need to have it in a malloc'd structure just taking up space. Furthermore two of the functions it was used in were completely unnecessary since fn2 was set to exactly the same value as the vm_state's fn string. fn2 was a char array sized at PATH_MAX. On my system, PATH_MAX is 4096. This equates to a 4K memory savings per vm_state allocated. Since there is a vm_state malloc'd for every voicemail user on the system, this could potentially add up nicely if there are lots of users. In addition, a vm_state is allocated on the stack each time a caller calls the VoiceMailMain application, meaning that there is a significant stack savings with this patch too. Of course, a single vm_state struct still takes up approximately 20K on my system (when using IMAP storage. Without IMAP storage, there would be about another 300 bytes fewer usage), even with this removal. Further optimizations are probably possible, but most likely not as easy as this one. git-svn-id: http://svn.digium.com/svn/asterisk/trunk@129734 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'apps')
-rw-r--r--apps/app_voicemail.c20
1 files changed, 7 insertions, 13 deletions
diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c
index 08049eee6..2d30973a3 100644
--- a/apps/app_voicemail.c
+++ b/apps/app_voicemail.c
@@ -420,7 +420,6 @@ struct vm_state {
char curdir[PATH_MAX];
char vmbox[PATH_MAX];
char fn[PATH_MAX];
- char fn2[PATH_MAX];
char intro[PATH_MAX];
int *deleted;
int *heard;
@@ -5811,9 +5810,7 @@ static int play_message(struct ast_channel *chan, struct ast_vm_user *vmu, struc
else if (vms->curmsg == vms->lastmsg)
res = wait_file2(chan, vms, "vm-last"); /* "last" */
- /* Retrieve info from VM attribute file earlier, to get flag info */
- make_file(vms->fn2, sizeof(vms->fn2), vms->curdir, vms->curmsg);
- snprintf(filename, sizeof(filename), "%s.txt", vms->fn2);
+ snprintf(filename, sizeof(filename), "%s.txt", vms->fn);
RETRIEVE(vms->curdir, vms->curmsg, vmu->mailbox, vmu->context);
msg_cfg = ast_config_load(filename, config_flags);
if (!msg_cfg) {
@@ -5864,9 +5861,6 @@ static int play_message(struct ast_channel *chan, struct ast_vm_user *vmu, struc
}
}
- /* Retrieve info from VM attribute file */
- make_file(vms->fn2, sizeof(vms->fn2), vms->curdir, vms->curmsg);
- snprintf(filename, sizeof(filename), "%s.txt", vms->fn2);
RETRIEVE(vms->curdir, vms->curmsg, vmu->mailbox, vmu->context);
msg_cfg = ast_config_load(filename, config_flags);
if (!msg_cfg) {
@@ -6249,6 +6243,7 @@ static int close_mailbox(struct vm_state *vms, struct ast_vm_user *vmu)
int x = 0;
#ifndef IMAP_STORAGE
int res = 0, nummsg;
+ char fn2[PATH_MAX];
#endif
if (vms->lastmsg <= -1)
@@ -6267,9 +6262,9 @@ static int close_mailbox(struct vm_state *vms, struct ast_vm_user *vmu)
if (!EXISTS(vms->curdir, x, vms->fn, NULL))
break;
vms->curmsg++;
- make_file(vms->fn2, sizeof(vms->fn2), vms->curdir, vms->curmsg);
- if (strcmp(vms->fn, vms->fn2)) {
- RENAME(vms->curdir, x, vmu->mailbox,vmu->context, vms->curdir, vms->curmsg, vms->fn, vms->fn2);
+ make_file(fn2, sizeof(fn2), vms->curdir, vms->curmsg);
+ if (strcmp(vms->fn, fn2)) {
+ RENAME(vms->curdir, x, vmu->mailbox,vmu->context, vms->curdir, vms->curmsg, vms->fn, fn2);
}
} else if ((!strcasecmp(vms->curbox, "INBOX") || !strcasecmp(vms->curbox, "Urgent")) && vms->heard[x] && ast_test_flag(vmu, VM_MOVEHEARD) && !vms->deleted[x]) {
/* Move to old folder before deleting */
@@ -8043,6 +8038,7 @@ static int vm_execmain(struct ast_channel *chan, void *data)
/* Add the vm_state to the active list and keep it active */
memset(&vms, 0, sizeof(vms));
+
vms.lastmsg = -1;
memset(&vmus, 0, sizeof(vmus));
@@ -10297,9 +10293,7 @@ static int advanced_options(struct ast_channel *chan, struct ast_vm_user *vmu, s
make_file(vms->fn, sizeof(vms->fn), vms->curdir, msg);
/* Retrieve info from VM attribute file */
-
- make_file(vms->fn2, sizeof(vms->fn2), vms->curdir, vms->curmsg);
- snprintf(filename,sizeof(filename), "%s.txt", vms->fn2);
+ snprintf(filename,sizeof(filename), "%s.txt", vms->fn);
RETRIEVE(vms->curdir, vms->curmsg, vmu->mailbox, vmu->context);
msg_cfg = ast_config_load(filename, config_flags);
DISPOSE(vms->curdir, vms->curmsg);