[asterisk-commits] rmudgett: trunk r399503 - in /trunk: ./ main/optional_api.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Sep 19 18:20:45 CDT 2013


Author: rmudgett
Date: Thu Sep 19 18:20:43 2013
New Revision: 399503

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=399503
Log:
optional_api: Make always use the standard malloc functions even with MALLOC_DEBUG.
........

Merged revisions 399501 from http://svn.asterisk.org/svn/asterisk/branches/12

Modified:
    trunk/   (props changed)
    trunk/main/optional_api.c

Propchange: trunk/
------------------------------------------------------------------------------
--- branch-12-merged (original)
+++ branch-12-merged Thu Sep 19 18:20:43 2013
@@ -1,1 +1,1 @@
-/branches/12:1-398558,398560-398577,398579-399100,399136,399146,399160,399197,399207,399225,399237,399247,399257,399268,399283,399294,399339,399365,399376,399404,399458
+/branches/12:1-398558,398560-398577,398579-399100,399136,399146,399160,399197,399207,399225,399237,399247,399257,399268,399283,399294,399339,399365,399376,399404,399458,399501

Modified: trunk/main/optional_api.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/optional_api.c?view=diff&rev=399503&r1=399502&r2=399503
==============================================================================
--- trunk/main/optional_api.c (original)
+++ trunk/main/optional_api.c Thu Sep 19 18:20:43 2013
@@ -76,7 +76,7 @@
 static void optional_api_user_destroy(struct optional_api_user *user)
 {
 	*user->optional_ref = user->stub;
-	free(user);
+	ast_std_free(user);
 }
 
 /*!
@@ -95,7 +95,7 @@
 	struct optional_api_user *user;
 	size_t size = sizeof(*user) + strlen(module) + 1;
 
-	user = calloc(1, size);
+	user = ast_std_calloc(1, size);
 	if (!user) {
 		return NULL;
 	}
@@ -117,10 +117,10 @@
 	while (api->users_len--) {
 		optional_api_user_destroy(api->users[api->users_len]);
 	}
-	free(api->users);
+	ast_std_free(api->users);
 	api->users = NULL;
 	api->users_maxlen = 0;
-	free(api);
+	ast_std_free(api);
 }
 
 /*!
@@ -137,7 +137,7 @@
 
 	ast_verb(6, "%s: building api object\n", symname);
 	size = sizeof(*api) + strlen(symname) + 1;
-	api = calloc(1, size);
+	api = ast_std_calloc(1, size);
 	if (!api) {
 		ast_log(LOG_ERROR, "Failed to allocate api\n");
 		return NULL;
@@ -181,13 +181,16 @@
 
 	/* API not found. Build one */
 	api = optional_api_create(symname);
+	if (!api) {
+		return NULL;
+	}
 
 	/* Grow the list, if needed */
 	if (apis.len + 1 > apis.maxlen) {
 		size_t new_maxlen = apis.maxlen ? 2 * apis.maxlen : 1;
-		struct optional_api **new_list =
-			realloc(apis.list, new_maxlen * sizeof(*new_list));
-
+		struct optional_api **new_list;
+
+		new_list = ast_std_realloc(apis.list, new_maxlen * sizeof(*new_list));
 		if (!new_list) {
 			optional_api_destroy(api);
 			ast_log(LOG_ERROR, "Failed to allocate api list\n");
@@ -300,11 +303,10 @@
 
 	/* Add user to the API */
 	if (api->users_len + 1 > api->users_maxlen) {
-		size_t new_maxlen = api->users_maxlen ?
-			2 * api->users_maxlen : 1;
-		struct optional_api_user **new_list =
-			realloc(api->users, new_maxlen * sizeof(*new_list));
-
+		size_t new_maxlen = api->users_maxlen ? 2 * api->users_maxlen : 1;
+		struct optional_api_user **new_list;
+
+		new_list = ast_std_realloc(api->users, new_maxlen * sizeof(*new_list));
 		if (!new_list) {
 			optional_api_user_destroy(user);
 			ast_log(LOG_ERROR, "Failed to allocate api list\n");
@@ -336,6 +338,7 @@
 
 	for (i = 0; i < api->users_len; ++i) {
 		struct optional_api_user *user = api->users[i];
+
 		if (user->optional_ref == optional_ref) {
 			if (*user->optional_ref != user->stub) {
 				ast_verb(4, "%s: stubbing for %s\n", symname,




More information about the asterisk-commits mailing list