make range allocation dynamic

This is a test fix after commit

5cbe8d07fb

to see what can be done. Truth is that not much. I could fix how
ranges are allocated, but the fact there is pointers to shared
networks and network names reallocating the memory spaces is not
really going to work. The only way to truly fix this issue is to
create better data structures. As you can expect that is a major
change, and will take some time to implement.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
This commit is contained in:
Sami Kerola 2011-04-10 19:12:29 +02:00
parent f6880ed5f4
commit b492802dfa
6 changed files with 33 additions and 17 deletions

View file

@ -386,9 +386,14 @@ char *parse_config(int is_include, char *config_file,
range_p->backups = 0;
range_p->shared_net = shared_p;
num_ranges++;
if (RANGES < num_ranges) {
errx(EXIT_FAILURE,
"parse_config: increase default.h RANGES and recompile.");
if (RANGES < num_ranges + 1) {
RANGES *= 2;
ranges =
safe_realloc(ranges,
sizeof(struct
range_t) *
RANGES);
range_p = ranges + num_ranges;
}
newclause = true;
break;
@ -429,13 +434,14 @@ char *parse_config(int is_include, char *config_file,
errx(EXIT_FAILURE,
"parse_config: increase default.h SHARED_NETWORKS_NAMES and recompile");
}
if (SHARED_NETWORKS < num_shared_networks) {
/* FIXME: make this go
if (SHARED_NETWORKS <
num_shared_networks + 2) {
/* FIXME: make this
* away by reallocationg
* more space. */
errx(EXIT_FAILURE,
"parse_config: increase default.h SHARED_NETWORKS and recompile");
}
}
argument = 0;
braces_shared = braces;
break;