Replace a few instances of malloc() followed by memset(0) with
calloc()
Signed-off-by: Mark McLoughlin <markmc(a)redhat.com>
Index: libvirt/qemud/iptables.c
===================================================================
--- libvirt.orig/qemud/iptables.c
+++ libvirt/qemud/iptables.c
@@ -270,11 +270,9 @@ iptRulesNew(const char *table,
{
iptRules *rules;
- if (!(rules = (iptRules *)malloc(sizeof (iptRules))))
+ if (!(rules = (iptRules *)calloc(1, sizeof (iptRules))))
return NULL;
- memset (rules, 0, sizeof (iptRules));
-
if (!(rules->table = strdup(table)))
goto error;
@@ -353,11 +351,9 @@ iptablesAddRemoveChain(iptRules *rules,
2 + /* --table foo */
2; /* --new-chain bar */
- if (!(argv = (char **)malloc(sizeof(char *) * (n+1))))
+ if (!(argv = (char **)calloc(n + 1, sizeof(char *))))
goto error;
- memset(argv, 0, sizeof(char *) * (n + 1));
-
n = 0;
if (!(argv[n++] = strdup(IPTABLES_PATH)))
@@ -413,14 +409,12 @@ iptablesAddRemoveRule(iptRules *rules, i
va_end(args);
- if (!(argv = (char **)malloc(sizeof(char *) * (n + 1))))
+ if (!(argv = (char **)calloc(n + 1, sizeof(char *))))
goto error;
if (!(rule = (char *)malloc(rulelen)))
goto error;
- memset(argv, 0, sizeof(char *) * (n + 1));
-
n = 0;
if (!(argv[n++] = strdup(IPTABLES_PATH)))
--