提交 30994737 编写于 作者: J John Ferlan

interface: Introduce virInterfaceObjNew

Create/use a helper to perform the object allocation
Signed-off-by: NJohn Ferlan <jferlan@redhat.com>
上级 ad3c6b22
......@@ -46,6 +46,27 @@ struct _virInterfaceObjList {
/* virInterfaceObj manipulation */
static virInterfaceObjPtr
virInterfaceObjNew(void)
{
virInterfaceObjPtr obj;
if (VIR_ALLOC(obj) < 0)
return NULL;
if (virMutexInit(&obj->lock) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("cannot initialize mutex"));
VIR_FREE(obj);
return NULL;
}
virInterfaceObjLock(obj);
return obj;
}
void
virInterfaceObjLock(virInterfaceObjPtr obj)
{
......@@ -230,18 +251,12 @@ virInterfaceObjListAssignDef(virInterfaceObjListPtr interfaces,
return obj;
}
if (VIR_ALLOC(obj) < 0)
return NULL;
if (virMutexInit(&obj->lock) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("cannot initialize mutex"));
VIR_FREE(obj);
if (!(obj = virInterfaceObjNew()))
return NULL;
}
virInterfaceObjLock(obj);
if (VIR_APPEND_ELEMENT_COPY(interfaces->objs,
interfaces->count, obj) < 0) {
virInterfaceObjUnlock(obj);
virInterfaceObjFree(obj);
return NULL;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册