aboutsummaryrefslogtreecommitdiffstats
path: root/devicestate.c
diff options
context:
space:
mode:
authorrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2006-02-09 16:59:50 +0000
committerrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2006-02-09 16:59:50 +0000
commit34490de229310cffd8ee332e86e9e1018aaa57f5 (patch)
treebc582fc8d1412250a1a150dcaf06bfb7fe76e0c2 /devicestate.c
parent0a2b114fb5907f90ec49f443931fffdb79a89d55 (diff)
conversions to memory allocation wrappers, remove duplicated error messages,
remove unnecessary casts, malloc+memset to calloc (issue #6395) git-svn-id: http://svn.digium.com/svn/asterisk/trunk@9310 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'devicestate.c')
-rw-r--r--devicestate.c15
1 files changed, 4 insertions, 11 deletions
diff --git a/devicestate.c b/devicestate.c
index d7f39612c..93200a9c0 100644
--- a/devicestate.c
+++ b/devicestate.c
@@ -143,11 +143,7 @@ int ast_devstate_add(ast_devstate_cb_type callback, void *data)
{
struct devstate_cb *devcb;
- if (!callback)
- return -1;
-
- devcb = calloc(1, sizeof(*devcb));
- if (!devcb)
+ if (!callback || !(devcb = ast_calloc(1, sizeof(*devcb))))
return -1;
devcb->data = data;
@@ -198,16 +194,13 @@ static void do_state_change(const char *device)
static int __ast_device_state_changed_literal(char *buf)
{
char *device, *tmp;
- struct state_change *change = NULL;
+ struct state_change *change;
device = buf;
- tmp = strrchr(device, '-');
- if (tmp)
+ if ((tmp = strrchr(device, '-')))
*tmp = '\0';
- if (change_thread != AST_PTHREADT_NULL)
- change = calloc(1, sizeof(*change) + strlen(device));
- if (!change) {
+ if (change_thread == AST_PTHREADT_NULL || !(change = ast_calloc(1, sizeof(*change) + strlen(device)))) {
/* we could not allocate a change struct, or */
/* there is no background thread, so process the change now */
do_state_change(device);