[asterisk-commits] qwell: branch 1.4 r49742 - in /branches/1.4: main/ pbx/ res/

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Fri Jan 5 17:24:39 MST 2007


Author: qwell
Date: Fri Jan  5 18:24:38 2007
New Revision: 49742

URL: http://svn.digium.com/view/asterisk?view=rev&rev=49742
Log:
Save 1 whopping byte of allocated memory!

This looks like it may have been a chicken/egg scenario..

You had to call a cleanup func, because everything was allocated.
Then since you had to call a cleanup func, you were forced to allocate - ie; strdup("").

Modified:
    branches/1.4/main/pbx.c
    branches/1.4/pbx/pbx_config.c
    branches/1.4/res/res_features.c

Modified: branches/1.4/main/pbx.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/main/pbx.c?view=diff&rev=49742&r1=49741&r2=49742
==============================================================================
--- branches/1.4/main/pbx.c (original)
+++ branches/1.4/main/pbx.c Fri Jan  5 18:24:38 2007
@@ -4591,10 +4591,6 @@
 	return count;
 }
 
-static void null_datad(void *foo)
-{
-}
-
 /*! \brief add the extension in the priority chain.
  * returns 0 on success, -1 on failure
  */
@@ -4616,7 +4612,8 @@
 		   replacement?  If so, replace, otherwise, bonk. */
 		if (!replace) {
 			ast_log(LOG_WARNING, "Unable to register extension '%s', priority %d in '%s', already in use\n", tmp->exten, tmp->priority, con->name);
-			tmp->datad(tmp->data);
+			if (tmp->datad)
+				tmp->datad(tmp->data);
 			free(tmp);
 			return -1;
 		}
@@ -4634,7 +4631,8 @@
 		if (tmp->priority == PRIORITY_HINT)
 			ast_change_hint(e,tmp);
 		/* Destroy the old one */
-		e->datad(e->data);
+		if (e->datad)
+			e->datad(e->data);
 		free(e);
 	} else {	/* Slip ourselves in just before e */
 		tmp->peer = e;
@@ -4718,8 +4716,6 @@
 		length ++;	/* just the '\0' */
 
 	/* Be optimistic:  Build the extension structure first */
-	if (datad == NULL)
-		datad = null_datad;
 	if (!(tmp = ast_calloc(1, length)))
 		return -1;
 

Modified: branches/1.4/pbx/pbx_config.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/pbx/pbx_config.c?view=diff&rev=49742&r1=49741&r2=49742
==============================================================================
--- branches/1.4/pbx/pbx_config.c (original)
+++ branches/1.4/pbx/pbx_config.c Fri Jan  5 18:24:38 2007
@@ -2409,7 +2409,7 @@
 		}
 		if (!ast_strlen_zero(iface)) {
 			/* Add hint */
-			ast_add_extension2(con, 0, cat, -1, NULL, NULL, iface, strdup(""), ast_free, registrar);
+			ast_add_extension2(con, 0, cat, -1, NULL, NULL, iface, NULL, NULL, registrar);
 			/* If voicemail, use "stdexten" else use plain old dial */
 			if (hasvoicemail) {
 				snprintf(tmp, sizeof(tmp), "stdexten|%s|${HINT}", cat);

Modified: branches/1.4/res/res_features.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/res/res_features.c?view=diff&rev=49742&r1=49741&r2=49742
==============================================================================
--- branches/1.4/res/res_features.c (original)
+++ branches/1.4/res/res_features.c Fri Jan  5 18:24:38 2007
@@ -2277,7 +2277,7 @@
 		ast_log(LOG_ERROR, "Parking context '%s' does not exist and unable to create\n", parking_con);
 		return -1;
 	}
-	res = ast_add_extension2(con, 1, ast_parking_ext(), 1, NULL, NULL, parkcall, strdup(""), ast_free, registrar);
+	res = ast_add_extension2(con, 1, ast_parking_ext(), 1, NULL, NULL, parkcall, NULL, NULL, registrar);
 	if (parkaddhints)
 		park_add_hints(parking_con, parking_start, parking_stop);
 	if (!res)



More information about the asterisk-commits mailing list