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>
/* virInterfaceObj manipulation */
static virInterfaceObjPtr
-virInterfaceObjNew(void)
+virInterfaceObjNew(virInterfaceDefPtr def)
{
virInterfaceObjPtr obj;
}
virInterfaceObjLock(obj);
+ obj->def = def;
return obj;
}
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;
}