[virt-tools-list] [libosinfo] Fix osinfo_list_add_union()

Zeeshan Ali (Khattak) zeeshanak at gnome.org
Mon Jun 4 15:44:21 UTC 2012


From: "Zeeshan Ali (Khattak)" <zeeshanak at gnome.org>

This function was adding the second list elements to new list first so
the order of elements in the new list was contrary to what user will
expect of this function (and all wrapper/using functions).
---
 osinfo/osinfo_list.c |   10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/osinfo/osinfo_list.c b/osinfo/osinfo_list.c
index 1ed9ca7..ba3f117 100644
--- a/osinfo/osinfo_list.c
+++ b/osinfo/osinfo_list.c
@@ -337,19 +337,19 @@ void osinfo_list_add_union(OsinfoList *list, OsinfoList *sourceOne, OsinfoList *
 
     newSet = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL);
 
-    // Add all from other list to new list
+    // Add all from first list to new list
     int i, len;
-    len = osinfo_list_get_length(sourceTwo);
+    len = osinfo_list_get_length(sourceOne);
     for (i = 0; i < len; i++) {
-        OsinfoEntity *entity = osinfo_list_get_nth(sourceTwo, i);
+        OsinfoEntity *entity = osinfo_list_get_nth(sourceOne, i);
         osinfo_list_add(list, entity);
         g_hash_table_insert(newSet, g_strdup(osinfo_entity_get_id(entity)), entity);
     }
 
     // Add remaining elements from this list to new list
-    len = osinfo_list_get_length(sourceOne);
+    len = osinfo_list_get_length(sourceTwo);
     for (i = 0; i < len; i++) {
-        OsinfoEntity *entity = osinfo_list_get_nth(sourceOne, i);
+        OsinfoEntity *entity = osinfo_list_get_nth(sourceTwo, i);
         // If new list does not contain element, add to new list
         if (!g_hash_table_lookup(newSet, osinfo_entity_get_id(entity))) {
             osinfo_list_add(list, entity);
-- 
1.7.10.2




More information about the virt-tools-list mailing list