mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-15 17:15:18 +00:00
interface: Introduce virInterfaceObjNew
Create/use a helper to perform the object allocation Signed-off-by: John Ferlan <jferlan@redhat.com>
This commit is contained in:
parent
ad3c6b229b
commit
309947375a
@ -46,6 +46,27 @@ struct _virInterfaceObjList {
|
|||||||
|
|
||||||
/* virInterfaceObj manipulation */
|
/* 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
|
void
|
||||||
virInterfaceObjLock(virInterfaceObjPtr obj)
|
virInterfaceObjLock(virInterfaceObjPtr obj)
|
||||||
{
|
{
|
||||||
@ -230,18 +251,12 @@ virInterfaceObjListAssignDef(virInterfaceObjListPtr interfaces,
|
|||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (VIR_ALLOC(obj) < 0)
|
if (!(obj = virInterfaceObjNew()))
|
||||||
return NULL;
|
return NULL;
|
||||||
if (virMutexInit(&obj->lock) < 0) {
|
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
||||||
"%s", _("cannot initialize mutex"));
|
|
||||||
VIR_FREE(obj);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
virInterfaceObjLock(obj);
|
|
||||||
|
|
||||||
if (VIR_APPEND_ELEMENT_COPY(interfaces->objs,
|
if (VIR_APPEND_ELEMENT_COPY(interfaces->objs,
|
||||||
interfaces->count, obj) < 0) {
|
interfaces->count, obj) < 0) {
|
||||||
|
virInterfaceObjUnlock(obj);
|
||||||
virInterfaceObjFree(obj);
|
virInterfaceObjFree(obj);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user