[libvirt PATCH 20/21] util: rename two *Free() functions while changing VIR_FREE to g_free

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



dhcpHostFree() and addnHostFree() don't follow the normal pattern of
*Free functions in the rest of libvirt code - they are actually more
similar to the *Dispose() functions, in that they free all subordinate
objects, but not the object pointed to by the argument
itself. However, the arguments aren't virObjects, so it wouldn't be
proper to name them *Dispose() either.

They *currently* behave similar to a *Clear() function, in that they
free all the subordinate objects and nullify the pointers of those
objects. HOWEVER, we don't actually need or want that behavior - the
two functions in question are only called as part of a higher level
*Free() function, and the pointers are not referenced in any way
between the time they are freed and when the parent object is freed.

So, since the current name isn't correct, nor is *Dispose(), and we
want to change the behavior in such a way that *Clear() also wouldn't
be correct, lets name the functions *FreeContent(), which is an
accurate description of what the functions do, and what we *want* them
to do.

And since it's such a small patch, we can go ahead and change that
behavior - replacing the VIR_FREEs with g_free.

Signed-off-by: Laine Stump <laine@xxxxxxxxxx>
---
 src/util/virdnsmasq.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/src/util/virdnsmasq.c b/src/util/virdnsmasq.c
index c21819c981..653d46bef9 100644
--- a/src/util/virdnsmasq.c
+++ b/src/util/virdnsmasq.c
@@ -50,20 +50,20 @@ VIR_LOG_INIT("util.dnsmasq");
 #define DNSMASQ_ADDNHOSTSFILE_SUFFIX "addnhosts"
 
 static void
-dhcphostFree(dnsmasqDhcpHost *host)
+dhcphostFreeContent(dnsmasqDhcpHost *host)
 {
-    VIR_FREE(host->host);
+    g_free(host->host);
 }
 
 static void
-addnhostFree(dnsmasqAddnHost *host)
+addnhostFreeContent(dnsmasqAddnHost *host)
 {
     size_t i;
 
     for (i = 0; i < host->nhostnames; i++)
-        VIR_FREE(host->hostnames[i]);
-    VIR_FREE(host->hostnames);
-    VIR_FREE(host->ip);
+        g_free(host->hostnames[i]);
+    g_free(host->hostnames);
+    g_free(host->ip);
 }
 
 static void
@@ -73,7 +73,7 @@ addnhostsFree(dnsmasqAddnHostsfile *addnhostsfile)
 
     if (addnhostsfile->hosts) {
         for (i = 0; i < addnhostsfile->nhosts; i++)
-            addnhostFree(&addnhostsfile->hosts[i]);
+            addnhostFreeContent(&addnhostsfile->hosts[i]);
 
         g_free(addnhostsfile->hosts);
 
@@ -270,7 +270,7 @@ hostsfileFree(dnsmasqHostsfile *hostsfile)
 
     if (hostsfile->hosts) {
         for (i = 0; i < hostsfile->nhosts; i++)
-            dhcphostFree(&hostsfile->hosts[i]);
+            dhcphostFreeContent(&hostsfile->hosts[i]);
 
         g_free(hostsfile->hosts);
 
-- 
2.29.2




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux