analysis: shared networks to be linked list

This way memory is allocated only for items that are in use, and walking
through shared network items is also more straightforward.

As an unfortunate side effect in --perfdata output shared networks are no
longer printed in reverse order.  This should be a cosmetic issue.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
This commit is contained in:
Sami Kerola 2017-11-12 16:50:19 +00:00
parent a237c11d5a
commit ef5421ed05
No known key found for this signature in database
GPG key ID: A9553245FDE9B739
8 changed files with 84 additions and 100 deletions

View file

@ -78,12 +78,11 @@ static int return_limit(const char c)
* initializations, etc are here. */
static void prepare_memory(struct conf_t *state)
{
/* The SHARED_NETWORKS is a static value from defaults.h */
state->shared_networks = xcalloc(sizeof(struct shared_network_t), SHARED_NETWORKS);
state->ranges = xmalloc(sizeof(struct range_t) * state->ranges_size);
/* First shared network entry is all networks */
state->shared_networks->name = xstrdup("All networks");
state->shared_net_root = xcalloc(sizeof(struct shared_network_t), 1);
state->shared_net_root->name = xstrdup("All networks");
state->shared_net_head = state->shared_net_root;
}
/*! \brief Start of execution. Parse options, and call other other
@ -306,7 +305,7 @@ int main(int argc, char **argv)
}
/* Do the job */
parse_config(&state, 1, state.dhcpdconf_file, state.shared_networks);
parse_config(&state, 1, state.dhcpdconf_file, state.shared_net_root);
if (output_format == 'X' || output_format == 'J')
parse_leases(&state, 1);
else