if (n > 0) {
int *domids;
/* Get list of domains. */
- domids = malloc(sizeof(*domids) * n);
+ domids = calloc(n, sizeof(*domids));
if (domids == NULL) {
- ERROR(PLUGIN_NAME " plugin: malloc failed.");
+ ERROR(PLUGIN_NAME " plugin: calloc failed.");
return -1;
}
n = virConnectListDomains(conn, domids, n);
int *domids;
/* Get list of domains. */
- domids = malloc(sizeof(*domids) * n);
+ domids = calloc(n, sizeof(*domids));
if (domids == NULL) {
- ERROR(PLUGIN_NAME " plugin: malloc failed.");
+ ERROR(PLUGIN_NAME " plugin: calloc failed.");
return -1;
}