Firstly, we realloc internal list to hold new item (=volume that
will be potentially created) and then we check whether we
actually know how to create it. If we don't we consume more
memory than we really need for no good reason.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
goto cleanup;
}
- if (VIR_REALLOC_N(pool->volumes.objs,
- pool->volumes.count+1) < 0)
- goto cleanup;
-
if (!backend->createVol) {
virReportError(VIR_ERR_NO_SUPPORT,
"%s", _("storage pool does not support volume "
goto cleanup;
}
+ if (VIR_REALLOC_N(pool->volumes.objs,
+ pool->volumes.count+1) < 0)
+ goto cleanup;
+
/* Wipe any key the user may have suggested, as volume creation
* will generate the canonical key. */
VIR_FREE(voldef->key);