diff options
author | russell <russell@f38db490-d61c-443f-a65b-d21fe96a405b> | 2006-07-23 04:58:56 +0000 |
---|---|---|
committer | russell <russell@f38db490-d61c-443f-a65b-d21fe96a405b> | 2006-07-23 04:58:56 +0000 |
commit | 7388c7ee9946dcd96184692ba745b3e1934f4d70 (patch) | |
tree | 7f2d3745db015068d0c02ea3c8ddddd8ca127501 /cli.c | |
parent | 1ace17079bed36426af22b5bc25b756f7f8dde95 (diff) |
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.
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@38108 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'cli.c')
-rw-r--r-- | cli.c | 13 |
1 files changed, 4 insertions, 9 deletions
@@ -1177,7 +1177,7 @@ static char *parse_args(const char *s, int *argc, char *argv[], int max, int *tr 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 @@ int ast_cli_command(int fd, const char *s) 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 @@ int ast_cli_command(int fd, const char *s) } } 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); |