[svn-commits] russell: trunk r38108 - /trunk/cli.c

svn-commits at lists.digium.com svn-commits at lists.digium.com
Sat Jul 22 21:58:57 MST 2006


Author: russell
Date: Sat Jul 22 23:58:56 2006
New Revision: 38108

URL: http://svn.digium.com/view/asterisk?rev=38108&view=rev
Log:
take the advice of an XXX comment and use an atomic operation to decrement a
variable.  Also, change a use of strdup to ast_strdup and remove a duplicated
error message.

Modified:
    trunk/cli.c

Modified: trunk/cli.c
URL: http://svn.digium.com/view/asterisk/trunk/cli.c?rev=38108&r1=38107&r2=38108&view=diff
==============================================================================
--- trunk/cli.c (original)
+++ trunk/cli.c Sat Jul 22 23:58:56 2006
@@ -1177,7 +1177,7 @@
 	if (s == NULL)	/* invalid, though! */
 		return NULL;
 	/* make a copy to store the parsed string */
-	if (!(dup = strdup(s)))
+	if (!(dup = ast_strdup(s)))
 		return NULL;
 
 	cur = dup;
@@ -1350,10 +1350,8 @@
 	char *dup;
 	int tws;
 	
-	if (!(dup = parse_args(s, &x, argv, sizeof(argv) / sizeof(argv[0]), &tws))) {
-		ast_log(LOG_ERROR, "Memory allocation failure\n");
+	if (!(dup = parse_args(s, &x, argv, sizeof(argv) / sizeof(argv[0]), &tws)))
 		return -1;
-	}
 
 	/* We need at least one entry, or ignore */
 	if (x > 0) {
@@ -1373,11 +1371,8 @@
 			}
 		} else 
 			ast_cli(fd, "No such command '%s' (type 'help' for help)\n", find_best(argv));
-		if (e) {
-			AST_LIST_LOCK(&helpers);
-			e->inuse--;	/* XXX here an atomic dec would suffice */
-			AST_LIST_UNLOCK(&helpers);
-		}
+		if (e)
+			ast_atomic_fetchadd_int(&e->inuse, -1);
 	}
 	free(dup);
 	



More information about the svn-commits mailing list