]> xenbits.xensource.com Git - libvirt.git/commitdiff
virHashRemoveSet bugfixes
authorDaniel Veillard <veillard@redhat.com>
Thu, 7 Feb 2008 16:56:01 +0000 (16:56 +0000)
committerDaniel Veillard <veillard@redhat.com>
Thu, 7 Feb 2008 16:56:01 +0000 (16:56 +0000)
* src/hash.c: fix a couple of problems in virHashRemoveSet based
  on Hiroyuki Kaguchi patch and explanations.
Daniel

ChangeLog
src/hash.c

index 3a21ca9ee4f3e85624f8f4cc4d2923be194ebd94..df458cde5a8fe986828a28fb1a472e92db8ebddf 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Thu Feb  7 17:46:14 CET 2008 Daniel Veillard <veillard@redhat.com>
+
+       * src/hash.c: fix a couple of problems in virHashRemoveSet based
+         on Hiroyuki Kaguchi patch and explanations.
+
 Thu Feb  7 17:48:30 CET 2008 Jim Meyering  <meyering@redhat.com>
 
        Mark all qemudLog diagnostics for translation.
@@ -52,6 +57,8 @@ Thu Feb  7 17:48:30 CET 2008 Jim Meyering  <meyering@redhat.com>
        * src/xml.c (virXPathString): Likewise.
        * tests/xmlrpctest.c (checkRequestValue): Likewise.
 
+2008-02-07  Jim Meyering  <meyering@redhat.com>
+
        * src/xm_internal.c: Remove trailing blanks
        * NEWS, ChangeLog: Likewise.
 
index 8bd30a7efdce246bbbafb800f45f44cabe218f70..84b41b0bb5bec3c0eba20597f2c816217af55d45 100644 (file)
@@ -537,9 +537,11 @@ int virHashRemoveSet(virHashTablePtr table, virHashSearcher iter, virHashDealloc
                 count++;
                 f(entry->payload, entry->name);
                 free(entry->name);
+                table->nbElems--;
                 if (prev) {
                     prev->next = entry->next;
                     free(entry);
+                    entry = prev;
                 } else {
                     if (entry->next == NULL) {
                         entry->valid = 0;
@@ -549,16 +551,14 @@ int virHashRemoveSet(virHashTablePtr table, virHashSearcher iter, virHashDealloc
                         memcpy(&(table->table[i]), entry,
                                sizeof(virHashEntry));
                         free(entry);
-                        entry = NULL;
+                        entry = &(table->table[i]);
+                        continue;
                     }
                 }
-                table->nbElems--;
             }
             prev = entry;
             if (entry) {
                 entry = entry->next;
-            } else {
-                entry = NULL;
             }
         }
     }