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
This commit is contained in:
parent
4bc06f4114
commit
b1b9a78505
|
@ -420,7 +420,6 @@ struct vm_state {
|
||||||
char curdir[PATH_MAX];
|
char curdir[PATH_MAX];
|
||||||
char vmbox[PATH_MAX];
|
char vmbox[PATH_MAX];
|
||||||
char fn[PATH_MAX];
|
char fn[PATH_MAX];
|
||||||
char fn2[PATH_MAX];
|
|
||||||
char intro[PATH_MAX];
|
char intro[PATH_MAX];
|
||||||
int *deleted;
|
int *deleted;
|
||||||
int *heard;
|
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)
|
else if (vms->curmsg == vms->lastmsg)
|
||||||
res = wait_file2(chan, vms, "vm-last"); /* "last" */
|
res = wait_file2(chan, vms, "vm-last"); /* "last" */
|
||||||
|
|
||||||
/* Retrieve info from VM attribute file earlier, to get flag info */
|
snprintf(filename, sizeof(filename), "%s.txt", vms->fn);
|
||||||
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);
|
RETRIEVE(vms->curdir, vms->curmsg, vmu->mailbox, vmu->context);
|
||||||
msg_cfg = ast_config_load(filename, config_flags);
|
msg_cfg = ast_config_load(filename, config_flags);
|
||||||
if (!msg_cfg) {
|
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);
|
RETRIEVE(vms->curdir, vms->curmsg, vmu->mailbox, vmu->context);
|
||||||
msg_cfg = ast_config_load(filename, config_flags);
|
msg_cfg = ast_config_load(filename, config_flags);
|
||||||
if (!msg_cfg) {
|
if (!msg_cfg) {
|
||||||
|
@ -6249,6 +6243,7 @@ static int close_mailbox(struct vm_state *vms, struct ast_vm_user *vmu)
|
||||||
int x = 0;
|
int x = 0;
|
||||||
#ifndef IMAP_STORAGE
|
#ifndef IMAP_STORAGE
|
||||||
int res = 0, nummsg;
|
int res = 0, nummsg;
|
||||||
|
char fn2[PATH_MAX];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (vms->lastmsg <= -1)
|
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))
|
if (!EXISTS(vms->curdir, x, vms->fn, NULL))
|
||||||
break;
|
break;
|
||||||
vms->curmsg++;
|
vms->curmsg++;
|
||||||
make_file(vms->fn2, sizeof(vms->fn2), vms->curdir, vms->curmsg);
|
make_file(fn2, sizeof(fn2), vms->curdir, vms->curmsg);
|
||||||
if (strcmp(vms->fn, vms->fn2)) {
|
if (strcmp(vms->fn, fn2)) {
|
||||||
RENAME(vms->curdir, x, vmu->mailbox,vmu->context, vms->curdir, vms->curmsg, vms->fn, vms->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]) {
|
} 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 */
|
/* 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 */
|
/* Add the vm_state to the active list and keep it active */
|
||||||
memset(&vms, 0, sizeof(vms));
|
memset(&vms, 0, sizeof(vms));
|
||||||
|
|
||||||
vms.lastmsg = -1;
|
vms.lastmsg = -1;
|
||||||
|
|
||||||
memset(&vmus, 0, sizeof(vmus));
|
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);
|
make_file(vms->fn, sizeof(vms->fn), vms->curdir, msg);
|
||||||
|
|
||||||
/* Retrieve info from VM attribute file */
|
/* Retrieve info from VM attribute file */
|
||||||
|
snprintf(filename,sizeof(filename), "%s.txt", vms->fn);
|
||||||
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);
|
RETRIEVE(vms->curdir, vms->curmsg, vmu->mailbox, vmu->context);
|
||||||
msg_cfg = ast_config_load(filename, config_flags);
|
msg_cfg = ast_config_load(filename, config_flags);
|
||||||
DISPOSE(vms->curdir, vms->curmsg);
|
DISPOSE(vms->curdir, vms->curmsg);
|
||||||
|
|
Reference in New Issue