[libvirt PATCH 4/9] esx: switch VIR_FREE->g_free in esx*Free*()

Laine Stump laine at redhat.com
Fri Feb 12 22:07:12 UTC 2021


Although the three functions esxFreePrivate(), esxFreeStreamPrivate(),
and esxUtil_FreeParsedUri() are calling VIR_FREE on *object, and so in
theory the caller of the function might rely on "object" (the free
function's arg) being set to NULL, in practice these functions are
only called from a couple places each, and in all cases the pointer
that is passed is a local variable, and goes out of scope almost
immediately after calling the Free function, so it is safe to change
VIR_FREE() into g_free().

Signed-off-by: Laine Stump <laine at redhat.com>
---
 src/esx/esx_driver.c |  2 +-
 src/esx/esx_stream.c |  4 ++--
 src/esx/esx_util.c   | 10 +++++-----
 3 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c
index 8afec464dd..952e769376 100644
--- a/src/esx/esx_driver.c
+++ b/src/esx/esx_driver.c
@@ -71,7 +71,7 @@ esxFreePrivate(esxPrivate **priv)
     esxUtil_FreeParsedUri(&(*priv)->parsedUri);
     virObjectUnref((*priv)->caps);
     virObjectUnref((*priv)->xmlopt);
-    VIR_FREE(*priv);
+    g_free(*priv);
 }
 
 
diff --git a/src/esx/esx_stream.c b/src/esx/esx_stream.c
index cc48c182d9..131fbc100b 100644
--- a/src/esx/esx_stream.c
+++ b/src/esx/esx_stream.c
@@ -336,8 +336,8 @@ esxFreeStreamPrivate(esxStreamPrivate **priv)
         return;
 
     esxVI_CURL_Free(&(*priv)->curl);
-    VIR_FREE((*priv)->backlog);
-    VIR_FREE(*priv);
+    g_free((*priv)->backlog);
+    g_free(*priv);
 }
 
 static int
diff --git a/src/esx/esx_util.c b/src/esx/esx_util.c
index 64a2c968f0..e9b74f386f 100644
--- a/src/esx/esx_util.c
+++ b/src/esx/esx_util.c
@@ -171,12 +171,12 @@ esxUtil_FreeParsedUri(esxUtil_ParsedUri **parsedUri)
     if (!parsedUri || !(*parsedUri))
         return;
 
-    VIR_FREE((*parsedUri)->transport);
-    VIR_FREE((*parsedUri)->vCenter);
-    VIR_FREE((*parsedUri)->proxy_hostname);
-    VIR_FREE((*parsedUri)->path);
+    g_free((*parsedUri)->transport);
+    g_free((*parsedUri)->vCenter);
+    g_free((*parsedUri)->proxy_hostname);
+    g_free((*parsedUri)->path);
 
-    VIR_FREE(*parsedUri);
+    g_free(*parsedUri);
 }
 
 
-- 
2.29.2




More information about the libvir-list mailing list