[PATCH 12/19] virHashAddOrUpdateEntry: Simplify allocation of new entry

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

 



Use g_new0 and skip checking of the return value of keyCopy callback
as both are bound to return a valid pointer.

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 src/util/virhash.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/src/util/virhash.c b/src/util/virhash.c
index c57d9f8292..36a2d312fc 100644
--- a/src/util/virhash.c
+++ b/src/util/virhash.c
@@ -344,7 +344,6 @@ virHashAddOrUpdateEntry(virHashTablePtr table, const void *name,
     size_t key, len = 0;
     virHashEntryPtr entry;
     virHashEntryPtr last = NULL;
-    void *new_name;

     if ((table == NULL) || (name == NULL))
         return -1;
@@ -374,12 +373,8 @@ virHashAddOrUpdateEntry(virHashTablePtr table, const void *name,
         len++;
     }

-    if (VIR_ALLOC(entry) < 0 || !(new_name = table->keyCopy(name))) {
-        VIR_FREE(entry);
-        return -1;
-    }
-
-    entry->name = new_name;
+    entry = g_new0(virHashEntry, 1);
+    entry->name = table->keyCopy(name);
     entry->payload = userdata;

     if (last)
-- 
2.24.1





[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