summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 4bb6f36)
raw | patch | inline | side by side (parent: 4bb6f36)
author | Florian Forster <octo@collectd.org> | |
Wed, 17 Jun 2015 06:38:27 +0000 (08:38 +0200) | ||
committer | Florian Forster <octo@collectd.org> | |
Wed, 17 Jun 2015 06:39:55 +0000 (08:39 +0200) |
src/ceph.c | patch | blob | history |
diff --git a/src/ceph.c b/src/ceph.c
index 56e349c3aea49e7deafa8fc875b4cd5bcf74598e..d928a7ba4b5db1d71e87449f635783e44000f621 100644 (file)
--- a/src/ceph.c
+++ b/src/ceph.c
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))
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;
}