On Tue, Nov 23, 2021 at 06:09:36PM +0100, Michal Privoznik wrote:
At a lot of places we have the following pattern: virXXXDef *def = parseDef(); if (!(obj = virXXXObjListAdd(def))) goto clenaup; def = NULL; cleanup: virXXXDefFree(def); The 'def = NULL' step is necessary because the ownership of the definition was transferred onto the object. Well, this approach is fragile as it relies on developers remembering to set the variable explicitly. If the virXXXObjListAdd() would take address of @def then the explicit set to NULL can be left out. Please note, I've reworked only a few virXXXObjListAdd() functions to see whether these are desired or not. If merged, I can post patches for the rest. Michal Prívozník (4): virInterfaceObjListAssignDef: Transfer definition ownership virSecretObjListAdd: Transfer definition ownership virStoragePoolObjListAdd: Transfer definition ownership virDomainObjListAdd: Transfer definition ownership
Reviewed-by: Martin Kletzander <mkletzan@xxxxxxxxxx>
Attachment:
signature.asc
Description: PGP signature