virHashRemoveSet bugfixes

* src/hash.c: fix a couple of problems in virHashRemoveSet based
  on Hiroyuki Kaguchi patch and explanations.
Daniel
This commit is contained in:
Daniel Veillard 2008-02-07 16:56:01 +00:00
parent 247df6e448
commit e9b3bc773d
2 changed files with 11 additions and 4 deletions

View File

@ -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.

View 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;
}
}
}