diff options
author | russell <russell@f38db490-d61c-443f-a65b-d21fe96a405b> | 2007-11-14 00:33:52 +0000 |
---|---|---|
committer | russell <russell@f38db490-d61c-443f-a65b-d21fe96a405b> | 2007-11-14 00:33:52 +0000 |
commit | cc34f5c17ee680c37563223bee3d8880bebbc28c (patch) | |
tree | 75d3f4a72670921a5cf42dc81ef503ae0dd6ebf4 | |
parent | 726bcbdaa810d26631a9eeb95abb264f20b8deb8 (diff) |
- 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
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@89258 f38db490-d61c-443f-a65b-d21fe96a405b
-rw-r--r-- | main/image.c | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/main/image.c b/main/image.c index 91cdebaeb..f160cebff 100644 --- a/main/image.c +++ b/main/image.c @@ -51,27 +51,20 @@ static AST_RWLIST_HEAD_STATIC(imagers, ast_imager); 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; + img = AST_RWLIST_REMOVE(&imagers, img, list); AST_RWLIST_UNLOCK(&imagers); - if (i) + + if (img) ast_verb(2, "Unregistered format '%s' (%s)\n", img->name, img->desc); } @@ -216,6 +209,6 @@ struct ast_cli_entry cli_image[] = { 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; } |