]> xenbits.xensource.com Git - libvirt.git/commitdiff
cpu_x86: Use glib allocation for virCPUx86Feature
authorJiri Denemark <jdenemar@redhat.com>
Wed, 25 Mar 2020 09:40:29 +0000 (10:40 +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 5ffae3cebe6ab96aa7faf46d3da5b2cc475abd45..cf0f8a712060c151dbe0bdc9670ad4eddfcc3871 100644 (file)
@@ -893,28 +893,17 @@ x86VendorParse(xmlXPathContextPtr ctxt,
 }
 
 
-static virCPUx86FeaturePtr
-x86FeatureNew(void)
-{
-    virCPUx86FeaturePtr feature;
-
-    if (VIR_ALLOC(feature) < 0)
-        return NULL;
-
-    return feature;
-}
-
-
 static void
 x86FeatureFree(virCPUx86FeaturePtr feature)
 {
     if (!feature)
         return;
 
-    VIR_FREE(feature->name);
+    g_free(feature->name);
     virCPUx86DataClear(&feature->data);
-    VIR_FREE(feature);
+    g_free(feature);
 }
+G_DEFINE_AUTOPTR_CLEANUP_FUNC(virCPUx86Feature, x86FeatureFree);
 
 
 static int
@@ -1056,11 +1045,8 @@ x86FeatureParse(xmlXPathContextPtr ctxt,
     char *str = NULL;
     int ret = -1;
 
-    if (!(feature = x86FeatureNew()))
-        goto cleanup;
-
+    feature = g_new0(virCPUx86Feature, 1);
     feature->migratable = true;
-
     feature->name = g_strdup(name);
 
     if (x86FeatureFind(map, feature->name)) {