提交 92840eb3 编写于 作者: J John Ferlan

interface: Consume @def in virInterfaceObjNew

Move the consumption of @def in virInterfaceObjNew and then handle that
in the error path of virInterfaceObjListAssignDef since it's caller expects
to need to free @def when NULL is returned and so would virInterfaceObjFree.
Signed-off-by: NJohn Ferlan <jferlan@redhat.com>
上级 30994737
......@@ -47,7 +47,7 @@ struct _virInterfaceObjList {
/* virInterfaceObj manipulation */
static virInterfaceObjPtr
virInterfaceObjNew(void)
virInterfaceObjNew(virInterfaceDefPtr def)
{
virInterfaceObjPtr obj;
......@@ -62,6 +62,7 @@ virInterfaceObjNew(void)
}
virInterfaceObjLock(obj);
obj->def = def;
return obj;
}
......@@ -251,17 +252,17 @@ virInterfaceObjListAssignDef(virInterfaceObjListPtr interfaces,
return obj;
}
if (!(obj = virInterfaceObjNew()))
if (!(obj = virInterfaceObjNew(def)))
return NULL;
if (VIR_APPEND_ELEMENT_COPY(interfaces->objs,
interfaces->count, obj) < 0) {
obj->def = NULL;
virInterfaceObjUnlock(obj);
virInterfaceObjFree(obj);
return NULL;
}
obj->def = def;
return obj;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册