mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-07-06 09:55:46 +00:00
conf: Introduce allocator for virDomainIOThreadIDDef
So far, iothread configuration structure (virDomainIOThreadIDDef) is allocated by plain g_new0(). This is perfectly okay because all members of the struct default to value 0 anyway. But soon this is going to change. Therefore, replace those g_new0() with a function so that the default value can be set consistently in one place. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Peter Krempa <pkrempa@redhat.com>
This commit is contained in:
parent
c4c57cef33
commit
f899276737
@ -3477,6 +3477,15 @@ virDomainIOThreadIDArrayHasPin(virDomainDef *def)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static virDomainIOThreadIDDef *
|
||||||
|
virDomainIOThreadIDDefNew(void)
|
||||||
|
{
|
||||||
|
virDomainIOThreadIDDef *def = g_new0(virDomainIOThreadIDDef, 1);
|
||||||
|
|
||||||
|
return def;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
virDomainIOThreadIDDefFree(virDomainIOThreadIDDef *def)
|
virDomainIOThreadIDDefFree(virDomainIOThreadIDDef *def)
|
||||||
{
|
{
|
||||||
@ -3540,7 +3549,7 @@ virDomainIOThreadIDDefArrayInit(virDomainDef *def,
|
|||||||
_("failed to populate iothreadids"));
|
_("failed to populate iothreadids"));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
iothrid = g_new0(virDomainIOThreadIDDef, 1);
|
iothrid = virDomainIOThreadIDDefNew();
|
||||||
iothrid->iothread_id = nxt;
|
iothrid->iothread_id = nxt;
|
||||||
iothrid->autofill = true;
|
iothrid->autofill = true;
|
||||||
def->iothreadids[def->niothreadids++] = g_steal_pointer(&iothrid);
|
def->iothreadids[def->niothreadids++] = g_steal_pointer(&iothrid);
|
||||||
@ -17009,7 +17018,7 @@ virDomainIdmapDefParseXML(xmlXPathContextPtr ctxt,
|
|||||||
static virDomainIOThreadIDDef *
|
static virDomainIOThreadIDDef *
|
||||||
virDomainIOThreadIDDefParseXML(xmlNodePtr node)
|
virDomainIOThreadIDDefParseXML(xmlNodePtr node)
|
||||||
{
|
{
|
||||||
g_autoptr(virDomainIOThreadIDDef) iothrid = g_new0(virDomainIOThreadIDDef, 1);
|
g_autoptr(virDomainIOThreadIDDef) iothrid = virDomainIOThreadIDDefNew();
|
||||||
|
|
||||||
if (virXMLPropUInt(node, "id", 10,
|
if (virXMLPropUInt(node, "id", 10,
|
||||||
VIR_XML_PROP_REQUIRED | VIR_XML_PROP_NONZERO,
|
VIR_XML_PROP_REQUIRED | VIR_XML_PROP_NONZERO,
|
||||||
@ -22932,8 +22941,7 @@ virDomainIOThreadIDAdd(virDomainDef *def,
|
|||||||
{
|
{
|
||||||
virDomainIOThreadIDDef *iothrid = NULL;
|
virDomainIOThreadIDDef *iothrid = NULL;
|
||||||
|
|
||||||
iothrid = g_new0(virDomainIOThreadIDDef, 1);
|
iothrid = virDomainIOThreadIDDefNew();
|
||||||
|
|
||||||
iothrid->iothread_id = iothread_id;
|
iothrid->iothread_id = iothread_id;
|
||||||
|
|
||||||
VIR_APPEND_ELEMENT_COPY(def->iothreadids, def->niothreadids, iothrid);
|
VIR_APPEND_ELEMENT_COPY(def->iothreadids, def->niothreadids, iothrid);
|
||||||
|
Loading…
Reference in New Issue
Block a user