[asterisk-commits] russell: trunk r89258 - /trunk/main/image.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Nov 13 18:33:52 CST 2007


Author: russell
Date: Tue Nov 13 18:33:52 2007
New Revision: 89258

URL: http://svn.digium.com/view/asterisk?view=rev&rev=89258
Log:
- Simplify removing an item from a list
- move a verbose message to after the item is added to the list
- make use of the ARRAY_LEN macro in one spot

Modified:
    trunk/main/image.c

Modified: trunk/main/image.c
URL: http://svn.digium.com/view/asterisk/trunk/main/image.c?view=diff&rev=89258&r1=89257&r2=89258
==============================================================================
--- trunk/main/image.c (original)
+++ trunk/main/image.c Tue Nov 13 18:33:52 2007
@@ -51,27 +51,20 @@
 
 int ast_image_register(struct ast_imager *img)
 {
-	ast_verb(2, "Registered format '%s' (%s)\n", img->name, img->desc);
 	AST_RWLIST_WRLOCK(&imagers);
 	AST_RWLIST_INSERT_HEAD(&imagers, img, list);
 	AST_RWLIST_UNLOCK(&imagers);
+	ast_verb(2, "Registered format '%s' (%s)\n", img->name, img->desc);
 	return 0;
 }
 
 void ast_image_unregister(struct ast_imager *img)
 {
-	struct ast_imager *i;
-	
 	AST_RWLIST_WRLOCK(&imagers);
-	AST_RWLIST_TRAVERSE_SAFE_BEGIN(&imagers, i, list) {	
-		if (i == img) {
-			AST_RWLIST_REMOVE_CURRENT(list);
-			break;
-		}
-	}
-	AST_RWLIST_TRAVERSE_SAFE_END;
-	AST_RWLIST_UNLOCK(&imagers);
-	if (i)
+	img = AST_RWLIST_REMOVE(&imagers, img, list);
+	AST_RWLIST_UNLOCK(&imagers);
+
+	if (img)
 		ast_verb(2, "Unregistered format '%s' (%s)\n", img->name, img->desc);
 }
 
@@ -216,6 +209,6 @@
 
 int ast_image_init(void)
 {
-	ast_cli_register_multiple(cli_image, sizeof(cli_image) / sizeof(struct ast_cli_entry));
+	ast_cli_register_multiple(cli_image, ARRAY_LEN(cli_image));
 	return 0;
 }




More information about the asterisk-commits mailing list