[icinga-checkins] icinga.org: icinga-core/mfriedrich/core: comments: Remove one comment at a time from hashlist (Hiren Patel)

git at icinga.org git at icinga.org
Wed May 12 20:37:49 CEST 2010


Module: icinga-core
Branch: mfriedrich/core
Commit: ab1eb97085b85921f0382628c9a934d4b96e04ef
URL:    https://git.icinga.org/?p=icinga-core.git;a=commit;h=ab1eb97085b85921f0382628c9a934d4b96e04ef

Author: Michael Friedrich <michael.friedrich at univie.ac.at>
Date:   Wed May 12 20:37:42 2010 +0200

comments: Remove one comment at a time from hashlist (Hiren Patel)

[--snip--]
Previously we would remove a bunch of comments from the hashlist
if the comment we were supposed to remove was at the first slot
in the linked list.

This patch makes sure we preserve the remaining comments
[--snip--]

fixes #405

---

 Changelog         |    1 +
 common/comments.c |   11 ++++++++---
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/Changelog b/Changelog
index 7833ac0..a23fb5c 100644
--- a/Changelog
+++ b/Changelog
@@ -33,6 +33,7 @@ FIXES
 * core: common/objects.c: Use calloc() instead of malloc() + manual NULL'ing (Andreas Ericsson)
 * core: macros: Protect against typos in macro names (Andreas Ericsson)
 * core: macros: Add NOTIFICATIONISESCALATED to the list of macro names (Marc Powell)
+* core: comments: Remove one comment at a time from hashlist (Hiren Patel)
 
 * idoutils: Host DB inserts use string 'NULL\n' instead of NULL (William Preston)
 * idoutils: ndo2db_get_object_id fails to return existing IDs (William Preston)
diff --git a/common/comments.c b/common/comments.c
index fbf174f..14fafe4 100644
--- a/common/comments.c
+++ b/common/comments.c
@@ -198,10 +198,15 @@ int delete_comment(int type, unsigned long comment_id){
 		last_hash=NULL;
 		for(this_hash=comment_hashlist[hashslot];this_hash;this_hash=this_hash->nexthash){
 			if(this_hash==this_comment){
-				if(last_hash)
+				if(last_hash){
 					last_hash->nexthash=this_hash->nexthash;
-				else
-					comment_hashlist[hashslot]=NULL;
+				} else {
+					if (this_hash->nexthash){
+						comment_hashlist[hashslot]=this_hash->nexthash;
+					} else {
+						comment_hashlist[hashslot]=NULL;
+					}
+				}
 				break;
 			        }
 			last_hash=this_hash;





More information about the icinga-checkins mailing list