1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-03-07 17:28:15 +00:00

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: John Ferlan <jferlan@redhat.com>
This commit is contained in:
John Ferlan 2017-06-02 07:56:59 -04:00
parent 309947375a
commit 92840eb3a7

View File

@ -47,7 +47,7 @@ struct _virInterfaceObjList {
/* virInterfaceObj manipulation */ /* virInterfaceObj manipulation */
static virInterfaceObjPtr static virInterfaceObjPtr
virInterfaceObjNew(void) virInterfaceObjNew(virInterfaceDefPtr def)
{ {
virInterfaceObjPtr obj; virInterfaceObjPtr obj;
@ -62,6 +62,7 @@ virInterfaceObjNew(void)
} }
virInterfaceObjLock(obj); virInterfaceObjLock(obj);
obj->def = def;
return obj; return obj;
} }
@ -251,17 +252,17 @@ virInterfaceObjListAssignDef(virInterfaceObjListPtr interfaces,
return obj; return obj;
} }
if (!(obj = virInterfaceObjNew())) if (!(obj = virInterfaceObjNew(def)))
return NULL; return NULL;
if (VIR_APPEND_ELEMENT_COPY(interfaces->objs, if (VIR_APPEND_ELEMENT_COPY(interfaces->objs,
interfaces->count, obj) < 0) { interfaces->count, obj) < 0) {
obj->def = NULL;
virInterfaceObjUnlock(obj); virInterfaceObjUnlock(obj);
virInterfaceObjFree(obj); virInterfaceObjFree(obj);
return NULL; return NULL;
} }
obj->def = def;
return obj; return obj;
} }