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

ageric at users.sourceforge.net ageric at users.sourceforge.net
Tue Aug 28 17:59:08 UTC 2012


Revision: 2121
          http://nagios.svn.sourceforge.net/nagios/?rev=2121&view=rev
Author:   ageric
Date:     2012-08-28 17:59:08 +0000 (Tue, 28 Aug 2012)
Log Message:
-----------
Add prepend_object_to_objectlist

When we have better ways of ensuring uniqueness in a linked list,
we might as well not traverse the entire thing every time we add
something to it, but having this little helper is nifty for those
occasions.

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

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

Modified: nagioscore/trunk/common/objects.c
===================================================================
--- nagioscore/trunk/common/objects.c	2012-08-28 09:56:34 UTC (rev 2120)
+++ nagioscore/trunk/common/objects.c	2012-08-28 17:59:08 UTC (rev 2121)
@@ -2093,6 +2093,19 @@
 	}
 
 
+/* useful when we don't care if the object is unique or not */
+int prepend_object_to_objectlist(objectlist **list, void *object_ptr)
+{
+	objectlist *item;
+	if(list == NULL || object_ptr == NULL)
+		return ERROR;
+	if((item = malloc(sizeof(*item))) == NULL)
+		return ERROR;
+	item->next = *list;
+	item->object_ptr = object_ptr;
+	*list = item;
+	return OK;
+	}
 
 /* frees memory allocated to a temporary object list */
 int free_objectlist(objectlist **temp_list) {

Modified: nagioscore/trunk/include/objects.h
===================================================================
--- nagioscore/trunk/include/objects.h	2012-08-28 09:56:34 UTC (rev 2120)
+++ nagioscore/trunk/include/objects.h	2012-08-28 17:59:08 UTC (rev 2121)
@@ -686,6 +686,7 @@
 
 
 int add_object_to_objectlist(objectlist **, void *);
+int prepend_object_to_objectlist(objectlist **, void *);
 int free_objectlist(objectlist **);
 
 

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