don't segfault when running out of globals

This commit is contained in:
Bill Currie 2005-06-10 05:16:20 +00:00
parent 9f662787e0
commit 116860bb66
2 changed files with 8 additions and 1 deletions

View File

@ -362,8 +362,13 @@ new_location (type_t *type, defspace_t *space)
}
ofs = space->size;
space->size += size;
if (space->size > space->max_size)
if (space->size > space->max_size) {
if (!space->grow) {
error (0, "unable to allocate %d globals", size);
exit (1);
}
space->grow (space);
}
return ofs;
}

View File

@ -154,6 +154,8 @@ InitData (void)
pr.near_data = new_defspace ();
pr.near_data->data = calloc (65536, sizeof (pr_type_t));
pr.near_data->max_size = 65536;
pr.near_data->grow = 0;
pr.scope = new_scope (sc_global, pr.near_data, 0);
current_scope = pr.scope;