提交 298d9f61 编写于 作者: J John Ferlan

nwfilter: Introduce virNWFilterObjNew

Perform the object initialization in a helper rather than inline.
Signed-off-by: NJohn Ferlan <jferlan@redhat.com>
上级 4b626450
......@@ -43,6 +43,26 @@ struct _virNWFilterObj {
};
static virNWFilterObjPtr
virNWFilterObjNew(void)
{
virNWFilterObjPtr obj;
if (VIR_ALLOC(obj) < 0)
return NULL;
if (virMutexInitRecursive(&obj->lock) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("cannot initialize mutex"));
VIR_FREE(obj);
return NULL;
}
virNWFilterObjLock(obj);
return obj;
}
virNWFilterDefPtr
virNWFilterObjGetDef(virNWFilterObjPtr obj)
{
......@@ -321,16 +341,8 @@ virNWFilterObjAssignDef(virNWFilterObjListPtr nwfilters,
return obj;
}
if (VIR_ALLOC(obj) < 0)
return NULL;
if (virMutexInitRecursive(&obj->lock) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("cannot initialize mutex"));
VIR_FREE(obj);
if (!(obj = virNWFilterObjNew()))
return NULL;
}
virNWFilterObjLock(obj);
if (VIR_APPEND_ELEMENT_COPY(nwfilters->objs,
nwfilters->count, obj) < 0) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册