[libvirt PATCH 07/39] cpu_x86: Use glib allocation in virCPUx86GetModels

Ján Tomko jtomko at redhat.com
Tue Apr 7 07:45:06 UTC 2020


On a Friday in 2020, Jiri Denemark wrote:
>Signed-off-by: Jiri Denemark <jdenemar at redhat.com>
>---
> src/cpu/cpu_x86.c | 10 +---------
> 1 file changed, 1 insertion(+), 9 deletions(-)
>
>diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
>index bcb87d6f93..fce7a2b8c5 100644
>--- a/src/cpu/cpu_x86.c
>+++ b/src/cpu/cpu_x86.c
>@@ -3123,21 +3123,13 @@ virCPUx86GetModels(char ***models)
>         return -1;
>
>     if (models) {
>-        if (VIR_ALLOC_N(*models, map->nmodels + 1) < 0)
>-            goto error;
>+        *models = g_new0(char *, map->nmodels + 1);
>
>         for (i = 0; i < map->nmodels; i++)
>             (*models)[i] = g_strdup(map->models[i]->name);
>     }
>
>     return map->nmodels;
>-
>- error:

Bye, error:

>-    if (models) {
>-        virStringListFree(*models);
>-        *models = NULL;
>-    }
>-    return -1;
> }

Reviewed-by: Ján Tomko <jtomko at redhat.com>

Jano
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20200407/e91b79e0/attachment-0001.sig>


More information about the libvir-list mailing list