xod: Plug a memory leak in xdata/xodtemplate.c

On soft reloads, we used to leak the bitmaps we created to track
contacts, hosts and services. This patch adds the necessary calls
to get rid of it.

Signed-off-by: Andreas Ericsson <ae@op5.se>
xod: Make sure we free servicedependency templates

Apparently we forgot to do that earlier. For host dependencies this
doesn't seem to be a problem.

Signed-off-by: Andreas Ericsson <ae@op5.se>
core: Avoid strdup()'ing group member names

Since we know all string lists are duplicated to kingdom come when
we inherit variable values, read them from config and register
objects, we can at least avoid duplicating them once again here,
cutting down memory used by lots, and allocations even more (making
it far more pleasant to run large configurations through valgrind).

The user-visible feature here is that error messages for non-existant
objects listed as members of some particular group can contain the
location in the configuration where things went south, which is
particularly helpful for larger configurations.

Signed-off-by: Andreas Ericsson <ae@op5.se>
core: Assign strings rather than copying them when registering objects

This means we avoid one layer of strdup(). Since everything is
already copied from config to pre-objects anyway, and then from
templates to pre-objects, we really needn't bother with it when
creating the real objects too.

This cuts down the number of memory allocations by quite a significant
amount. We still copy everything from services though, since those
are duplicated per-object, and releasing duplicated services would
otherwise lead to heap corruption on double-free when we exit or
reload.

Signed-off-by: Andreas Ericsson <ae@op5.se>
core: Stop leaking neb-modules on reloads and shutdowns

Only 40-ish bytes per module, but it's good to get valgrind to
shut the hell up.

Signed-off-by: Andreas Ericsson <ae@op5.se>
core: Make valgrind report leaked and reachable memory more accurately

Mostly for the --verify-config case though, where we have to free
the nebmod lists and some miscellaneous variables.

Signed-off-by: Andreas Ericsson <ae@op5.se>
xod: Avoid printf() calls

Changing it to a logging call makes a lot more sense.

Signed-off-by: Andreas Ericsson <ae@op5.se>
core: free() more variables when quitting

While we'd like to get "No leaks possible" from valgrind, we'll
have to settle for the memory my_strtok() allocates and keeps a
pointer to (for now anyways).

We also make sure to assign more of the "runtime constant" macros
from our global variables, to avoid tracking both of them for leaks.

Signed-off-by: Andreas Ericsson <ae@op5.se>
xod: Launch a massive strike in the war against strdup()

We already get an allocated and duplicated buffer from mmap_fgets(),
so there's no need for us copy it again, and then once more to get
the value part of the variable in a separate string.

Instead, we avoid the two extra copies per object config entry and
simply modify the input in-place.

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