Switch the allocation in virshSnapshotListCollect and
its cargo-culted Checkpoint counterpart to two separate
g_new0 calls and move the boolean expression to
the if condition that chooses between them.
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
/* When mixing --from and --tree, we also want a copy of from
* in the list, but with no parent for that one entry. */
- checkpointlist->chks = vshCalloc(ctl, count + (tree && from),
- sizeof(*checkpointlist->chks));
+ if (from && tree)
+ checkpointlist->chks = g_new0(struct virshChk, count + 1);
+ else
+ checkpointlist->chks = g_new0(struct virshChk, count);
checkpointlist->nchks = count;
for (i = 0; i < count; i++)
checkpointlist->chks[i].chk = chks[i];
if (count >= 0) {
/* When mixing --from and --tree, we also want a copy of from
* in the list, but with no parent for that one entry. */
- snaplist->snaps = vshCalloc(ctl, count + (tree && from),
- sizeof(*snaplist->snaps));
+ if (tree && from)
+ snaplist->snaps = g_new0(struct virshSnap, count + 1);
+ else
+ snaplist->snaps = g_new0(struct virshSnap, count);
snaplist->nsnaps = count;
for (i = 0; i < count; i++)
snaplist->snaps[i].snap = snaps[i];