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

Jiri Denemark jdenemar at redhat.com
Fri Mar 27 13:43:36 UTC 2020


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:
-    if (models) {
-        virStringListFree(*models);
-        *models = NULL;
-    }
-    return -1;
 }
 
 
-- 
2.26.0




More information about the libvir-list mailing list