[asterisk-commits] trunk - r7991 /trunk/apps/

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Wed Jan 11 16:41:40 CST 2006


Author: russell
Date: Wed Jan 11 16:41:34 2006
New Revision: 7991

URL: http://svn.digium.com/view/asterisk?rev=7991&view=rev
Log:
conversions to memory allocation wrappers (issue #6210)

Modified:
    trunk/apps/app_alarmreceiver.c
    trunk/apps/app_curl.c
    trunk/apps/app_dial.c
    trunk/apps/app_directory.c
    trunk/apps/app_externalivr.c

Modified: trunk/apps/app_alarmreceiver.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_alarmreceiver.c?rev=7991&r1=7990&r2=7991&view=diff
==============================================================================
--- trunk/apps/app_alarmreceiver.c (original)
+++ trunk/apps/app_alarmreceiver.c Wed Jan 11 16:41:34 2006
@@ -56,6 +56,7 @@
 #include "asterisk/localtime.h"
 #include "asterisk/callerid.h"
 #include "asterisk/astdb.h"
+#include "asterisk/utils.h"
 
 #define ALMRCV_CONFIG "alarmreceiver.conf"
 #define ADEMCO_CONTACT_ID "ADEMCO_CONTACT_ID"
@@ -579,17 +580,11 @@
 
 		events_received++;
 		
-		/* Queue the Event */
-
-		if((enew = malloc(sizeof(event_node_t))) == NULL){
-			if(option_verbose >= 1)
-				ast_verbose(VERBOSE_PREFIX_1 "AlarmReceiver: Failed to allocate memory\n");
-			ast_log(LOG_WARNING, "AlarmReceiver Failed to allocate memory\n");
+		/* Queue the Event */		
+		if (!(enew = ast_calloc(1, sizeof(*enew)))) {
 			res = -1;
-                        break;
-		}
-
-		memset(enew, 0, sizeof(event_node_t));
+			break;
+		}
 		
 		enew->next = NULL;
 		ast_copy_string(enew->data, event, sizeof(enew->data));

Modified: trunk/apps/app_curl.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_curl.c?rev=7991&r1=7990&r2=7991&view=diff
==============================================================================
--- trunk/apps/app_curl.c (original)
+++ trunk/apps/app_curl.c Wed Jan 11 16:41:34 2006
@@ -46,6 +46,7 @@
 #include "asterisk/options.h"
 #include "asterisk/module.h"
 #include "asterisk/app.h"
+#include "asterisk/utils.h"
 
 static char *tdesc = "Load external URL";
 
@@ -63,9 +64,9 @@
 	/* There might be a realloc() out there that doesn't like reallocing
 	   NULL pointers, so we take care of it here */
 	if (ptr)
-		return realloc(ptr, size);
+		return ast_realloc(ptr, size);
 	else
-		return malloc(size);
+		return ast_malloc(size);
 }
 
 static size_t WriteMemoryCallback(void *ptr, size_t size, size_t nmemb, void *data)

Modified: trunk/apps/app_dial.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_dial.c?rev=7991&r1=7990&r2=7991&view=diff
==============================================================================
--- trunk/apps/app_dial.c (original)
+++ trunk/apps/app_dial.c Wed Jan 11 16:41:34 2006
@@ -984,13 +984,10 @@
 			goto out;
 		}
 		*number = '\0';
-		number++;
-		tmp = malloc(sizeof(struct localuser));
-		if (!tmp) {
-			ast_log(LOG_WARNING, "Out of memory\n");
+		number++;		
+		if (!(tmp = ast_calloc(1, sizeof(*tmp)))) {
 			goto out;
 		}
-		memset(tmp, 0, sizeof(struct localuser));
 		if (opts.flags) {
 			ast_copy_flags(tmp, &opts,
 				       OPT_CALLEE_TRANSFER | OPT_CALLER_TRANSFER |

Modified: trunk/apps/app_directory.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_directory.c?rev=7991&r1=7990&r2=7991&view=diff
==============================================================================
--- trunk/apps/app_directory.c (original)
+++ trunk/apps/app_directory.c Wed Jan 11 16:41:34 2006
@@ -84,7 +84,7 @@
 {
 	char *tmp;
 	int lcount = 0;
-	tmp = malloc(NUMDIGITS + 1);
+	tmp = ast_malloc(NUMDIGITS + 1);
 	if (tmp) {
 		while((*lastname > 32) && lcount < NUMDIGITS) {
 			switch(toupper(*lastname)) {

Modified: trunk/apps/app_externalivr.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_externalivr.c?rev=7991&r1=7990&r2=7991&view=diff
==============================================================================
--- trunk/apps/app_externalivr.c (original)
+++ trunk/apps/app_externalivr.c Wed Jan 11 16:41:34 2006
@@ -49,6 +49,7 @@
 #include "asterisk/module.h"
 #include "asterisk/linkedlists.h"
 #include "asterisk/app.h"
+#include "asterisk/utils.h"
 
 static const char *tdesc = "External IVR Interface Application";
 
@@ -112,10 +113,8 @@
 {
 	struct localuser *u = params;
 	struct gen_state *state;
-
-	state = calloc(1, sizeof(*state));
-
-	if (!state)
+	
+	if (!(state = ast_calloc(1, sizeof(*state))))
 		return NULL;
 
 	state->u = u;
@@ -234,10 +233,8 @@
 static struct playlist_entry *make_entry(const char *filename)
 {
 	struct playlist_entry *entry;
-
-	entry = calloc(1, sizeof(*entry) + strlen(filename) + 10);
-
-	if (!entry)
+	
+	if (!(entry = ast_calloc(1, sizeof(*entry) + strlen(filename) + 10)))
 		return NULL;
 
 	strcpy(entry->filename, filename);



More information about the asterisk-commits mailing list