[PATCH 0/4] virXXXListAdd: Transfer definition ownership
Martin Kletzander
mkletzan at redhat.com
Wed Nov 24 10:52:24 UTC 2021
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 at redhat.com>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20211124/0dc0d00c/attachment-0001.sig>
More information about the libvir-list
mailing list