common/objects: Avoid using uninitialized memory

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

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2131 5f96b256-904b-4d8d-8c98-d829582c6739
lib/skiplist: Plug a memory leak on duplicate inserts

Previously we used to allocate space for the new entry before we
checked if it was unique. With this patch we can return an error
before we take any memory and thereby avoid leaking it.

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

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2132 5f96b256-904b-4d8d-8c98-d829582c6739
xdata/xodtemplate: Remove macro for hostgroupescalations

It was an internal one and they haven't been around for a long time.

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

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2133 5f96b256-904b-4d8d-8c98-d829582c6739
xdata/xodtemplate: Return of the recombobulation fixes

This is the next algorithmic step towards making config parsing as
quick as possible. The valgrind numbers are from a config with 1k
hosts, 10k services and 7 servicegroups, where services are assigned
to servicegroups using the 'servicegroups' directive from the service
themselves. This seemed to be the worst way to do it, apart from
creating insanely long template inheritance chains and achieve
much the same thing through that. The /usr/bin/time numbers are from
a config created exactly the same way but with 10k hosts and 100k
services. I did do a valgrind run on that setup with the old code
once but had to let it run an entire night to get numbers, and I
didn't save them.

Without patch (valgrind + /usr/bin/time, relevant figures):
heap usage: 711,866 allocs, 711,849 frees, 647,021,086 bytes allocated
48.86user 1.24system 0:51.25elapsed 97%CPU (0avgtext+0avgdata 222544maxresident)k
6856inputs+536outputs (2major+1232198minor)pagefaults 0swaps


With patch (valgrind + /usr/bin/time, relevant figures):
heap usage: 546,172 allocs, 546,149 frees, 26,950,412 bytes allocated
8.50user 0.20system 0:08.91elapsed 97%CPU (0avgtext+0avgdata 218960maxresident)k
0inputs+528outputs (0major+41675minor)pagefaults 0swaps

So not only do we process objects 5.7 times faster. We also use less
memory to do so. The speedups seem primarily related to the number of
memory allocations and string operations we do, which can ofcourse
be improved further. Both cores were compiled with -O0 and -pg to get
profiling numbers, so function call overhead is overemphasized and
skews the results somewhat in favor of the old code, which still
loses by a large margin.

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

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2134 5f96b256-904b-4d8d-8c98-d829582c6739
Reduce memory usage when parsing config

Using full integers to mark the "have's" of objects makes little sense,
since we only use one byte of them. With this patch, we reduce the
size of all xodtemplate_* objects. A lot of hosts and services and a
little for the others (done mostly by sed, so some of it makes very
little sense, but still get applied). We do this by adding bitfields
for the true booleans that never get passed by address (since bitfields
don't have addresses), saving us a neat 17megs of max rss for 10k
hosts and 100k services. Not too shabby for two minutes of work with
sed.

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

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2135 5f96b256-904b-4d8d-8c98-d829582c6739
Reduce memory usage from object config parsing

Since the group recombobulation fixup, we always duplicate objects
using the pointer to the master object's name variable, which will
get free()'d later. By marking which objects are the copies, we
can thus get away without duplicating quite so many strings, and
thereby save ourselves another 20-ish % of both runtime and memory
usage during config parsing and resolution time.

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

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2136 5f96b256-904b-4d8d-8c98-d829582c6739
core: Officially (and loudly) deprecate extinfo objects

We want to get rid of them at some point, but they get to linger
on for a while longer so we have the blaring-trumpets-period of
deprecation.

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

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2137 5f96b256-904b-4d8d-8c98-d829582c6739
core: Make sure to stash next_check_event for hosts and services

I stumbled on this by accident. It looked wrong and the fix is
obviously correct, so we might as well apply it.

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

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2138 5f96b256-904b-4d8d-8c98-d829582c6739