[svn-commits] trunk - r8009 /trunk/apps/app_voicemail.c

svn-commits at lists.digium.com svn-commits at lists.digium.com
Thu Jan 12 09:51:14 CST 2006


Author: bweschke
Date: Thu Jan 12 09:51:13 2006
New Revision: 8009

URL: http://svn.digium.com/view/asterisk?rev=8009&view=rev
Log:
 New memory wrapper changes.


Modified:
    trunk/apps/app_voicemail.c

Modified: trunk/apps/app_voicemail.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_voicemail.c?rev=8009&r1=8008&r2=8009&view=diff
==============================================================================
--- trunk/apps/app_voicemail.c (original)
+++ trunk/apps/app_voicemail.c Thu Jan 12 09:51:13 2006
@@ -533,12 +533,13 @@
 	if (ivm)
 		retval=ivm;
 	else
-		retval=malloc(sizeof(struct ast_vm_user));
+		retval=ast_calloc(1, sizeof(*retval));
 
 	if (retval) {
-		memset(retval, 0, sizeof(struct ast_vm_user));
 		if (!ivm)
 			ast_set_flag(retval, VM_ALLOCED);	
+		else
+			memset(retval, 0, sizeof(*retval));
 		if (mailbox) 
 			ast_copy_string(retval->mailbox, mailbox, sizeof(retval->mailbox));
 		populate_defaults(retval);
@@ -597,9 +598,9 @@
 			vmu = ivm;
 		else
 			/* Make a copy, so that on a reload, we have no race */
-			vmu = malloc(sizeof(struct ast_vm_user));
+			vmu = ast_malloc(sizeof(*vmu));
 		if (vmu) {
-			memcpy(vmu, cur, sizeof(struct ast_vm_user));
+			memcpy(vmu, cur, sizeof(*vmu));
 			ast_set2_flag(vmu, !ivm, VM_ALLOCED);	
 			vmu->next = NULL;
 		}
@@ -3418,7 +3419,7 @@
 		/* start optimistic */
 		valid_extensions = 1;
 		while (s) {
-			/* find_user is going to malloc since we have a NULL as first argument */
+			/* find_user is going to ast_malloc since we have a NULL as first argument */
 			if ((receiver = find_user(NULL, context, s))) {
 				if (!extensions)
 					vmtmp = extensions = receiver;
@@ -5585,9 +5586,8 @@
 	struct ast_vm_user *vmu;
 
 	ast_copy_string(tmp, data, sizeof(tmp));
-	vmu = malloc(sizeof(struct ast_vm_user));
+	vmu = ast_calloc(1, sizeof(*vmu));
 	if (vmu) {
-		memset(vmu, 0, sizeof(struct ast_vm_user));
 		ast_copy_string(vmu->context, context, sizeof(vmu->context));
 		ast_copy_string(vmu->mailbox, mbox, sizeof(vmu->mailbox));
 
@@ -6123,7 +6123,7 @@
 					/* Timezones in this context */
 					while (var) {
 						struct vm_zone *z;
-						z = malloc(sizeof(struct vm_zone));
+						z = ast_malloc(sizeof(*z));
 						if (z != NULL) {
 							char *msg_format, *timezone;
 							msg_format = ast_strdupa(var->value);



More information about the svn-commits mailing list