From e9b3bc773d27b2fa3899b35dfe3849a212222264 Mon Sep 17 00:00:00 2001 From: Daniel Veillard Date: Thu, 7 Feb 2008 16:56:01 +0000 Subject: [PATCH] virHashRemoveSet bugfixes * src/hash.c: fix a couple of problems in virHashRemoveSet based on Hiroyuki Kaguchi patch and explanations. Daniel --- ChangeLog | 7 +++++++ src/hash.c | 8 ++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3a21ca9ee4..df458cde5a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Thu Feb 7 17:46:14 CET 2008 Daniel Veillard + + * 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 Mark all qemudLog diagnostics for translation. @@ -52,6 +57,8 @@ Thu Feb 7 17:48:30 CET 2008 Jim Meyering * src/xml.c (virXPathString): Likewise. * tests/xmlrpctest.c (checkRequestValue): Likewise. +2008-02-07 Jim Meyering + * src/xm_internal.c: Remove trailing blanks * NEWS, ChangeLog: Likewise. diff --git a/src/hash.c b/src/hash.c index 8bd30a7efd..84b41b0bb5 100644 --- a/src/hash.c +++ b/src/hash.c @@ -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; } } }