X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=src%2Fceph.c;h=419ca6e56170758c5c05dea2e1e20994b53b2ff3;hb=042c592bcddeea04cf81230ba9c97a09c5d3595c;hp=56e349c3aea49e7deafa8fc875b4cd5bcf74598e;hpb=9817e7298bd6c364fa17347327af54adf048bd21;p=collectd.git diff --git a/src/ceph.c b/src/ceph.c index 56e349c3..419ca6e5 100644 --- a/src/ceph.c +++ b/src/ceph.c @@ -43,7 +43,6 @@ #include #include #include -#include #include #include #include @@ -657,7 +656,8 @@ static int cc_handle_bool(struct oconfig_item_s *item, int *dest) static int cc_add_daemon_config(oconfig_item_t *ci) { int ret, i; - struct ceph_daemon *array, *nd, cd; + struct ceph_daemon *nd, cd; + struct ceph_daemon **tmp; memset(&cd, 0, sizeof(struct ceph_daemon)); if((ci->values_num != 1) || (ci->values[0].type != OCONFIG_TYPE_STRING)) @@ -709,21 +709,21 @@ static int cc_add_daemon_config(oconfig_item_t *ci) return -EINVAL; } - array = realloc(g_daemons, - sizeof(struct ceph_daemon *) * (g_num_daemons + 1)); - if(array == NULL) + tmp = realloc(g_daemons, (g_num_daemons+1) * sizeof(*g_daemons)); + if(tmp == NULL) { /* The positive return value here indicates that this is a * runtime error, not a configuration error. */ return ENOMEM; } - g_daemons = (struct ceph_daemon**) array; - nd = malloc(sizeof(struct ceph_daemon)); + g_daemons = tmp; + + nd = malloc(sizeof(*nd)); if(!nd) { return ENOMEM; } - memcpy(nd, &cd, sizeof(struct ceph_daemon)); + memcpy(nd, &cd, sizeof(*nd)); g_daemons[g_num_daemons++] = nd; return 0; }