[Nagios-checkins] SF.net SVN: nagios:[2080] nagioscore/trunk

ageric at users.sourceforge.net ageric at users.sourceforge.net
Mon Aug 20 16:26:47 UTC 2012


Revision: 2080
          http://nagios.svn.sourceforge.net/nagios/?rev=2080&view=rev
Author:   ageric
Date:     2012-08-20 16:26:47 +0000 (Mon, 20 Aug 2012)
Log Message:
-----------
lib/skiplist: Make types opaque

It's a good design paradigm to hide the types used to implement
a certain library, since that leaves one free to make large design
changes to the structures constituting the engine of the algorithm.
Since the types' data was only accessed in two places, and even
those places were fortunately made accidentally redundant a few days
ago, leaving us completely free to make the skiplist types opaque
by simply removing a few lines of code.

Signed-off-by: Andreas Ericsson <ae at op5.se>

Modified Paths:
--------------
    nagioscore/trunk/common/objects.c
    nagioscore/trunk/lib/skiplist.c
    nagioscore/trunk/lib/skiplist.h

Modified: nagioscore/trunk/common/objects.c
===================================================================
--- nagioscore/trunk/common/objects.c	2012-08-20 16:26:22 UTC (rev 2079)
+++ nagioscore/trunk/common/objects.c	2012-08-20 16:26:47 UTC (rev 2080)
@@ -373,20 +373,12 @@
 
 
 int get_host_count(void) {
-
-	if(object_skiplists[HOST_SKIPLIST])
-		return object_skiplists[HOST_SKIPLIST]->items;
-
-	return 0;
+	return num_objects.hosts;
 	}
 
 
 int get_service_count(void) {
-
-	if(object_skiplists[SERVICE_SKIPLIST])
-		return object_skiplists[SERVICE_SKIPLIST]->items;
-
-	return 0;
+	return num_objects.services;
 	}
 
 

Modified: nagioscore/trunk/lib/skiplist.c
===================================================================
--- nagioscore/trunk/lib/skiplist.c	2012-08-20 16:26:22 UTC (rev 2079)
+++ nagioscore/trunk/lib/skiplist.c	2012-08-20 16:26:47 UTC (rev 2080)
@@ -36,6 +36,23 @@
 #include "skiplist.h"
 
 
+typedef struct skiplistnode_struct {
+	void *data;
+	struct skiplistnode_struct *forward[1]; /* this must be the last element of the struct, as we allocate # of elements during runtime*/
+	} skiplistnode;
+
+typedef struct skiplist_struct {
+	int current_level;
+	int max_levels;
+	float level_probability;
+	unsigned long items;
+	int allow_duplicates;
+	int append_duplicates;
+	int (*compare_function)(void *, void *);
+	skiplistnode *head;
+	} skiplist;
+
+
 static skiplistnode *skiplist_new_node(skiplist *list, int node_levels) {
 	skiplistnode *newnode = NULL;
 	register int x = 0;

Modified: nagioscore/trunk/lib/skiplist.h
===================================================================
--- nagioscore/trunk/lib/skiplist.h	2012-08-20 16:26:22 UTC (rev 2079)
+++ nagioscore/trunk/lib/skiplist.h	2012-08-20 16:26:47 UTC (rev 2080)
@@ -30,23 +30,9 @@
 
 NAGIOS_BEGIN_DECL
 
-typedef struct skiplistnode_struct {
-	void *data;
-	struct skiplistnode_struct *forward[1]; /* this must be the last element of the struct, as we allocate # of elements during runtime*/
-	} skiplistnode;
+struct skiplist_struct;
+typedef struct skiplist_struct skiplist;
 
-typedef struct skiplist_struct {
-	int current_level;
-	int max_levels;
-	float level_probability;
-	unsigned long items;
-	int allow_duplicates;
-	int append_duplicates;
-	int (*compare_function)(void *, void *);
-	skiplistnode *head;
-	} skiplist;
-
-
 skiplist *skiplist_new(int max_levels, float level_probability, int allow_duplicates, int append_duplicates, int (*compare_function)(void *, void *));
 int skiplist_insert(skiplist *list, void *data);
 int skiplist_empty(skiplist *list);

This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.





More information about the Nagios-commits mailing list