]> xenbits.xensource.com Git - libvirt.git/commitdiff
cpu_x86: Use glib allocation in virCPUx86GetModels
authorJiri Denemark <jdenemar@redhat.com>
Wed, 25 Mar 2020 17:41:48 +0000 (18:41 +0100)
committerJiri Denemark <jdenemar@redhat.com>
Wed, 8 Apr 2020 15:41:00 +0000 (17:41 +0200)
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/cpu/cpu_x86.c

index 51c2a0ea360a42f84cdcd887f25a49085ef89895..3c08edcd7355e4becc6ec9286377613146d04adc 100644 (file)
@@ -3121,21 +3121,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;
 }