diff options
author | Russell Bryant <russell@russellbryant.com> | 2006-02-09 16:59:50 +0000 |
---|---|---|
committer | Russell Bryant <russell@russellbryant.com> | 2006-02-09 16:59:50 +0000 |
commit | b96af335d8e719bce4032f538a677035f57df949 (patch) | |
tree | bc582fc8d1412250a1a150dcaf06bfb7fe76e0c2 /devicestate.c | |
parent | 091a14754d7da5b7a7dddfc356e80ca70d6a678a (diff) |
conversions to memory allocation wrappers, remove duplicated error messages,
remove unnecessary casts, malloc+memset to calloc (issue #6395)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@9310 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'devicestate.c')
-rw-r--r-- | devicestate.c | 15 |
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); |